Java Code Examples for java.awt.dnd.DropTargetDropEvent

The following are top voted examples for showing how to use java.awt.dnd.DropTargetDropEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: DragOperation.java   View source code 6 votes vote down vote up
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();
    
}
 
Example 2
Project: incubator-netbeans   File: QuietEditorPane.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: incubator-netbeans   File: DnDSupport.java   View source code 6 votes vote down vote up
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();
}
 
Example 4
Project: SubtitleDownloader   File: SubtitleDownloaderUI.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 5
Project: VASSAL-src   File: Map.java   View source code 6 votes vote down vote up
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();
}
 
Example 6
Project: Equella   File: UploadAction.java   View source code 6 votes vote down vote up
@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;
	}
}
 
Example 7
Project: TrabalhoFinalEDA2   File: mxGraphHandler.java   View source code 6 votes vote down vote up
/**
 * 
 * @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);
	}
}
 
Example 8
Project: Tarski   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 9
Project: Tarski   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
  }
}
 
Example 10
Project: KATscans   File: DraggableTree.java   View source code 6 votes vote down vote up
@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();
}
 
Example 11
Project: OWLAx   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 12
Project: OWLAx   File: mxGraphHandler.java   View source code 6 votes vote down vote up
/**
 * 
 * @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);
	}
}
 
Example 13
Project: SporeModder   File: AdvancedFileChooser.java   View source code 6 votes vote down vote up
@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();
	}
}
 
Example 14
Project: SporeModder   File: DropTargetTextField.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 15
Project: bigtable-sql   File: RecentFilesController.java   View source code 6 votes vote down vote up
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);
}
 
Example 16
Project: bigtable-sql   File: RecentFilesController.java   View source code 6 votes vote down vote up
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;

}
 
Example 17
Project: bigtable-sql   File: FileEditorDropTargetListener.java   View source code 6 votes vote down vote up
/**
 * @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);
    }

}
 
Example 18
Project: bigtable-sql   File: JTreeAliasesListImpl.java   View source code 6 votes vote down vote up
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);
}
 
Example 19
Project: CentipeTextEditor   File: TextArea.java   View source code 6 votes vote down vote up
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();
       }
}
 
Example 20
Project: dsworkbench   File: AbstractDSWorkbenchFrame.java   View source code 6 votes vote down vote up
@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) {
    }
}
 
Example 21
Project: netbeans-mmd-plugin   File: DnDUtils.java   View source code 6 votes vote down vote up
@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;
}
 
Example 22
Project: netbeans-mmd-plugin   File: DnDTree.java   View source code 6 votes vote down vote up
@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();
  }
}
 
Example 23
Project: netbeans-mmd-plugin   File: MMDEditor.java   View source code 6 votes vote down vote up
@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;
}
 
Example 24
Project: BioPano   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 25
Project: ORS   File: MainFrameDropTargetListener.java   View source code 6 votes vote down vote up
@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);
        }
    }
}
 
Example 26
Project: thingweb-gui   File: ThingsClient.java   View source code 6 votes vote down vote up
@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);
			}
		}
	});
}
 
Example 27
Project: Desktop   File: JhromeTabbedPaneUI.java   View source code 6 votes vote down vote up
@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);
}
 
Example 28
Project: vassal   File: Map.java   View source code 6 votes vote down vote up
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();
}
 
Example 29
Project: ij-ridgedetection   File: GenericDialogPlus.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 30
Project: arget   File: SessionPanel.java   View source code 6 votes vote down vote up
@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);
	}
}
 
Example 31
Project: ireport-fork   File: CreateCalloutAction.java   View source code 6 votes vote down vote up
@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();
}
 
Example 32
Project: ireport-fork   File: CreateTextFieldFromCrosstabParameterAction.java   View source code 6 votes vote down vote up
@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);
}
 
Example 33
Project: ireport-fork   File: CreateDetailTextFieldsForFieldsAction.java   View source code 6 votes vote down vote up
@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);
    }
}
 
Example 34
Project: ireport-fork   File: CreateTextFieldFromCrosstabMeasureNodeAction.java   View source code 6 votes vote down vote up
@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);
}
 
Example 35
Project: passage   File: BeanBoxDnDCatcher.java   View source code 6 votes vote down vote up
/**
 * 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");
}
 
Example 36
Project: passage   File: BeanBoxDnDCatcher.java   View source code 6 votes vote down vote up
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();
    }
}
 
Example 37
Project: passage   File: DefaultDnDCatcher.java   View source code 6 votes vote down vote up
/**
 * 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;
    }
}
 
Example 38
Project: WP3   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
	}
}
 
Example 39
Project: WP3   File: JTableRenderer.java   View source code 6 votes vote down vote up
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();
  }
}
 
Example 40
Project: jpexs-decompiler   File: MainPanel.java   View source code 6 votes vote down vote up
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);
    }
}