Java 类java.awt.dnd.DropTargetDropEvent 实例源码

项目:incubator-netbeans    文件:DragOperation.java   
void end(EventObject e, boolean clear) {
    Point pt = (e instanceof MouseEvent) ? ((MouseEvent)e).getPoint() : ((DropTargetDropEvent)e).getLocation();
    started = false;
    currentItem = null;
    if(dragComponent == null) return;
    if ((e instanceof DropTargetDropEvent)
            || ((e instanceof MouseEvent) && !((MouseEvent) e).isShiftDown())) {// #195795: Do not deselect the dropTarget when Shift is pressed
        menuEditLayer.layers.remove(dragComponent);
        menuEditLayer.dropTargetLayer.clearDropTarget();
    }

    switch (op) {
    case PICK_AND_PLOP_FROM_PALETTE: completePickAndPlopFromPalette(pt, clear); break;
    case INTER_MENU_DRAG: completeInterMenuDrag(pt); break ;
    case NO_MENUBAR: /* do nothing */ break;
    }

    menuEditLayer.glassLayer.requestFocusInWindow();
    if ((e instanceof DropTargetDropEvent)
            || ((e instanceof MouseEvent) && !((MouseEvent) e).isShiftDown())) {// #195795: Do not deselect the dropTarget when Shift is pressed
        payloadComponent = null;
        targetComponent = null;
    }
    menuEditLayer.repaint();

}
项目:incubator-netbeans    文件:QuietEditorPane.java   
@Override
public void drop(DropTargetDropEvent e) {
    Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
    for (ExternalDropHandler handler : handlers) {
        if (handler.canDrop(e)) {
            e.acceptDrop(DnDConstants.ACTION_COPY);
            boolean dropped = handler.handleDrop(e);
            if(!dropped) {
                continue; //try next ExternalDropHandler
            }
            e.dropComplete(true);
            isDragging = false;
            return;
        }
    }
    orig.drop(e);
    isDragging = false;
}
项目:incubator-netbeans    文件:DnDSupport.java   
public void drop(DropTargetDropEvent dtde) {
    boolean res = false;
    try {
        if( isButtonDrag ) {
            if( validateDropPosition() ) {
                res = handleDrop( dtde.getTransferable() );
            }
        } else if( isToolbarDrag ) {
            res = true;
            //taken care of in dragDropEnd()
        }
    } finally {
        dtde.dropComplete(res);
    }
    resetDropGesture();
}
项目:SubtitleDownloader    文件:SubtitleDownloaderUI.java   
@Override
public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        Transferable t = dtde.getTransferable();
        DataFlavor[] dataFlavors = t.getTransferDataFlavors();
        for (DataFlavor df : dataFlavors) {
            if (df.isFlavorJavaFileListType()) {
                File[] filesArray = (File[]) ((List<File>) t.getTransferData(df)).toArray();
                pathNameTextField.setText(getFilesName(filesArray));
            }
        }
    } catch (UnsupportedFlavorException e2) {
    } catch (IOException ex) {
        Logger.getLogger(SubtitleDownloaderUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:VASSAL-src    文件:Map.java   
public void drop(DropTargetDropEvent dtde) {
  if (dtde.getDropTargetContext().getComponent() == theMap) {
    final MouseEvent evt = new MouseEvent(
      theMap,
      MouseEvent.MOUSE_RELEASED,
      System.currentTimeMillis(),
      0,
      dtde.getLocation().x,
      dtde.getLocation().y,
      1,
      false
    );
    theMap.dispatchEvent(evt);
    dtde.dropComplete(true);
  }

  if (scroller.isRunning()) scroller.stop();
}
项目:Equella    文件:UploadAction.java   
@Override
public boolean handleDrop(DropTargetDropEvent e) throws Exception
{
    List<File> files = DnDUtils.getDroppedNativeFiles(e.getTransferable());
    try
    {
        FileInfo dir = fileList.getFileUnderMouseCursor();
        if( dir == null || !dir.isDirectory() )
        {
            dir = fileList.getCurrentDirectory();
        }

        uploadFiles(dir, files.toArray(new File[files.size()]));
        return true;
    }
    catch( Exception ex )
    {
        ex.printStackTrace();
        return false;
    }
}
项目:TrabalhoFinalEDA2    文件:mxGraphHandler.java   
/**
 * 
 * @param e
 */
public void drop(DropTargetDropEvent e)
{
    if (canImport)
    {
        mxGraphTransferHandler handler = getGraphTransferHandler(e);
        MouseEvent event = createEvent(e);

        // Ignores the event in mouseReleased if it is
        // handled by the transfer handler as a drop
        if (handler != null && !handler.isLocalDrag())
        {
            event.consume();
        }

        mouseReleased(event);
    }
}
项目:Tarski    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e)
{
    if (dragSource != null)
    {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge = graph.insertEdge(null, null, null,
                dragSource.cell, JTableRenderer.this.cell, "sourceRow="
                        + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
    }
    else
    {
        e.rejectDrop();
    }
}
项目:Tarski    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e) {
  if (dragSource != null) {
    e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    Point p = e.getLocation();
    int targetRow = rowAtPoint(p);

    Object edge = graph.insertEdge(null, null, null, dragSource.cell, JTableRenderer.this.cell,
        "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
    graph.setSelectionCell(edge);

    // System.out.println("clearing drag source");
    dragSource = null;
    e.dropComplete(true);
  } else {
    e.rejectDrop();
  }
}
项目:KATscans    文件:DraggableTree.java   
@Override
public void drop(DropTargetDropEvent dtde) {
    if (checkDropValid()) {
        int action = dtde.getDropAction();

        ProjectHandler project = ProjectHandler.getInstance();
        if (action == DnDConstants.ACTION_MOVE) {
            project.removeNodeFromParent(incomingNode);
        } else if (action == DnDConstants.ACTION_COPY) {
            incomingNode = incomingNode.copy();
        }

        project.insertNodeInto(incomingNode, targetNode, 0);
        expandPath(path);
        selectionModel.setSelectionPath(path.pathByAddingChild(incomingNode));

        dtde.acceptDrop(action);
    } else {
        dtde.rejectDrop();
    }

    finishDnD();
}
项目:OWLAx    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e)
{
    if (dragSource != null)
    {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge = graph.insertEdge(null, null, null,
                dragSource.cell, JTableRenderer.this.cell, "sourceRow="
                        + sourceRow + ";targetRow=" + targetRow, null);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
    }
    else
    {
        e.rejectDrop();
    }
}
项目:OWLAx    文件:mxGraphHandler.java   
/**
 * 
 * @param e
 */
public void drop(DropTargetDropEvent e)
{
    if (canImport)
    {
        mxGraphTransferHandler handler = getGraphTransferHandler(e);
        MouseEvent event = createEvent(e);

        // Ignores the event in mouseReleased if it is
        // handled by the transfer handler as a drop
        if (handler != null && !handler.isLocalDrag())
        {
            event.consume();
        }

        mouseReleased(event);
    }
}
项目:SporeModder    文件:AdvancedFileChooser.java   
@Override
public synchronized void drop(DropTargetDropEvent event) {
    event.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        @SuppressWarnings("unchecked")
        List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);

        int count = droppedFiles.size();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < droppedFiles.size(); i++) {
            sb.append(droppedFiles.get(i));

            if (i != count-1) {
                sb.append("|");
            }
        }

        target.setText(sb.toString());

    } catch (UnsupportedFlavorException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:SporeModder    文件:DropTargetTextField.java   
public synchronized void drop(DropTargetDropEvent event) {
    event.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        @SuppressWarnings("unchecked")
        List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);

        int count = droppedFiles.size();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < droppedFiles.size(); i++) {
            sb.append(droppedFiles.get(i));

            if (i != count-1) {
                sb.append("|");
            }
        }

        target.setText(sb.toString());

    } catch (UnsupportedFlavorException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:bigtable-sql    文件:RecentFilesController.java   
private void initDnD()
{
   TreeDnDHandlerCallback treeDnDHandlerCallback = new TreeDnDHandlerCallback()
   {
      @Override
      public boolean nodeAcceptsKids(DefaultMutableTreeNode selNode)
      {
         return onNodeAcceptsKids(selNode);
      }

      @Override
      public void dndExecuted()
      {
         onDndExecuted();
      }

      @Override
      public ArrayList<DefaultMutableTreeNode> createPasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
      {
         return onCreatePasteTreeNodesFromExternalTransfer(dtde, targetPath);
      }
   };

   new TreeDnDHandler(_dialog.treFiles, treeDnDHandlerCallback, true);
}
项目:bigtable-sql    文件:RecentFilesController.java   
private ArrayList<DefaultMutableTreeNode> onCreatePasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
{
   List<File> files = DropedFileExtractor.getFiles(dtde, _app);

   ArrayList<DefaultMutableTreeNode> ret = new ArrayList<DefaultMutableTreeNode>();

   DefaultMutableTreeNode parent = findParent(targetPath);
   for (File file : files)
   {
      if (false == parentContainsFile(parent, file))
      {
         ret.add(new DefaultMutableTreeNode(file));
      }
   }

   return ret;

}
项目:bigtable-sql    文件:FileEditorDropTargetListener.java   
/**
 * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
 */
public void drop(DropTargetDropEvent dtde) {
    try {
       File fileToOpen = DropedFileExtractor.getFile(dtde, _session.getApplication());

       if (fileToOpen != null) {
            if (s_log.isInfoEnabled()) {
                s_log.info("drop: path="+fileToOpen.getAbsolutePath());
            }            
            ISQLPanelAPI api = 
                _session.getSQLPanelAPIOfActiveSessionWindow(); 
            api.fileOpen(fileToOpen);
        }            
    } catch (Exception e) {
        s_log.error("drop: Unexpected exception "+e.getMessage(),e);
    }

}
项目:bigtable-sql    文件:JTreeAliasesListImpl.java   
private void initDnD()
{
   TreeDnDHandlerCallback treeDnDHandlerCallback = new TreeDnDHandlerCallback()
   {
      @Override
      public boolean nodeAcceptsKids(DefaultMutableTreeNode selNode)
      {
         return onNodeAcceptsKids(selNode);
      }

      @Override
      public void dndExecuted() {}

      @Override
      public ArrayList<DefaultMutableTreeNode> createPasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
      {
         return null;
      }
   };

   _treeDnDHandler = new TreeDnDHandler(_tree, treeDnDHandlerCallback);
}
项目:CentipeTextEditor    文件:TextArea.java   
public synchronized void drop(DropTargetDropEvent evt) {

       try {

           evt.acceptDrop(DnDConstants.ACTION_COPY);

           @SuppressWarnings("unchecked")
        List<File> droppedFiles = (List<File>)
               evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);

           for (File file : droppedFiles) {
            textWindow.getDocumentManager().startOpenFile( file.getAbsolutePath() );
           }

       } catch (Exception ex) {
        AlertDialog.showErrorDialog( textWindow.getFrame(), "File naming error!", AlertDialog.ERROR );
        //e.printStackTrace();
       }
}
项目:dsworkbench    文件:AbstractDSWorkbenchFrame.java   
@Override
public void drop(DropTargetDropEvent dtde) {
    if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    } else {
        dtde.rejectDrop();
        return;
    }

    Transferable t = dtde.getTransferable();
    List<Village> v;
    MapPanel.getSingleton().setCurrentCursor(MapPanel.getSingleton().getCurrentCursor());
    try {
        v = (List<Village>) t.getTransferData(VillageTransferable.villageDataFlavor);
        fireVillagesDraggedEvent(v, dtde.getLocation());
    } catch (Exception ignored) {
    }
}
项目:netbeans-mmd-plugin    文件:DnDUtils.java   
@Nullable
public static String extractDropLink(@Nonnull final DropTargetDropEvent dtde) throws Exception {
  String foundHtmlLink = null;
  String foundMozLink = null;
  for (final DataFlavor df : dtde.getCurrentDataFlavors()) {
    if (df.getRepresentationClass() == String.class) {
      if (foundHtmlLink == null && df.isMimeTypeEqual(MIME_TEXT_HTML)) {
        final String link = extractHtmlLink(true, (String) dtde.getTransferable().getTransferData(df));
        if (link != null) {
          foundHtmlLink = link;
        }
      }
    } else if (df.getRepresentationClass() == InputStream.class && df.isMimeTypeEqual(MIME_MOZ_URL)) {
      if (foundMozLink == null) {
        final InputStream in = ((InputStream) dtde.getTransferable().getTransferData(df));
        final StringWriter string = new StringWriter();
        IOUtils.copy(in, string);
        IOUtils.closeQuietly(in);
        foundMozLink = removeZeroChars(string.toString().split("\\n")[0]).trim();
      }
    }
  }
  return foundMozLink == null ? foundHtmlLink : foundMozLink;
}
项目:netbeans-mmd-plugin    文件:DnDTree.java   
@Override
public void drop(@Nonnull final DropTargetDropEvent dtde) {
  if (this.dragAcceptableType) {

    final Point dragPoint = dtde.getLocation();

    final TreePath path = getPathForLocation(dragPoint.x, dragPoint.y);

    if (path != null) {
      final Object dropTargetNode = path.getLastPathComponent();
      if (dropTargetNode instanceof NodeFileOrFolder) {
        final NodeFileOrFolder node = (NodeFileOrFolder) dropTargetNode;
        if (!node.isLeaf()) {
         //TODO processing of file drag in tree
         System.out.println("Not implemented yet!"); //NOI18N
        } else {
          dtde.rejectDrop();
        }
      }
    }

    repaint();
  }
}
项目:netbeans-mmd-plugin    文件:MMDEditor.java   
@Nullable
private File extractDropFile(@Nonnull final DropTargetDropEvent dtde) throws Exception {
  File result = null;
  for (final DataFlavor df : dtde.getCurrentDataFlavors()) {
    final Class<?> representation = df.getRepresentationClass();
    if (FileTransferable.class.isAssignableFrom(representation)) {
      final FileTransferable t = (FileTransferable) dtde.getTransferable();
      final List<File> listOfFiles = t.getFiles();
      result = listOfFiles.isEmpty() ? null : listOfFiles.get(0);
      break;
    } else if (df.isFlavorJavaFileListType()) {
      try {
        final List list = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        if (list != null && !list.isEmpty()) {
          result = (File) list.get(0);
        }
        break;
      }
      catch (final Exception ex) {
        LOGGER.error("Can't extract file from DnD", ex); //NOI18N
      }
    }
  }
  return result;
}
项目:BioPano    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e)
{
    if (dragSource != null)
    {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge = graph.insertEdge(null, null, null,
                dragSource.cell, JTableRenderer.this.cell, "sourceRow="
                        + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
    }
    else
    {
        e.rejectDrop();
    }
}
项目:ORS    文件:MainFrameDropTargetListener.java   
@Override
public void drop(DropTargetDropEvent arg0) {
    Transferable tr = arg0.getTransferable();
    arg0.acceptDrop(DnDConstants.ACTION_REFERENCE);
    if(arg0.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
        try {
            @SuppressWarnings("unchecked")
            List<File> fileList = (List<File>)tr.getTransferData(DataFlavor.javaFileListFlavor);
            for(File file: fileList){
                AttackResultFrame resultFrame = new AttackResultFrame();
                if (resultFrame.loadResult(file) == true){
                    resultFrame.setVisible(true);
                    resultFrame.invalidate();
                }else{
                    resultFrame = null;
                }
            }
        } catch (UnsupportedFlavorException | IOException e) {
            logger.debug(e);
        }
    }
}
项目:thingweb-gui    文件:ThingsClient.java   
@SuppressWarnings("unchecked")
protected void doDragAndDropFile(final JButton button) {
    button.setDropTarget(new DropTarget() {
        private static final long serialVersionUID = 1L;

        public synchronized void drop(DropTargetDropEvent evt) {
            try {
                evt.acceptDrop(DnDConstants.ACTION_COPY);
                List<File> droppedFiles = (List<File>) evt.getTransferable()
                        .getTransferData(DataFlavor.javaFileListFlavor);

                for (File f : droppedFiles) {
                    // process file(s)
                    addThingPanelFile(f.getAbsolutePath());
                }
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null,
                        "Errors while creating panels for dropped files: " + ex.getMessage(), "Drop Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });
}
项目:Desktop    文件:JhromeTabbedPaneUI.java   
@Override
public void drop(DropTargetDropEvent dtde) {
    setDragState(null, 0, 0);

    TabDragInfo dragInfo = getDragInfo(dtde.getTransferable());
    if (dragInfo != null) {
        if (dragInfo.tab != null && Utils.contains(dropZone, dtde.getLocation()) && isSnapInAllowed(dragInfo.tab)) {
            dtde.acceptDrop(dtde.getDropAction());
        } else {
            dtde.rejectDrop();
        }
    } else {
        dtde.rejectDrop();
    }

    dtde.dropComplete(true);
}
项目:vassal    文件:Map.java   
public void drop(DropTargetDropEvent dtde) {
  if (dtde.getDropTargetContext().getComponent() == theMap) {
    final MouseEvent evt = new MouseEvent(
      theMap,
      MouseEvent.MOUSE_RELEASED,
      System.currentTimeMillis(),
      0,
      dtde.getLocation().x,
      dtde.getLocation().y,
      1,
      false
    );
    theMap.dispatchEvent(evt);
    dtde.dropComplete(true);
  }

  if (scroller.isRunning()) scroller.stop();
}
项目:ij-ridgedetection    文件:GenericDialogPlus.java   
/**
 * Gets the string.
 *
 * @param event
 *            the event
 * @return the string
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws UnsupportedFlavorException
 *             the unsupported flavor exception
 */
@SuppressWarnings("unchecked")
static String getString(DropTargetDropEvent event) throws IOException, UnsupportedFlavorException {
    String text = null;
    DataFlavor fileList = DataFlavor.javaFileListFlavor;

    if (event.isDataFlavorSupported(fileList)) {
        event.acceptDrop(DnDConstants.ACTION_COPY);
        List<File> list = (List<File>) event.getTransferable().getTransferData(fileList);
        text = list.get(0).getAbsolutePath();
    } else if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        event.acceptDrop(DnDConstants.ACTION_COPY);
        text = (String) event.getTransferable().getTransferData(DataFlavor.stringFlavor);
        if (text.startsWith("file://"))
            text = text.substring(7);
        text = stripSuffix(stripSuffix(text, "\n"), "\r").replaceAll("%20", " ");
    } else {
        event.rejectDrop();
        return null;
    }

    event.dropComplete(text != null);
    return text;
}
项目:arget    文件:SessionPanel.java   
@Override
public synchronized void drop (DropTargetDropEvent evt) {
    try {
        evt.acceptDrop(DnDConstants.ACTION_COPY);

        // nothing we can do about it, casting to generic list will be unsafe
        @SuppressWarnings("unchecked")
        List<File> droppedFiles = (List<File>)evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        if (droppedFiles.size() > 1) return;

        File file = droppedFiles.get(0);
        listener.sendFile(instance, file);

    } catch (IOException | UnsupportedFlavorException e) {
        Log.exception(e);
    }
}
项目:ireport-fork    文件:CreateCalloutAction.java   
@Override
public void drop(DropTargetDropEvent dtde) {

        Point p = getScene().convertViewToScene( dtde.getLocation() );

        if (!(getScene() instanceof ReportObjectScene))
        {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    JOptionPane.showMessageDialog(Misc.getMainFrame(), "Notes can be added only to the main report designer");
                }
            });

            return;

        }

        CalloutsLayer layer = CalloutsUtility.getCalloutsLayer((AbstractReportObjectScene)getScene(), true);

        Widget w = CalloutsUtility.createCalloutWidget((AbstractReportObjectScene)getScene());
        w.setPreferredLocation(p);
        layer.addChild(w);
        getScene().validate();
}
项目:ireport-fork    文件:CreateTextFieldFromCrosstabParameterAction.java   
@Override
public void drop(DropTargetDropEvent dtde) {

    if (!(getScene() instanceof CrosstabObjectScene))
    {
        Runnable r = new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(Misc.getMainFrame(), "You can only use a crosstab parameter inside a crosstab.","Error", JOptionPane.WARNING_MESSAGE);
            }
        };

        Mutex.EVENT.readAccess(r); 
        return;
    }

    super.drop(dtde);
}
项目:ireport-fork    文件:CreateDetailTextFieldsForFieldsAction.java   
@Override
public void drop(DropTargetDropEvent dtde) {

    JRDesignElement[] elements = createElements(getJasperDesign(), false);

    if (elements == null || elements.length == 0) return;
    // Find location...
    dropElementsAt(getScene(), getJasperDesign(), elements, dtde.getLocation());

    if (getJasperDesign().getColumnHeader() != null &&
                    getJasperDesign().getColumnHeader().getHeight() >= 20 &&
                    IReportManager.getPreferences().getBoolean("createLabelForField", true))
    {
        int y = ModelUtils.getBandLocation(getJasperDesign().getColumnHeader(), getJasperDesign());

        Point labelLocation = getScene().convertSceneToView(new Point(getJasperDesign().getLeftMargin()+1,y+1));
        dropElementsAt(getScene(), getJasperDesign(), createElements(getJasperDesign(), true), labelLocation);
    }
}
项目:ireport-fork    文件:CreateTextFieldFromCrosstabMeasureNodeAction.java   
@Override
public void drop(DropTargetDropEvent dtde) {

    if ( !(getPaletteItem().getData() instanceof CrosstabMeasureNode))
    {
        return;
    }

    CrosstabMeasureNode measureNode = (CrosstabMeasureNode)getPaletteItem().getData();

    if (!(getScene() instanceof CrosstabObjectScene) ||
        measureNode.getCrosstab() != ((CrosstabObjectScene)getScene()).getDesignCrosstab() )
    {
        Runnable r = new Runnable() {
            public void run() {
                JOptionPane.showMessageDialog(Misc.getMainFrame(), "You can only use a measure inside the crosstab\nin which the measure is defined.","Error", JOptionPane.WARNING_MESSAGE);
            }
        };

        Mutex.EVENT.readAccess(r); 
        return;
    }

    super.drop(dtde);
}
项目:passage    文件:BeanBoxDnDCatcher.java   
/**
 * The drag operation has terminated with a drop on this
 * <code>DropTarget</code>. This method is responsible for undertaking the
 * transfer of the data associated with the gesture. The
 * <code>DropTargetDropEvent</code> provides a means to obtain a
 * <code>Transferable</code> object that represents the data object(s) to be
 * transfered.
 * <P>
 * <P>
 * 
 * @param dtde the <code>DropTargetDropEvent</code>
 */
