public void drop(DropTargetDropEvent dtde) { logger.info("Drop: " + dtde); if (dtde.isDataFlavorSupported(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR)) { try { List<OWLObject> objects = (List<OWLObject>) dtde.getTransferable().getTransferData(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR); List<OWLClass> clses = new ArrayList<OWLClass>(); for (OWLObject obj : objects) { if (obj instanceof OWLClass) { clses.add((OWLClass) obj); } } if (!clses.isEmpty()) { getAssertedGraphComponent().getVisualisedObjectManager().showObjects(clses.toArray()); dtde.dropComplete(true); } } catch (UnsupportedFlavorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
public void drop(DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { try { content = (java.util.List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor); repaint(); } catch (UnsupportedFlavorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } dtde.dropComplete(true); boolean listsAreEqual = true; for (int i = 0; i < content.size(); i++) { if (!FileListTransferable.files[i].getName().equals(content.get(i).getName())) { listsAreEqual = false; } } if (listsAreEqual) { System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL); System.exit(0); } } dtde.rejectDrop(); System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED); System.exit(1); }
public void drop(DropTargetDropEvent event) { if (!isDropAcceptable(event)) { event.rejectDrop(); return; } event.acceptDrop(DnDConstants.ACTION_COPY); Transferable transferable = event.getTransferable(); MessageCollection messages = new MessageCollection(); try { List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor); for (File file : files) { try { ResourceLocator locator = new ResourceLocator(file.getAbsolutePath()); IGV.getInstance().load(locator, panel); } catch (DataLoadException de) { messages.append(de.getMessage()); } } String obj = transferable.getTransferData(DataFlavor.stringFlavor).toString(); if (HttpUtils.isRemoteURL(obj)) { IGV.getInstance().load(new ResourceLocator(obj), panel); } if (messages != null && !messages.isEmpty()) { log.error(messages.getFormattedMessage()); MessageUtils.showMessage(messages.getFormattedMessage()); } } catch (Exception e) { String obj = null; try { obj = transferable.getTransferData(DataFlavor.stringFlavor).toString(); if (HttpUtils.isRemoteURL(obj)) { IGV.getInstance().load(new ResourceLocator(obj), panel); } } catch (Exception e1) { log.error(e1); if (messages != null && !messages.isEmpty()) { MessageUtils.showMessage(messages.getFormattedMessage()); } } } IGV.getMainFrame().repaint(); event.dropComplete(true); }
private DropData convertEventIntoDropData(DropTargetDropEvent dropTargetDropEvent) { Transferable transferable = dropTargetDropEvent.getTransferable(); Point tableLocation = getTableLocationForEvent(dropTargetDropEvent); if (null != _underlyingTable.getValueAt(tableLocation.x, tableLocation.y)) { return null; } Instance entry; try { entry = (Instance) transferable.getTransferData(_flavor); } catch (Exception e) { return null; } if ((null == entry) || !entry.hasType(_entryCls)) { return null; } return new DropData(tableLocation, entry); }
@Override public void drop(DropTargetDropEvent dtde) { try { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY); Transferable t = dtde.getTransferable(); List list = (List) t.getTransferData(DataFlavor.javaFileListFlavor); for (Object o : list) { if (o instanceof File) { File f = (File) o; System.out.println(f.getAbsolutePath()); } } dtde.dropComplete(true); return; } } catch (UnsupportedFlavorException | IOException ex) { ex.printStackTrace(); } dtde.rejectDrop(); }
public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); StringBuffer dropData = null; DataFlavor dtf; JConfig.log().logVerboseDebug("Dropping!"); if (t.getTransferDataFlavors().length == 0) { Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable t2 = sysClip.getContents(null); DataFlavor[] dfa2; int j; JConfig.log().logDebug("Dropped 0 data flavors, trying clipboard."); dfa2 = null; if (t2 != null) { JConfig.log().logVerboseDebug("t2 is not null: " + t2); dfa2 = t2.getTransferDataFlavors(); JConfig.log().logVerboseDebug("Back from getTransferDataFlavors()!"); } else { JConfig.log().logVerboseDebug("t2 is null!"); } if (JConfig.queryConfiguration("debug.uber", "false").equals("true")) { if (dfa2 != null) { if (dfa2.length == 0) { JConfig.log().logVerboseDebug("Length is still zero!"); } for (j = 0; j < dfa2.length; j++) { JConfig.log() .logVerboseDebug("Flavah " + j + " == " + dfa2[j].getHumanPresentableName()); JConfig.log().logVerboseDebug("Flavah/mime " + j + " == " + dfa2[j].getMimeType()); } } else { JConfig.log().logVerboseDebug("Flavahs supported: none!\n"); } } } if (JConfig.queryConfiguration("debug.uber", "false").equals("true") && JConfig.debugging) dumpFlavorsOld(t); dtf = testAllFlavors(t); if (dtf != null) { JConfig.log().logVerboseDebug("Accepting!"); acceptDrop(dtde); dropData = getTransferData(t); dtde.dropComplete(true); dtde.getDropTargetContext().dropComplete(true); if (dropData != null) { if (handler != null) { handler.receiveDropString(dropData); } } } else { JConfig.log().logVerboseDebug("Rejecting!"); dtde.rejectDrop(); handler.receiveDropString(dropData); } }