當前位置: 首頁>>代碼示例>>Java>>正文


Java DropTargetDropEvent.getDropAction方法代碼示例

本文整理匯總了Java中java.awt.dnd.DropTargetDropEvent.getDropAction方法的典型用法代碼示例。如果您正苦於以下問題:Java DropTargetDropEvent.getDropAction方法的具體用法?Java DropTargetDropEvent.getDropAction怎麽用?Java DropTargetDropEvent.getDropAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.dnd.DropTargetDropEvent的用法示例。


在下文中一共展示了DropTargetDropEvent.getDropAction方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@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();
}
 
開發者ID:m-lima,項目名稱:KATscans,代碼行數:24,代碼來源:DraggableTree.java

示例2: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
	if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
		// Accept the drop and get the transfer data
		dtde.acceptDrop(dtde.getDropAction());
		Transferable transferable = dtde.getTransferable();
		boolean dropSucceeded = false;

		try {
			window
					.setCursor(Cursor
							.getPredefinedCursor(Cursor.WAIT_CURSOR));

			dropSucceeded = dropFile(dtde.getDropAction(), transferable,
					dtde.getLocation());

		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			window.setCursor(Cursor.getDefaultCursor());
			dtde.dropComplete(dropSucceeded);
		}
	} else {
		dtde.dropComplete(false);
	}
}
 
開發者ID:yjgoo,項目名稱:pdm-viewer,代碼行數:26,代碼來源:DropFileLoader.java

