java.awt.dnd.DnDConstants Java Examples
The following examples show how to use
java.awt.dnd.DnDConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SunDropTargetContextPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * mapOperation */ private int mapOperation(int operation) { int[] operations = { DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY, DnDConstants.ACTION_LINK, }; int ret = DnDConstants.ACTION_NONE; for (int i = 0; i < operations.length; i++) { if ((operation & operations[i]) == operations[i]) { ret = operations[i]; break; } } return ret; }
Example #2
Source File: ImageTransferTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #3
Source File: SunDropTargetContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * mapOperation */ private int mapOperation(int operation) { int[] operations = { DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY, DnDConstants.ACTION_LINK, }; int ret = DnDConstants.ACTION_NONE; for (int i = 0; i < operations.length; i++) { if ((operation & operations[i]) == operations[i]) { ret = operations[i]; break; } } return ret; }
Example #4
Source File: XDragSourceContextPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void doUpdateTargetWindow(long subwindow, long time) { long clientWindow = 0; long proxyWindow = 0; XDragSourceProtocol protocol = null; boolean isReceiver = false; if (subwindow != 0) { clientWindow = findClientWindow(subwindow); } if (clientWindow != 0) { Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols(); while (dragProtocols.hasNext()) { XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next(); if (dragProtocol.attachTargetWindow(clientWindow, time)) { protocol = dragProtocol; break; } } } /* Update the global state. */ dragProtocol = protocol; targetAction = DnDConstants.ACTION_NONE; targetRootSubwindow = subwindow; }
Example #5
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * mapOperation */ private int mapOperation(int operation) { int[] operations = { DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY, DnDConstants.ACTION_LINK, }; int ret = DnDConstants.ACTION_NONE; for (int i = 0; i < operations.length; i++) { if ((operation & operations[i]) == operations[i]) { ret = operations[i]; break; } } return ret; }
Example #6
Source File: WMouseDragGestureRecognizer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Invoked when a mouse button is pressed on a component. */ @Override public void mouseDragged(MouseEvent e) { if (!events.isEmpty()) { // gesture pending int dop = mapDragOperationFromModifiers(e); if (dop == DnDConstants.ACTION_NONE) { return; } MouseEvent trigger = (MouseEvent)events.get(0); Point origin = trigger.getPoint(); Point current = e.getPoint(); int dx = Math.abs(origin.x - current.x); int dy = Math.abs(origin.y - current.y); if (dx > motionThreshold || dy > motionThreshold) { fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint()); } else appendEvent(e); } }
Example #7
Source File: ImageTransferTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #8
Source File: XMouseDragGestureRecognizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Invoked when a mouse button is pressed on a component. */ public void mouseDragged(MouseEvent e) { if (!events.isEmpty()) { // gesture pending int dop = mapDragOperationFromModifiers(e); if (dop == DnDConstants.ACTION_NONE) { return; } MouseEvent trigger = (MouseEvent)events.get(0); Point origin = trigger.getPoint(); Point current = e.getPoint(); int dx = Math.abs(origin.x - current.x); int dy = Math.abs(origin.y - current.y); if (dx > motionThreshold || dy > motionThreshold) { fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint()); } else appendEvent(e); } }
Example #9
Source File: SymbolTreePlugin3Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testDropSiteOK2() throws Exception { // verify that a SymbolCategory is not a valid drop site GTreeNode nsNode = rootNode.getChild(5); util.createObject(nsNode, "MyNamespace", createNamespaceAction); GTreeNode fNode = rootNode.getChild(2); util.expandNode(fNode); GTreeNode gNode = fNode.getChild(1); GTreeNode sNode = fNode.getChild(2); util.selectNodes(new GTreeNode[] { gNode, sNode }); GTreeNode extNode = rootNode.getChild(0); DataFlavor flavor = ((SymbolTreeNode) gNode).getNodeDataFlavor(); GTreeDragNDropHandler dnd = util.getTree().getDragNDropHandler(); assertTrue( !dnd.isDropSiteOk(extNode, new DataFlavor[] { flavor }, DnDConstants.ACTION_MOVE)); assertTrue( !dnd.isDropSiteOk(extNode, new DataFlavor[] { flavor }, DnDConstants.ACTION_COPY)); }
Example #10
Source File: XDnDDragSourceProtocol.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean processXdndStatus(XClientMessageEvent xclient) { int action = DnDConstants.ACTION_NONE; /* Ignore XDnD messages from all other windows. */ if (xclient.get_data(0) != getTargetWindow()) { return true; } if ((xclient.get_data(1) & XDnDConstants.XDND_ACCEPT_DROP_FLAG) != 0) { /* This feature is new in XDnD version 2, but we can use it as XDnD compliance only requires supporting version 3 and up. */ action = XDnDConstants.getJavaActionForXDnDAction(xclient.get_data(4)); } getProtocolListener().handleDragReply(action); return true; }
Example #11
Source File: FrontEndPluginActionsTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testDragCopyFile2Folder() throws Exception { DomainFolder f = rootFolder.createFolder("myFolder"); createNotepadFile(f); GTreeNode winNode = getChild(rootNode, "tms"); GTreeNode myNode = getChild(rootNode, "myFolder"); assertNotNull(myNode); setSelectionPaths(new TreePath[] { myNode.getTreePath() }); doDrag(myNode, DnDConstants.ACTION_COPY, winNode); waitForTree(); // myFolder should have 2 files expandTreePath(myNode.getTreePath()); assertEquals(2, myNode.getChildCount()); assertNotNull(getChild(rootNode, "tms")); }
Example #12
Source File: WMouseDragGestureRecognizer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Invoked when a mouse button is pressed on a component. */ @Override public void mouseDragged(MouseEvent e) { if (!events.isEmpty()) { // gesture pending int dop = mapDragOperationFromModifiers(e); if (dop == DnDConstants.ACTION_NONE) { return; } MouseEvent trigger = (MouseEvent)events.get(0); Point origin = trigger.getPoint(); Point current = e.getPoint(); int dx = Math.abs(origin.x - current.x); int dy = Math.abs(origin.y - current.y); if (dx > motionThreshold || dy > motionThreshold) { fireDragGestureRecognized(dop, ((MouseEvent)getTriggerEvent()).getPoint()); } else appendEvent(e); } }
Example #13
Source File: ImageTransferTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
ImageDragSource() { formats = retrieveFormatsToTest(); passedArray = new boolean[formats.length]; final DragSourceListener dsl = new DragSourceAdapter() { public void dragDropEnd(DragSourceDropEvent e) { System.err.println("Drop was successful=" + e.getDropSuccess()); notifyTransferSuccess(e.getDropSuccess()); if (++fi < formats.length) { leaveFormat(formats[fi]); } } }; new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_COPY, dge -> dge.startDrag(null, new ImageSelection(image), dsl)); leaveFormat(formats[fi]); }
Example #14
Source File: WMouseDragGestureRecognizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * determine the drop action from the event */ protected int mapDragOperationFromModifiers(MouseEvent e) { int mods = e.getModifiersEx(); int btns = mods & ButtonMask; // Prohibit multi-button drags. if (!(btns == InputEvent.BUTTON1_DOWN_MASK || btns == InputEvent.BUTTON2_DOWN_MASK || btns == InputEvent.BUTTON3_DOWN_MASK)) { return DnDConstants.ACTION_NONE; } return SunDragSourceContextPeer.convertModifiersToDropAction(mods, getSourceActions()); }
Example #15
Source File: SunDropTargetContextPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * mapOperation */ private int mapOperation(int operation) { int[] operations = { DnDConstants.ACTION_MOVE, DnDConstants.ACTION_COPY, DnDConstants.ACTION_LINK, }; int ret = DnDConstants.ACTION_NONE; for (int i = 0; i < operations.length; i++) { if ((operation & operations[i]) == operations[i]) { ret = operations[i]; break; } } return ret; }
Example #16
Source File: MissingDragExitEventTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example #17
Source File: MissingDragExitEventTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example #18
Source File: QuietEditorPane.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void dragOver(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.dragOver(dtde); isDragging = true; }
Example #19
Source File: DragManager.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates a new instance of SplashDnDSupport */ DragManager(JComponent component) { this.component = component; dSource = new DragSource(); dRecognizer = dSource.createDefaultDragGestureRecognizer(this.component,DnDConstants.ACTION_MOVE,this); dTarget = new DropTarget(this.component,DnDConstants.ACTION_MOVE,this); component.addMouseMotionListener(this); oCursor = component.getCursor(); }
Example #20
Source File: DBColumnDrop.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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; }
Example #21
Source File: UnusedBindingsPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Initializes the three with unused bindings. */ private void initTreeView() { treeView = new BeanTreeView(); treeView.setAllowedDragActions(DnDConstants.ACTION_NONE); treeView.setAllowedDropActions(DnDConstants.ACTION_NONE); treeView.setRootVisible(false); }
Example #22
Source File: SourceFileListFrame.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
SourceFileListFrame() { super("Source File List Frame"); extractFilesFromTheWorkingDirectory(); initList(); initGUI(); new DragSource().createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY,this); }
Example #23
Source File: SourcePanel.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public SourcePanel() { setPreferredSize(new Dimension(200, 200)); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener); setBackground(Color.RED); }
Example #24
Source File: Trace.java From Method_Trace_Tool with Apache License 2.0 | 5 votes |
public static void drag()//定义的拖拽方法 { //panel表示要接受拖拽的控件 new DropTarget(JlPath, DnDConstants.ACTION_COPY_OR_MOVE, new DropTargetAdapter() { public void drop(DropTargetDropEvent dtde)//重写适配器的drop方法 { try { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor))//如果拖入的文件格式受支持 { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);//接收拖拽来的数据 List<File> list = (List<File>) (dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor)); String temp = ""; for (File file : list) { temp = file.getAbsolutePath(); JlPath.setText(temp); break; } //JOptionPane.showMessageDialog(null, temp); dtde.dropComplete(true);//指示拖拽操作已完成 } else { dtde.rejectDrop();//否则拒绝拖拽来的数据 } } catch (Exception e) { e.printStackTrace(); } } }); }
Example #25
Source File: SunDropTargetContextPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * signal drop complete */ public synchronized void dropComplete(boolean success) { if (dropStatus == STATUS_NONE) { throw new InvalidDnDOperationException("No Drop pending"); } if (currentDTC != null) { AWTAccessor.getDropTargetContextAccessor().reset(currentDTC); } currentDT = null; currentDTC = null; currentT = null; currentA = DnDConstants.ACTION_NONE; synchronized(_globalLock) { currentJVMLocalSourceTransferable = null; } dropStatus = STATUS_NONE; dropComplete = true; try { doDropDone(success, currentDA, local != null); } finally { currentDA = DnDConstants.ACTION_NONE; // The native context is invalid after the drop is done. // Clear the reference to prohibit access. nativeDragContext = 0; } }
Example #26
Source File: SourcePanel.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public SourcePanel() { setPreferredSize(new Dimension(200, 200)); DragSource defaultDragSource = DragSource.getDefaultDragSource(); defaultDragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, dragGestureListener); setBackground(Color.RED); }
Example #27
Source File: XMouseDragGestureRecognizer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Invoked when the mouse exits a component. */ public void mouseExited(MouseEvent e) { if (!events.isEmpty()) { // gesture pending int dragAction = mapDragOperationFromModifiers(e); if (dragAction == DnDConstants.ACTION_NONE) { events.clear(); } } }
Example #28
Source File: ProgramTreePlugin3Test.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testDnDCopyFrag2FragInvalid() throws Exception { // drag/copy a fragment onto another fragment // verify that there is no valid drop target ProgramNode textNode = root.getChild(".text"); ProgramNode debugNode = root.getChild(".debug_data"); assertTrue(!dndManager.isDropSiteOk(debugNode, new ProgramNode[] { textNode }, DnDConstants.ACTION_COPY, 0)); }
Example #29
Source File: SunDropTargetContextPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * signal drop complete */ public synchronized void dropComplete(boolean success) { if (dropStatus == STATUS_NONE) { throw new InvalidDnDOperationException("No Drop pending"); } if (currentDTC != null) currentDTC.removeNotify(); currentDT = null; currentDTC = null; currentT = null; currentA = DnDConstants.ACTION_NONE; synchronized(_globalLock) { currentJVMLocalSourceTransferable = null; } dropStatus = STATUS_NONE; dropComplete = true; try { doDropDone(success, currentDA, local != null); } finally { currentDA = DnDConstants.ACTION_NONE; // The native context is invalid after the drop is done. // Clear the reference to prohibit access. nativeDragContext = 0; } }
Example #30
Source File: SourceFileListFrame.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
SourceFileListFrame() { super("Source File List Frame"); extractFilesFromTheWorkingDirectory(); initList(); initGUI(); new DragSource().createDefaultDragGestureRecognizer(list, DnDConstants.ACTION_COPY,this); }