List of usage examples for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE
int ACTION_COPY_OR_MOVE
To view the source code for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.
Click Source Link
From source file:com.mirth.connect.client.ui.EditMessageDialog.java
public void dragEnter(DropTargetDragEvent dtde) { try {/*from w ww .jav a 2s. co m*/ Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator<File> iterator = fileList.iterator(); while (iterator.hasNext()) { iterator.next(); } } else { dtde.rejectDrag(); } } catch (Exception e) { dtde.rejectDrag(); } }
From source file:com.mirth.connect.client.ui.EditMessageDialog.java
public void drop(DropTargetDropEvent dtde) { try {//from w w w . ja va 2 s .co m Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator<File> iterator = fileList.iterator(); while (iterator.hasNext()) { File file = iterator.next(); messageContent.setText( messageContent.getText() + FileUtils.readFileToString(file, UIConstants.CHARSET)); } } } catch (Exception e) { dtde.rejectDrop(); } }
From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
public void dragEnter(DropTargetDragEvent dtde) { try {/*from ww w . j av a 2 s. co m*/ Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); List fileList = (List) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator iterator = fileList.iterator(); if (iterator.hasNext() && fileList.size() == 1) { String fileName = ((File) iterator.next()).getName(); if (!fileName.substring(fileName.lastIndexOf(".")).equalsIgnoreCase(".xml")) { dtde.rejectDrag(); } } else { dtde.rejectDrag(); } } else if (tr.isDataFlavorSupported(TreeTransferable.MAPPER_DATA_FLAVOR) || tr.isDataFlavorSupported(TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { dtde.rejectDrag(); } } catch (Exception e) { dtde.rejectDrag(); } }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
public void dragEnter(DropTargetDragEvent dtde) { try {/*from www. jav a 2 s . c om*/ Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); List fileList = (List) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator iterator = fileList.iterator(); if (iterator.hasNext() && fileList.size() == 1) { String fileName = ((File) iterator.next()).getName(); if (!fileName.substring(fileName.lastIndexOf(".")).equalsIgnoreCase(".xml")) { dtde.rejectDrag(); } } else { dtde.rejectDrag(); } } else if (tr.isDataFlavorSupported(TreeTransferable.RULE_DATA_FLAVOR)) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else { dtde.rejectDrag(); } } catch (Exception e) { dtde.rejectDrag(); } }
From source file:ScribbleDragAndDrop.java
/** * This method is invoked when the user first drags something over us. If we * understand the data type being dragged, then call acceptDrag() to tell * the system that we're receptive. Also, we change our border as a "drag * under" effect to signal that we can accept the drop. *///from w w w .ja v a 2 s .co m public void dragEnter(DropTargetDragEvent e) { if (e.isDataFlavorSupported(Scribble.scribbleDataFlavor) || e.isDataFlavorSupported(DataFlavor.stringFlavor)) { e.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); this.setBorder(dropBorder); } }
From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java
public void drop(DropTargetDropEvent dtde) { try {//from w w w . ja v a 2 s .c o m dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator<File> iterator = fileList.iterator(); if (fileList.size() == 1) { File file = (File) iterator.next(); importFilter(parent.readFileToString(file)); } } else if (tr.isDataFlavorSupported(TreeTransferable.RULE_DATA_FLAVOR)) { Object transferData = tr.getTransferData(TreeTransferable.RULE_DATA_FLAVOR); if (transferData instanceof RuleDropData) { RuleDropData data = (RuleDropData) transferData; addNewRule(MirthTree.constructNodeDescription(data.getNode()), data.getMapping()); } } } catch (Exception e) { dtde.rejectDrop(); } }
From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java
public void drop(DropTargetDropEvent dtde) { try {//from www .ja va2s . co m Transferable tr = dtde.getTransferable(); if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); List<File> fileList = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor); Iterator<File> iterator = fileList.iterator(); if (fileList.size() == 1) { File file = (File) iterator.next(); importTransformer(parent.readFileToString(file)); } } else if (tr.isDataFlavorSupported(TreeTransferable.MAPPER_DATA_FLAVOR) || tr.isDataFlavorSupported(TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR)) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Object mapperTransferData = tr.getTransferData(TreeTransferable.MAPPER_DATA_FLAVOR); Object messageBuilderTransferData = tr .getTransferData(TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR); if (mapperTransferData != null && !parent.isAcceleratorKeyPressed()) { Object transferData = tr.getTransferData(TreeTransferable.MAPPER_DATA_FLAVOR); MapperDropData data = (MapperDropData) transferData; addNewStep(data.getVariable(), data.getVariable(), data.getMapping(), MAPPER); } else if (mapperTransferData != null && parent.isAcceleratorKeyPressed()) { Object transferData = tr.getTransferData(TreeTransferable.MAPPER_DATA_FLAVOR); MapperDropData data2 = (MapperDropData) transferData; MessageBuilderDropData data = new MessageBuilderDropData(data2.getNode(), MirthTree.constructPath(data2.getNode().getParent(), "msg", "").toString(), ""); addNewStep(MirthTree.constructMessageBuilderStepName(null, data.getNode()), data.getMessageSegment(), data.getMapping(), MESSAGE_BUILDER); } else if (messageBuilderTransferData != null) { Object transferData = tr.getTransferData(TreeTransferable.MESSAGE_BUILDER_DATA_FLAVOR); MessageBuilderDropData data = (MessageBuilderDropData) transferData; addNewStep(MirthTree.constructMessageBuilderStepName(null, data.getNode()), data.getMessageSegment(), data.getMapping(), MESSAGE_BUILDER); } } } catch (Exception e) { dtde.rejectDrop(); } }
From source file:ScribbleDragAndDrop.java
/** * This is the key method of DropTargetListener. It is invoked when the user * drops something on us./* w w w .j ava 2s . c om*/ */ public void drop(DropTargetDropEvent e) { this.setBorder(normalBorder); // Restore the default border // First, check whether we understand the data that was dropped. // If we supports our data flavors, accept the drop, otherwise reject. if (e.isDataFlavorSupported(Scribble.scribbleDataFlavor) || e.isDataFlavorSupported(DataFlavor.stringFlavor)) { e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrop(); return; } // We've accepted the drop, so now we attempt to get the dropped data // from the Transferable object. Transferable t = e.getTransferable(); // Holds the dropped data Scribble droppedScribble; // This will hold the Scribble object // First, try to get the data directly as a scribble object try { droppedScribble = (Scribble) t.getTransferData(Scribble.scribbleDataFlavor); } catch (Exception ex) { // unsupported flavor, IO exception, etc. // If that doesn't work, try to get it as a String and parse it try { String s = (String) t.getTransferData(DataFlavor.stringFlavor); droppedScribble = Scribble.parse(s); } catch (Exception ex2) { // If we still couldn't get the data, tell the system we failed e.dropComplete(false); return; } } // If we get here, we've got the Scribble object Point p = e.getLocation(); // Where did the drop happen? droppedScribble.translate(p.getX(), p.getY()); // Move it there scribbles.add(droppedScribble); // add to display list repaint(); // ask for redraw e.dropComplete(true); // signal success! }
From source file:JTreeUtil.java
public static void configureDragAndDrop(JTree tree, JTreeDragController controller) { tree.setAutoscrolls(true);//from ww w. j a va2 s. c o m new TreeTransferHandler(tree, controller, DnDConstants.ACTION_COPY_OR_MOVE, true); }
From source file:com.eviware.soapui.SoapUI.java
private void buildUI() { // display used java version log.info("Used java version: " + System.getProperty("java.version")); frame.addWindowListener(new MainFrameWindowListener()); UISupport.setMainFrame(frame);// w w w.j a v a2s . c om navigator = new Navigator(workspace); navigator.addNavigatorListener(new InternalNavigatorListener()); desktopPanelsList = new JDesktopPanelsList(desktop); mainInspector = JInspectorPanelFactory.build(buildContentPanel(), SwingConstants.LEFT); mainInspector.addInspector( new JComponentInspector<JComponent>(buildMainPanel(), "Navigator", "The soapUI Navigator", true)); mainInspector.setCurrentInspector("Navigator"); frame.setJMenuBar(buildMainMenu()); frame.getContentPane().add(buildToolbar(), BorderLayout.NORTH); frame.getContentPane().add(mainInspector.getComponent(), BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setSize(1000, 750); mainInspector.setDividerLocation(250); mainInspector.setResizeWeight(0.1); navigator.selectModelItem(workspace); desktop.addDesktopListener(internalDesktopListener); ToolTipManager.sharedInstance().setInitialDelay(200); JTree mainTree = navigator.getMainTree(); DragSource dragSource = DragSource.getDefaultDragSource(); SoapUIDragAndDropHandler navigatorDragAndDropHandler = new SoapUIDragAndDropHandler( new NavigatorDragAndDropable(mainTree), DropType.ON + DropType.AFTER); dragSource.createDefaultDragGestureRecognizer(mainTree, DnDConstants.ACTION_COPY_OR_MOVE, navigatorDragAndDropHandler); desktop.init(); }