示例3: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
    gestureStarted = false;
    if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);
        Transferable t = dtde.getTransferable();

        try {
            DBTableInternalFrame iFrame = (DBTableInternalFrame) t
                    .getTransferData(InternalFrameTransferable.DATA_FLAVOR);
            if (iFrame != DBTableInternalFrame.this) {
                JoinLine joinLine = new JoinLine(iFrame, iFrame
                        .getSelectedRow(), DBTableInternalFrame.this,
                        columnsListBox.getSelectedIndex());
                desktop.addJoinLine(joinLine);
                desktop.repaint();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        dtde.dropComplete(true);
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:24,代碼來源:DBTableInternalFrame.java

示例4: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent event) {
    int dropAction = event.getDropAction();
    JComponent c = (JComponent) event.getDropTargetContext().getComponent();
    DataObjectTransferHandler transferHandler = (DataObjectTransferHandler) c.getTransferHandler();

    if (canImport && (transferHandler != null) && actionSupported(dropAction)) {
        event.acceptDrop(dropAction);
        try {
            Transferable transferable = event.getTransferable();
            transferHandler.setDropPoint(event.getLocation());
            transferHandler.setDropComponent(c);
            event.dropComplete(transferHandler.importData(c, transferable));
        } catch (RuntimeException e) {
            event.dropComplete(false);
        }
    } else {
        event.rejectDrop();
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:20,代碼來源:DataObjectTransferHandler.java

示例5: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public final void drop(DropTargetDropEvent dtde) {
	try {
		if (drawImage) {
			clearImage();
		}
		int action = dtde.getDropAction();
		Transferable transferable = dtde.getTransferable();
		Point pt = dtde.getLocation();
		if (transferable.isDataFlavorSupported(NODE_FLAVOR)
				&& controller.canPerformAction(tree, draggedNode, action, pt)) {
			TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
			Object node = transferable.getTransferData(NODE_FLAVOR);
			Object newParentNode = pathTarget.getLastPathComponent();
			if (controller.executeDrop(tree, node, newParentNode, action)) {
				dtde.acceptDrop(action);
				dtde.dropComplete(true);
				return;
			}
		}
		dtde.rejectDrop();
		dtde.dropComplete(false);
	} catch (Exception e) {
		dtde.rejectDrop();
		dtde.dropComplete(false);
	}
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:28,代碼來源:JTreeUtil.java

示例6: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public final void drop(DropTargetDropEvent dtde) {
	try {
		if (drawImage) {
			clearImage();
		}
		int action = dtde.getDropAction();
		Transferable transferable = dtde.getTransferable();
		Point pt = dtde.getLocation();
		if (transferable.isDataFlavorSupported(NODE_FLAVOR)
				&& controller.canPerformAction(tree, draggedNode,
						action, pt)) {
			TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
			Object node = transferable.getTransferData(NODE_FLAVOR);
			Object newParentNode = pathTarget.getLastPathComponent();
			if (controller.executeDrop(tree, node, newParentNode,
					action)) {
				dtde.acceptDrop(action);
				dtde.dropComplete(true);
				return;
			}
		}
		dtde.rejectDrop();
		dtde.dropComplete(false);
	} catch (Exception e) {
		dtde.rejectDrop();
		dtde.dropComplete(false);
	}
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:29,代碼來源:JTreeUtil.java

示例7: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public final void drop(DropTargetDropEvent dtde) {
	try {
		if (drawImage) {
			clearImage();
		}
		int action = dtde.getDropAction();
		Transferable transferable = dtde.getTransferable();
		Point pt = dtde.getLocation();
		if (transferable
				.isDataFlavorSupported(NODE_FLAVOR)
				&& controller.canPerformAction(tree, draggedNode, action, pt)) {
			TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
			Object node = transferable.getTransferData(NODE_FLAVOR);
			Object newParentNode = pathTarget.getLastPathComponent();
			if (controller.executeDrop(tree, node, newParentNode, action)) {
				dtde.acceptDrop(action);
				dtde.dropComplete(true);
				return;
			}
		}
		dtde.rejectDrop();
		dtde.dropComplete(false);
	} catch (Exception e) {
		dtde.rejectDrop();
		dtde.dropComplete(false);
	}
}
 
開發者ID:franciscaconcha,項目名稱:ProyectoLogisim,代碼行數:28,代碼來源:JTreeUtil.java

示例8: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
	for (DataFlavor dataFlover : dtde.getCurrentDataFlavors()) {
		if (dataFlover.isFlavorJavaFileListType()) {
			try {
				dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

				List<String> fileNames = new ArrayList<String>();
				for (File file : (List<File>)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor))
					if (file.exists())
						fileNames.add(file.getCanonicalPath());
					else
						LOG.warn("Failed to drop from clipboard: '" + file.getAbsolutePath() + "' is not a file.");

				if (!fileNames.isEmpty()) {
					if (dtde.getDropAction() != DnDConstants.ACTION_COPY)
						fileListModel.clear();

					addFileNames(fileNames);
				}

				dtde.getDropTargetContext().dropComplete(true);	
			} catch (UnsupportedFlavorException e1) {
				//
			} catch (IOException e2) {
				//
			}
		}
	}
}
 
開發者ID:3dcitydb,項目名稱:importer-exporter,代碼行數:32,代碼來源:ImportPanel.java

示例9: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
@Override
public void drop(DropTargetDropEvent dtde) {
	if (getComponentCount() == 0) {
		dtde.rejectDrop();
		return;
	}
	
	try {
		Transferable tr = dtde.getTransferable();
		if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
			dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
			List<?> fileList = (List<?>) tr.getTransferData(DataFlavor.javaFileListFlavor);
			
			File parent = new File(Assistant.getNodePath((EticetableTreeNode) Client.currentClient.frame.catalog.getSelectionPath().getLastPathComponent()));
			
			new FileMover(Client.currentClient.frame, false, dtde.getDropAction() == DnDConstants.ACTION_COPY, parent, fileList.toArray(new File[] {}));
			Client.currentClient.frame.directoryLoader.fireUpdate();
			
			dtde.getDropTargetContext().dropComplete(true);
		} else {
			CFG.p("Rejected");
			dtde.rejectDrop();
		}
	} catch (IOException io) {
		io.printStackTrace();
		dtde.rejectDrop();
	} catch (UnsupportedFlavorException ufe) {
		ufe.printStackTrace();
		dtde.rejectDrop();
	}
}
 
開發者ID:Dakror,項目名稱:VirtualHub,代碼行數:32,代碼來源:FileViewPanel.java

示例10: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent e)
{
	try {
		int dropaction = e.getDropAction();  // 1=copy, 2=move

		if ( dropaction == 0 || dropaction > 2)
		{ 
			e.rejectDrop(); 

			return; 
		}

		e.acceptDrop(dropaction);

		Transferable tr = e.getTransferable();
		DataFlavor[] df = tr.getTransferDataFlavors();
		List li = (List) tr.getTransferData(df[0]);  // see note about mac os x

		Object[] val = li.toArray();

		if (val.length > 0)
			loadCutList(val[0].toString());

		e.dropComplete(true);

	} catch (Exception eee) { 

		e.dropComplete(false); 
		Common.setExceptionMessage(eee);
	}
}
 
開發者ID:silid,項目名稱:project-x-cvs,代碼行數:32,代碼來源:CutPanel.java

示例11: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public final void drop(DropTargetDropEvent dtde) {
        try {
                if (drawImage) {
                        clearImage();
                }
                int action = dtde.getDropAction();
                Transferable transferable = dtde.getTransferable();
                Point pt = dtde.getLocation();
                if (transferable.isDataFlavorSupported(TransferableNode.NODE_FLAVOR) && canPerformAction(tree, draggedNode, action, pt)) {
                        TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) transferable.getTransferData(TransferableNode.NODE_FLAVOR);
                        DefaultMutableTreeNode newParentNode = (DefaultMutableTreeNode)pathTarget.getLastPathComponent();
                        if (executeDrop(tree, node, newParentNode, action)) {
                                dtde.acceptDrop(action);
                                dtde.dropComplete(true);
                                return;                                 
                        }
                }
                dtde.rejectDrop();
                dtde.dropComplete(false);
        }
        catch (Exception e) {   
                System.out.println(e);
                dtde.rejectDrop();
                dtde.dropComplete(false);
        }
}
 