public void drop(DropTargetDropEvent dtde) {
    if (Debug.debugging("beanbox"))
        Debug.output("Enter> drop");

    dtde.acceptDrop(DnDConstants.ACTION_MOVE);
    extractTransferData(dtde);
    extractDropLocation(dtde);

    if (transferData == null || dropLocation == null)
        return;

    Component parent = ((DropTarget) dtde.getSource()).getComponent();

    dtde.dropComplete(true);

    showPopUp(parent);
    if (Debug.debugging("beanbox"))
        Debug.output("Exit> drop");
}
项目:passage    文件:BeanBoxDnDCatcher.java   
private void extractTransferData(DropTargetDropEvent dtde) {
    if (dtde == null) {
        System.out.println("ERROR> BDnDC::getTransferData(): dropEvent is null");
        return;
    }

    Transferable tr = dtde.getTransferable();
    try {
        transferData = (Vector) tr.getTransferData(DefaultTransferableObject.OBJECT_FLAVOR);

        // cache beanInfos
        if (transferData.size() >= 2) {
            Object bean = transferData.get(0);
            BeanInfo beanInfo = (BeanInfo) transferData.get(1);
            beanInfoMap.put(bean.getClass().getName(), beanInfo);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:passage    文件:DefaultDnDCatcher.java   
/**
 * Gets the object that is passed in transferable in DropTargetDropEvent.
 */

private Object extractTransferData(DropTargetDropEvent dtde) {
    if (dtde == null) {
        Debug.message("defaultdndcatcher",
                "ERROR> DefaultDnDCatcher::getTransferData(): dropEvent is null");
        return null;
    }

    Transferable tr = dtde.getTransferable();
    try {
        return tr.getTransferData(DefaultTransferableObject.OBJECT_FLAVOR);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
项目:WP3    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e)
{
    if (dragSource != null)
    {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge = graph.insertEdge(null, null, null,
                dragSource.cell, JTableRenderer.this.cell, "sourceRow="
                        + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
    }
    else
    {
        e.rejectDrop();
    }
}
项目:WP3    文件:JTableRenderer.java   
public void drop(DropTargetDropEvent e) {
  if (dragSource != null) {
    e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    Point p = e.getLocation();
    int targetRow = rowAtPoint(p);

    Object edge = graph.insertEdge(null, null, null, dragSource.cell, JTableRenderer.this.cell,
        "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
    graph.setSelectionCell(edge);

    // System.out.println("clearing drag source");
    dragSource = null;
    e.dropComplete(true);
  } else {
    e.rejectDrop();
  }
}
项目:jpexs-decompiler    文件:MainPanel.java   
private void enableDrop(boolean value) {
    if (value) {
        setDropTarget(new DropTarget() {
            @Override
            public synchronized void drop(DropTargetDropEvent dtde) {
                try {
                    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                    @SuppressWarnings("unchecked")
                    List<File> droppedFiles = (List<File>) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
                    if (!droppedFiles.isEmpty()) {
                        SWFSourceInfo[] sourceInfos = new SWFSourceInfo[droppedFiles.size()];
                        for (int i = 0; i < droppedFiles.size(); i++) {
                            sourceInfos[i] = new SWFSourceInfo(null, droppedFiles.get(i).getAbsolutePath(), null);
                        }
                        Main.openFile(sourceInfos, null);
                    }
                } catch (UnsupportedFlavorException | IOException ex) {
                }
            }
        });
    } else {
        setDropTarget(null);
    }
}