org.openide.util.datatransfer.MultiTransferObject Java Examples
The following examples show how to use
org.openide.util.datatransfer.MultiTransferObject.
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: DragDropUtilitiesTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMultiTransferableForCopy() throws Exception { N node = new N(); N n2 = new N(); N[] arr = { node, n2 }; Transferable t = DragDropUtilities.getNodeTransferable(arr, NodeTransfer.DND_COPY); assertEquals("One call to copy", 1, node.copy); assertEquals("One call to copy on n2", 1, n2.copy); assertEquals("Also one call to drag which delegates to copy", 1, node.drag); assertEquals("Also one call to drag which delegates to copy on n2", 1, n2.drag); assertEquals("No call to cut", 0, node.cut); assertEquals("No call to cut", 0, n2.cut); assertNotNull("Call to convertor", last); assertTrue("multi flavor supported", last.isDataFlavorSupported(ExTransferable.multiFlavor)); Object obj = last.getTransferData(ExTransferable.multiFlavor); if (!( obj instanceof MultiTransferObject)) { fail("It should be MultiTransferObject: " + obj); } MultiTransferObject m = (MultiTransferObject)obj; assertEquals("Two in multi", 2, m.getCount()); assertTrue("Is string", m.getTransferData(0, DataFlavor.stringFlavor) instanceof String); assertTrue("Is string2", m.getTransferData(1, DataFlavor.stringFlavor) instanceof String); }
Example #2
Source File: DragDropUtilitiesTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMultiTransferableForCut() throws Exception { N node = new N(); N n2 = new N(); N[] arr = { node, n2 }; Transferable t = DragDropUtilities.getNodeTransferable(arr, NodeTransfer.DND_MOVE); assertEquals("One call to cut ", 1, node.cut); assertEquals("One call to cut on n2", 1, n2.cut); assertEquals("No to drag", 0, node.drag); assertEquals("No to drag on n2", 0, n2.drag); assertEquals("No call to copy", 0, node.copy); assertEquals("No call to copy on n2", 0, n2.copy); assertNotNull("Call to convertor", last); assertTrue("multi flavor supported", last.isDataFlavorSupported(ExTransferable.multiFlavor)); Object obj = last.getTransferData(ExTransferable.multiFlavor); if (!( obj instanceof MultiTransferObject)) { fail("It should be MultiTransferObject: " + obj); } MultiTransferObject m = (MultiTransferObject)obj; assertEquals("Two in multi", 2, m.getCount()); assertTrue("Is string", m.getTransferData(0, DataFlavor.stringFlavor) instanceof String); assertTrue("Is string2", m.getTransferData(1, DataFlavor.stringFlavor) instanceof String); }
Example #3
Source File: WidgetDropListenerImpl.java From jeddict with Apache License 2.0 | 5 votes |
private boolean isDBFlavor(Transferable transferable) { DataFlavor[] flavors = transferable.getTransferDataFlavors(); for (DataFlavor flavor : flavors) { Object transferData = null; try { transferData = transferable.getTransferData(flavor); } catch (UnsupportedFlavorException | IOException ex) { } if (DB_TYPE.equals(flavor.getSubType()) && PRIMARY_TYPE.equals(flavor.getPrimaryType())) { return true; } else if (transferData instanceof MultiTransferObject) { MultiTransferObject multiTransfer = (MultiTransferObject) transferData; for (int i = 0; i < multiTransfer.getCount(); i++) { if (isDBFlavor(multiTransfer.getTransferableAt(i))) { return true; } } } else if ("org.netbeans.modules.db.explorer.node.TableListNode" .equals(transferData.getClass().getName()) || "org.netbeans.modules.db.explorer.node.SchemaNode" .equals(transferData.getClass().getName())) { return true; } else if ("org.netbeans.modules.db.explorer.node.ConnectionNode" .equals(transferData.getClass().getName())) { return false; } } return false; }
Example #4
Source File: FileTable.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override public boolean canImport(TransferHandler.TransferSupport info) { if(info.isDataFlavorSupported(DataFlavor.stringFlavor)) return true; try { if(info.getDataFlavors().length > 0) { Object transferData = info.getTransferable().getTransferData(info.getDataFlavors()[0]); if (transferData instanceof PNode) { return true; } else if(transferData instanceof MultiTransferObject) { final MultiTransferObject multi = (MultiTransferObject) transferData; boolean allPNode = true; DataFlavor dataFlavor = multi.getTransferDataFlavors(0)[0]; for(int i=0; i < multi.getCount(); ++i) { Object data = multi.getTransferData(i, dataFlavor); if(!(data instanceof PNode)) { allPNode = false; break; } } return allPNode; } } } catch (Exception e) { return false; } return false; }