開發者ID:trakem2,項目名稱:TrakEM2,代碼行數:28,代碼來源:AbstractTreeTransferHandler.java

示例12: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde)
{
    // currently this method does all the work when a drop is performed
    
    try
    {
         
        Transferable data = dtde.getTransferable();
        DropTargetContext dtc = dtde.getDropTargetContext();
        Component comp = dtc.getComponent();
        
        int action = dtde.getDropAction();
        
        // check dataFlavor 
        
        /* if (t.isDataFlavorSupported (DataFlavor.javaFileListFlavor))
        {
            // Handle Java File List 
            
            dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
            
            java.util.List fileList = (java.util.List)
                t.getTransferData(DataFlavor.javaFileListFlavor);
            Iterator iterator = fileList.iterator();
            
            int len=fileList.size();
            
            VRL sourceLocs[]=new VRL[len];
            int index=0;
            
            dtde.getDropTargetContext().dropComplete(true);
            
            if (len<=0) 
                return; 
            
            while (iterator.hasNext())
            {
              java.io.File file = (File)iterator.next();
              
              Debug("name="+file.getName());
              Debug("url="+file.toURL().toString());
              Debug("path="+file.getAbsolutePath());
              
              sourceLocs[index++]=new VRL("file",null,file.getAbsolutePath()); 
            }
            
            viewerController.handleDropEvent(comp,sourceLocs[0].toString()); 
            
            boolean isMove=(action==DnDConstants.ACTION_MOVE);
            
      }
      else*/
        
      // String types for now: 
      if (VTransferData.canConvertToVRLs(data))   
      { 
            dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
        
            VRL vrls[]=VTransferData.getVRLsFrom(data); 
            controller.handleDrop(vrls[0]); 
       }
      else if (data.isDataFlavorSupported (DataFlavor.stringFlavor))
      { 
            dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
        
            String txt=  (String) 
            data.getTransferData(DataFlavor.stringFlavor);
            dtde.getDropTargetContext().dropComplete(true);
            controller.setContents(txt); 
       }                
    }
    catch (Exception e)
    {
        UILogger.logException(this,ClassLogger.ERROR,e,"Exception:%s\n",e);
    }
}
 
開發者ID:NLeSC,項目名稱:vbrowser,代碼行數:77,代碼來源:HexViewController.java

