@Override public boolean canDrop(DropTargetDragEvent e) { //check if the JEditorPane contains html document JEditorPane pane = findPane(e.getDropTargetContext().getComponent()); if (pane == null) { return false; } int offset = getLineEndOffset(pane, e.getLocation()); if (!containsLanguageAtOffset(pane.getDocument(), offset)) { return false; } else { //update the caret as the user drags the object //needs to be done explicitly here as QuietEditorPane doesn't call //the original Swings DropTarget which does this pane.setCaretPosition(offset); pane.requestFocusInWindow(); //pity we need to call this all the time when dragging, but ExternalDropHandler don't handle dragEnter event return canDrop(e.getCurrentDataFlavors()); } }
@Override public void dragEnter(DropTargetDragEvent dtde) { accept = null; value = null; for (DataFlavor dataFlavor : dtde.getCurrentDataFlavors()) { Object obj = null; try { obj = dtde.getTransferable().getTransferData(dataFlavor); } catch (Exception ex) { continue; } if (dataFlavor.isFlavorJavaFileListType()) { accept = dataFlavor; value = obj; break; } if ("text".equals(dataFlavor.getPrimaryType()) && "uri-list".equals(dataFlavor.getSubType()) && dataFlavor.getRepresentationClass() == String.class) { accept = dataFlavor; value = (String) obj; break; } } if (accept != null) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } }
@Override public void dragEnter(DropTargetDragEvent dtde) { if ( ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) != 0) && (dtde.getTransferable().isDataFlavorSupported(JDDLTransferData.DATA_FLAVOR)) ) { dtde.acceptDrag(DnDConstants.ACTION_MOVE); } else { dtde.rejectDrag(); } }
/** * Creates a drop target drag event. * @param id the event id * @param event the Swing event */ public WidgetDropTargetDragEvent (long id, DropTargetDragEvent event) { this.id = id; this.event = event; Point location = event.getLocation (); x = location.x; y = location.y; }
private boolean shouldRedispatchDnDToHandle(DropTargetDragEvent dtde) { RADComponent rad = formDesigner.getHandleLayer().getMetaComponentAt(dtde.getLocation(), HandleLayer.COMP_DEEPEST); if(rad != null && isMenuRelatedComponentClass(rad.getBeanClass())) { return false; } if(!USE_JSEPARATOR_FIX) return false; PaletteItem item = PaletteUtils.getSelectedItem(); if(item != null && JSeparator.class.isAssignableFrom(item.getComponentClass())) { return true; } return false; }
@Override public void dragEnter(DropTargetDragEvent dtde) { if(shouldRedispatchDnDToHandle(dtde)) { dragProxying = true; formDesigner.getHandleLayer().getNewComponentDropListener().dragEnter(dtde); return; } if(!dragop.isStarted()) { start(dtde); } }
@Override public void dragOver(DropTargetDragEvent dtde) { // look at the rad component under the cursor first if(dragProxying && shouldRedispatchDnDToHandle(dtde)) { formDesigner.getHandleLayer().getNewComponentDropListener().dragOver(dtde); return; } dragProxying = false; if(dragop.isStarted()) { dragop.move(dtde.getLocation()); } else { start(dtde); } }
@Override public void dragEnter(DropTargetDragEvent dtde) { Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class); for (ExternalDropHandler handler : handlers) { if (handler.canDrop(dtde)) { dtde.acceptDrag(DnDConstants.ACTION_COPY); isDragging = false; return; } } orig.dragEnter(dtde); isDragging = true; }
/** * */ protected MouseEvent createEvent(DropTargetEvent e) { JComponent component = getDropTarget(e); Point location = null; int action = 0; if (e instanceof DropTargetDropEvent) { location = ((DropTargetDropEvent) e).getLocation(); action = ((DropTargetDropEvent) e).getDropAction(); } else if (e instanceof DropTargetDragEvent) { location = ((DropTargetDragEvent) e).getLocation(); action = ((DropTargetDragEvent) e).getDropAction(); } if (location != null) { location = convertPoint(location); Rectangle r = graphComponent.getViewport().getViewRect(); location.translate(r.x, r.y); } // LATER: Fetch state of modifier keys from event or via global // key listener using Toolkit.getDefaultToolkit().addAWTEventListener( // new AWTEventListener() {...}, AWTEvent.KEY_EVENT_MASK). Problem // is the event does not contain the modifier keys and the global // handler is not called during drag and drop. int mod = (action == TransferHandler.COPY) ? InputEvent.CTRL_MASK : 0; return new MouseEvent(component, 0, System.currentTimeMillis(), mod, location.x, location.y, 1, false, MouseEvent.BUTTON1); }
private void setupDropLine( DropTargetDragEvent dtde, CategoryList list, int dropIndex ) { boolean verticalDropBar = list.getColumnCount() > 1; Rectangle rect = list.getCellBounds( dropIndex, dropIndex ); if( verticalDropBar ) dropBefore = dtde.getLocation().x < (rect.x + rect.width/2); else dropBefore = dtde.getLocation().y < (rect.y + rect.height/2); Point p1 = rect.getLocation(); Point p2 = rect.getLocation(); if( verticalDropBar ) { p2.y += rect.height; if( !dropBefore ) { p1.x += rect.width; p2.x += rect.width; } } else { p2.x += rect.width; if( !dropBefore ) { p1.y += rect.height; p2.y += rect.height; } } p1 = SwingUtilities.convertPoint( list, p1, palette.getRootPane() ); p2 = SwingUtilities.convertPoint( list, p2, palette.getRootPane() ); Line2D line = new Line2D.Double( p1.x, p1.y, p2.x, p2.y ); dropPane.setDropLine( line ); targetItem = (Item)list.getModel().getElementAt( dropIndex ); }
public void dragEnter(DropTargetDragEvent e) { if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); isButtonDrag = true; //in case use is dragging something from the customizer window } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrag(); } }
public void dragOver(DropTargetDragEvent e) { if( e.isDataFlavorSupported( buttonDataFlavor ) || e.isDataFlavorSupported( actionDataFlavor ) ) { updateDropGesture( e ); if( !validateDropPosition() ) { e.rejectDrag(); } else { e.acceptDrag( DnDConstants.ACTION_COPY_OR_MOVE ); } } else if( e.isDataFlavorSupported( toolbarDataFlavor ) ) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrag(); } }
/** User is starting to drag over us */ public void dragEnter(DropTargetDragEvent dtde) { if (!checkConditions(dtde)) { dtde.rejectDrag(); } else { lastIndex = comp.locationToIndex(dtde.getLocation()); cellRenderer.draggingEnter(lastIndex, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation()); comp.repaint(comp.getCellBounds(lastIndex, lastIndex)); } }
/** User drag over us */ public void dragOver(DropTargetDragEvent dtde) { if (!checkConditions(dtde)) { dtde.rejectDrag(); if (lastIndex >= 0) { cellRenderer.draggingExit(); comp.repaint(comp.getCellBounds(lastIndex, lastIndex)); lastIndex = -1; } } else { dtde.acceptDrag(DnDConstants.ACTION_MOVE); int index = comp.locationToIndex(dtde.getLocation()); if (lastIndex == index) { cellRenderer.draggingOver(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation()); } else { if (lastIndex < 0) { lastIndex = index; } cellRenderer.draggingExit(); cellRenderer.draggingEnter(index, ids.getDragGestureEvent().getDragOrigin(), dtde.getLocation()); comp.repaint(comp.getCellBounds(lastIndex, index)); lastIndex = index; } } }
/** * Returns <code>JTable</code> palette item. * * @param dtde corresponding drop target drag event. * @return <code>JTable</code> palette item. */ @Override public PaletteItem getPaletteItem(DropTargetDragEvent dtde) { if (!assistantInitialized) { initAssistant(); } PaletteItem pItem; if (!J2EEUtils.hasPrimaryKey(table.getDatabaseConnection(), table.getTableName())) { FormEditor.getAssistantModel(model).setContext("tableWithoutPK"); // NOI18N return null; } if (FormJavaSource.isInDefaultPackage(model)) { // 97982: default package FormEditor.getAssistantModel(model).setContext("tableDefaultPackage"); // NOI18N return null; } setBindingOnly(dtde.getDropAction() == DnDConstants.ACTION_MOVE); if (isBindingOnly()) { FormEditor.getAssistantModel(model).setContext("tableDropBinding", "tableDropComponent"); // NOI18N pItem = new PaletteItem(new ClassSource("javax.persistence.EntityManager", // NOI18N new ClassSourceResolver.LibraryEntry(LibraryManager.getDefault().getLibrary("eclipselink"))), // NOI18N null); pItem.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/j2ee/resources/binding.gif", false).getImage()); // NOI18N } else { pItem = new PaletteItem(new ClassSource("javax.swing.JTable"), null); // NOI18N } return pItem; }
/** * Returns <code>EntityManager</code> palette item. * * @param dtde corresponding drop target drag event. * @return <code>EntityManager</code> palette item. */ @Override public PaletteItem getPaletteItem(DropTargetDragEvent dtde) { PaletteItem pItem = new PaletteItem(new ClassSource("javax.persistence.EntityManager", // NOI18N new ClassSourceResolver.LibraryEntry(LibraryManager.getDefault().getLibrary("eclipselink"))), // NOI18N null); pItem.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/j2ee/resources/EntityManager.png", false).getImage()); // NOI18N return pItem; }
/** * Returns <code>JTextField</code> palette item. * * @param dtde corresponding drop target drag event. * @return <code>JTextField</code> palette item. */ @Override public PaletteItem getPaletteItem(DropTargetDragEvent dtde) { PaletteItem pItem; if (!assistantInitialized) { initAssistant(); } if (!J2EEUtils.hasPrimaryKey(column.getDatabaseConnection(), column.getTableName())) { FormEditor.getAssistantModel(model).setContext("tableWithoutPK"); // NOI18N return null; } if (FormJavaSource.isInDefaultPackage(model)) { // 97982: default package FormEditor.getAssistantModel(model).setContext("columnDefaultPackage"); // NOI18N return null; } setBindingOnly(dtde.getDropAction() == DnDConstants.ACTION_MOVE); if (isBindingOnly()) { FormEditor.getAssistantModel(model).setContext("columnDropBinding", "columnDropComponent"); // NOI18N pItem = new PaletteItem(new ClassSource("javax.persistence.EntityManager", // NOI18N new ClassSourceResolver.LibraryEntry(LibraryManager.getDefault().getLibrary("eclipselink"))), // NOI18N null); pItem.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/j2ee/resources/binding.gif", false).getImage()); // NOI18N } else { pItem = new PaletteItem(new ClassSource("javax.swing.JTextField"), null); // NOI18N } return pItem; }
@Override public void dragEnter(final DropTargetDragEvent e) { super.dragEnter(e); if (dropTragetListenerList != null) { Object[] listeners = dropTragetListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DropTargetListener.class) { ((DropTargetListener) listeners[i + 1]).dragEnter(e); } } } }
@Override public void dragOver(final DropTargetDragEvent e) { super.dragOver(e); if (dropTragetListenerList != null) { Object[] listeners = dropTragetListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DropTargetListener.class) { ((DropTargetListener) listeners[i + 1]).dragOver(e); } } } }
@Override public void dropActionChanged(final DropTargetDragEvent e) { super.dropActionChanged(e); if (dropTragetListenerList != null) { Object[] listeners = dropTragetListenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == DropTargetListener.class) { ((DropTargetListener) listeners[i + 1]).dropActionChanged(e); } } } }
@Override public final void dragOver(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); int action = dtde.getDropAction(); autoscroll(tree, pt); if (drawImage) { paintImage(pt); } if (controller.canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } }
public void dragEnter(DropTargetDragEvent e) { final Component newDropWin = e.getDropTargetContext().getComponent(); if (newDropWin != dropWin) { final double newZoom = newDropWin instanceof Map.View ? ((Map.View) newDropWin).getMap().getZoom() : 1.0; if (Math.abs(newZoom - dragCursorZoom) > 0.01) { makeDragCursor(newZoom); } setDrawWinToOwnerOf(e.getDropTargetContext().getComponent()); dropWin = newDropWin; } super.dragEnter(e); }
@Override public final void dragEnter(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); int action = dtde.getDropAction(); if (drawImage) { paintImage(pt); } if (controller.canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } }
private void registerDndHandlers() { new DragSource().createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY, new DragGestureListener() { @Override public void dragGestureRecognized(DragGestureEvent dge) { Transferable t = new FileInfoTransferable(getSelectedFile()); dge.startDrag(DragSource.DefaultMoveDrop, t); } }); DnDUtils.registerDropHandler(this, dropHandlers, new HoverHandler() { @Override public void hovering(DropTargetDragEvent e) { FileInfo fi = getFileUnderMouseCursor(); if( fi == null ) { int i = getListIndexUnderPoint(e.getLocation()); if( i >= 0 ) { fi = model.get(i); } } if( fi != null && fi.isDirectory() ) { list.setSelectedValue(fi, true); } else { list.getSelectionModel().clearSelection(); } } }); }
public static boolean supportsNativeFileDrop(DropTargetDragEvent e) { for( DataFlavor flavor : e.getCurrentDataFlavors() ) { if( flavor.equals(DataFlavor.javaFileListFlavor) || flavor.isRepresentationClassReader() ) { return true; } } return false; }
@Override public final void dropActionChanged(DropTargetDragEvent dtde) { Point pt = dtde.getLocation(); int action = dtde.getDropAction(); if (drawImage) { paintImage(pt); } if (controller.canPerformAction(tree, draggedNode, action, pt)) { dtde.acceptDrag(action); } else { dtde.rejectDrag(); } }
/** * actual processing on EventQueue Thread */ protected void processEnterMessage(SunDropTargetEvent event) { Component c = (Component)event.getSource(); DropTarget dt = c.getDropTarget(); Point hots = event.getPoint(); local = getJVMLocalSourceTransferable(); if (currentDTC != null) { // some wreckage from last time currentDTC.removeNotify(); currentDTC = null; } if (c.isShowing() && dt != null && dt.isActive()) { currentDT = dt; currentDTC = currentDT.getDropTargetContext(); currentDTC.addNotify(this); currentA = dt.getDefaultActions(); try { ((DropTargetListener)dt).dragEnter(new DropTargetDragEvent(currentDTC, hots, currentDA, currentSA)); } catch (Exception e) { e.printStackTrace(); currentDA = DnDConstants.ACTION_NONE; } } else { currentDT = null; currentDTC = null; currentDA = DnDConstants.ACTION_NONE; currentSA = DnDConstants.ACTION_NONE; currentA = DnDConstants.ACTION_NONE; } }
public void dragOver(DropTargetDragEvent e) { if (!((mxGraphTransferHandler) graphContainer.getTransferHandler()) .isLocalDrag() && JTableRenderer.this != dragSource) { Point p = e.getLocation(); int row = rowAtPoint(p); getSelectionModel().setSelectionInterval(row, row); } }
public void dragOver(DropTargetDragEvent e) { if (!((mxGraphTransferHandler) graphContainer.getTransferHandler()).isLocalDrag() && JTableRenderer.this != dragSource) { Point p = e.getLocation(); int row = rowAtPoint(p); getSelectionModel().setSelectionInterval(row, row); } }
@Override public void dragEnter(final DropTargetDragEvent dtde) { if (inside) { FAILED = true; Thread.dumpStack(); } inside = true; MOUSE_ENTERED_DT = true; try { Thread.sleep(10000); // we should have time to leave a component } catch (InterruptedException ignored) { } }
@Override public void dragEnter(DropTargetDragEvent dtde) { dtde.acceptDrag(dtde.getDropAction()); }
@Override public void dropActionChanged(DropTargetDragEvent dtde) { }
public void dragEnter(DropTargetDragEvent dtde) { }
@Override public void dropActionChanged(DropTargetDragEvent dtde) { dtde.acceptDrag(dtde.getDropAction()); }
/** * * @param e */ public void dragOver(DropTargetDragEvent e) { if (canImport) { mouseDragged(createEvent(e)); mxGraphTransferHandler handler = getGraphTransferHandler(e); if (handler != null) { mxGraph graph = graphComponent.getGraph(); double scale = graph.getView().getScale(); Point pt = SwingUtilities.convertPoint(graphComponent, e.getLocation(), graphComponent.getGraphControl()); pt = graphComponent.snapScaledPoint(new mxPoint(pt)).getPoint(); handler.setLocation(new Point(pt)); int dx = 0; int dy = 0; // Centers the preview image if (centerPreview && transferBounds != null) { dx -= Math.round(transferBounds.getWidth() * scale / 2); dy -= Math.round(transferBounds.getHeight() * scale / 2); } // Sets the drop offset so that the location in the transfer // handler reflects the actual mouse position handler.setOffset(new Point((int) graph.snap(dx / scale), (int) graph.snap(dy / scale))); pt.translate(dx, dy); // Shifts the preview so that overlapping parts do not // affect the centering if (transferBounds != null && dragImage != null) { dx = (int) Math .round((dragImage.getIconWidth() - 2 - transferBounds.getWidth() * scale) / 2); dy = (int) Math .round((dragImage.getIconHeight() - 2 - transferBounds.getHeight() * scale) / 2); pt.translate(-dx, -dy); } if (!handler.isLocalDrag() && previewBounds != null) { setPreviewBounds(new Rectangle(pt, previewBounds.getSize())); } } } else { e.rejectDrag(); } }
public void dropActionChanged(DropTargetDragEvent dtde) { }
@Override public void dropActionChanged(DropTargetDragEvent dtde) { if (isDragging) { orig.dropActionChanged(dtde); } }