示例13: drop

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
public void drop(DropTargetDropEvent dtde) {
    if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
        dtde.acceptDrop(DnDConstants.ACTION_MOVE);

        Transferable t = dtde.getTransferable();
        Point point = dtde.getLocation();

        try {
            DBProcedure proc = (DBProcedure) t.getTransferData(DBProcTransferable.DATA_FLAVOR);
            List<DBProcedureColumn> columns = Globals.getDBViewer().getProcedureColumns(proc.getSchema(), proc.getCatalog(), proc.getName());
            if (!Globals.getDBViewer().isValidProcedure(columns)) {
                Show.info(I18NSupport.getString("procedure.invalid"));
                return;
            } else {
                StringBuilder sb = new StringBuilder("call ");
                boolean order = Globals.getDialect().schemaBeforeCatalog();
                if (!order) {
                    if (proc.getCatalog() != null) {
                        sb.append(proc.getCatalog()).append(".");
                    }
                }
                if (!"%".equals(proc.getSchema())) {
                    sb.append(proc.getSchema()).append(".");
                }
                if (order) {
                    if (proc.getCatalog() != null) {
                        sb.append(proc.getCatalog()).append(".");
                    }
                }
                sb.append(proc.getName());
                sb.append("(");
                int index = 1;
                for (int i = 0, size = columns.size(); i < size; i++) {
                    DBProcedureColumn col = columns.get(i);
                    if (ProcUtil.IN.equals(col.getReturnType())) {
                        sb.append("${P").append(index).append("}");
                        index++;
                        if (i < size - 1) {
                            sb.append(", ");
                        }
                    } else if (ProcUtil.OUT.equals(col.getReturnType())) {
                        if (ProcUtil.REF_CURSOR.equals(col.getDataType())) {
                            sb.append("?");
                            if (i < size - 1) {
                                sb.append(" , ");
                            }
                        }
                    }
                }
                sb.append(")");
                sqlView.setQueryString(sb.toString());
            }

        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
            e.printStackTrace();
        }

        dtde.dropComplete(true);
    }
}
 
開發者ID:nextreports,項目名稱:nextreports-designer,代碼行數:62,代碼來源:QueryBuilderPanel.java

示例14: setDropData

import java.awt.dnd.DropTargetDropEvent; //導入方法依賴的package包/類
/**
 * Called by the DropTargetAdapter in drop
 * return true if add action succeeded
 * otherwise return false
 */
public boolean setDropData(Object transferredData, DropTargetDropEvent e, DataFlavor chosen)
{
	boolean isSuccess = false;
	Point p = e.getLocation();
	TreePath path = this.getTree().getPathForLocation(p.x, p.y);
	if (path == null)
	{
		Log.logInfo(this, this.getClass() + " path is null. cannot find the exact path. Going to find closest path.");
		path = this.getTree().getClosestPathForLocation(p.x, p.y);
		if (path == null)
		{
			Log.logInfo(this, this.getClass() + " path is null. Even cannot find the closest path. setDropData() will reject drop.");
			return false;
		}
	}

	DefaultMutableTreeNode targetNode = (DefaultMutableTreeNode) path.getLastPathComponent();
	try
	{

		TransferableNode dragSourceObjectSelection = (TransferableNode) transferredData;

		java.util.List dragSourceObjectList = dragSourceObjectSelection.getSelectionList();
		if (dragSourceObjectList == null || dragSourceObjectList.size() < 1)
		{
			return false;
		}
		TreeModel tempModel = mTree.getModel();
		if (!(tempModel instanceof CSVMetadataTreeModel))
		{
			System.err.println("I am expecting CSVMetadataTreeModel, but I received '" + tempModel == null ? "null" : tempModel.getClass().getName() + "'");
			return false;
		}

		int dropAction = e.getDropAction();
		CSVMetadataTreeModel treeModel = (CSVMetadataTreeModel) tempModel;
		isSuccess = treeModel.addChildren(targetNode, dragSourceObjectList, dropAction==DnDConstants.ACTION_COPY);
	}
	catch (Exception exp)
	{
		Log.logInfo(this, "Exception Caught by '" + this.getClass().getName() + "': " + exp.getClass().getName() + ";" + exp.getMessage());
		Log.logException(this, exp);
		isSuccess = false;
	}
	finally
	{
		return isSuccess;
	}
}
 
開發者ID:NCIP,項目名稱:caadapter,代碼行數:55,代碼來源:CSVTreeDropTransferHandler.java


注:本文中的java.awt.dnd.DropTargetDropEvent.getDropAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。