当前位置: 首页>>代码示例>>Java>>正文


Java DropTargetDropEvent.getDropTargetContext方法代码示例

本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.getDropTargetContext方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.getDropTargetContext方法的具体用法?Java DropTargetDropEvent.getDropTargetContext怎么用?Java DropTargetDropEvent.getDropTargetContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.dnd.DropTargetDropEvent的用法示例。


在下文中一共展示了DropTargetDropEvent.getDropTargetContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
    Point p = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    // Sets the original glass pane
    setOriginalGlassPane(tree);
    // Cancel tree item expanding
    dragOverTreePath = null;
    // Get the parent and sibling paths and nodes
    TreePath currentPath = tree.getPathForLocation(p.x, p.y);
    DefaultMutableTreeNode parent =
        (DefaultMutableTreeNode) getNodeForPath
            (getParentPathForPosition(currentPath));
    Node dropTargetNode = getDomNodeFromTreeNode(parent);
    DefaultMutableTreeNode sibling =
        (DefaultMutableTreeNode)
            getNodeForPath(getSiblingPathForPosition(currentPath));
    Node siblingNode = getDomNodeFromTreeNode(sibling);
    if (this.transferData != null) {
        ArrayList nodelist =
            getNodeListForParent(this.transferData.getNodeList(),
                                 dropTargetNode);
        fireDropCompleted
            (new DOMDocumentTreeEvent
                (new DropCompletedInfo
                    (dropTargetNode, siblingNode, nodelist)));
        dtde.dropComplete(true);
        return;
    }
    dtde.rejectDrop();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:DOMDocumentTree.java

示例2: _getFiles

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
private static List<File> _getFiles(DropTargetDropEvent dtde, IApplication app, boolean allowMoreThanOneFile)
{
   try
   {
      DropTargetContext context = dtde.getDropTargetContext();
      dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
      Transferable t = dtde.getTransferable();
      List<File> filesToOpen = new ArrayList<File>();

      if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
          filesToOpen = handleJavaFileListFlavor(t, app, allowMoreThanOneFile);
      } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
          filesToOpen = handleStringFlavor(t, app, allowMoreThanOneFile);
      } else {
          filesToOpen = handleUriListFlavor(t);
      }
      context.dropComplete(true);

      if (null != filesToOpen)
      {
         return filesToOpen;
      }
      else
      {
         return new ArrayList<File>();
      }
   }
   catch (Exception e)
   {
      throw new RuntimeException(e);
   }
}
 
开发者ID:realxujiang,项目名称:bigtable-sql,代码行数:33,代码来源:DropedFileExtractor.java

示例3: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public synchronized void drop(DropTargetDropEvent dtde) {
	try {
		TreeNode sourceNode = (TreeNode) dtde.getTransferable().getTransferData(
				NodeTransferWrapper.ATLAS_OBJECT_FLAVOR);

		Point pt = dtde.getLocation();
		DropTargetContext dtc = dtde.getDropTargetContext();
		JTree tree = (JTree) dtc.getComponent();
		TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
		TreeNode targetNode = (TreeNode) parentpath.getLastPathComponent();

		if (targetNode.equals(sourceNode) || targetNode.getParent().equals(sourceNode)) {
			dtde.rejectDrop();
			return;
		}
		AtlasTreeModel atlasTreeModel = (AtlasTreeModel) atlasTree.getModel();
		if (sourceNode instanceof LayerInterface && targetNode instanceof LayerInterface)
			mergeLayers(atlasTreeModel, (LayerInterface) sourceNode,
					(LayerInterface) targetNode);

		if (targetNode instanceof MapInterface)
			// We can not make a map child of another map
			// -> use it's layer instead
			targetNode = targetNode.getParent();

		if (sourceNode instanceof MapInterface && targetNode instanceof LayerInterface)
			moveMap(atlasTreeModel, (MapInterface) sourceNode, (LayerInterface) targetNode);

	} catch (Exception e) {
		log.error("", e);
		atlasTree.getTreeModel().notifyStructureChanged();
		dtde.rejectDrop();
	}
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:35,代码来源:DragDropController.java

示例4: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde)
{
	if (dtde.isDataFlavorSupported(CardFlavor.cardFlavor) && this.canDrop)
	{
		Transferable trans = dtde.getTransferable();
		try
		{
			Object data = trans.getTransferData(CardFlavor.cardFlavor);
			CardWindow card =(CardWindow)data;
			DropTargetContext context = dtde.getDropTargetContext();
			CardCollection comp = (CardCollection)context.getComponent();
			Container parent = comp.getParent();
			GameController.getController(false)
				.makeMove(CardCollection.getMoveFromIndex(comp.getCardMouseLocation(), new OrderedCard(card.card, card.cardLocation)));
			if (parent != null)
				parent.remove(card);
			comp.setCard(card, comp.getCardMouseLocation());
			dtde.acceptDrop(DnDConstants.ACTION_MOVE);
			comp.validate();
			comp.repaint();
			
			dtde.dropComplete(true);
		}
		catch (Exception e)
		{
			dtde.rejectDrop();
			dtde.dropComplete(false);
			JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "Invalid move.", "Invalid Move Error", JOptionPane.ERROR_MESSAGE);
			e.printStackTrace();
		}
	}
	else
	{
		dtde.rejectDrop();
		dtde.dropComplete(false);
		JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "Invalid move.", "Invalid Move Error", JOptionPane.ERROR_MESSAGE);
	}
}
 
开发者ID:slaymaker1907,项目名称:triple-triad-ai,代码行数:40,代码来源:CardDropHandler.java

示例5: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/** Drop On Node ! */ 

   public void drop(DropTargetDropEvent dtde)
   {
       // Global.debugPrintln(this,"Dropping:"+dtde); 
   	
   	DropTargetContext dtc = dtde.getDropTargetContext();
   	Component comp = dtc.getComponent();
   	Point p=dtde.getLocation();
   	Transferable data = dtde.getTransferable();
   	
   	ResourceTreeNode rtnode = getRTNode(comp,p); 
   	
   	// check dropped data: 
   	if (VTransferData.canConvertToVRLs(data))
   	{
   		 // I: accept drop: 
           dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);

       	// supply ResourceTree as (J)Component but TreeNode as VComponent ! 
       	VTransferHandler.getDefault().interActiveDrop(comp,rtnode,p,data);
           // III: complete the drag ! 
           dtde.getDropTargetContext().dropComplete(true);
   	}
   	else
   		dtde.rejectDrop(); 
   	
   }
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:29,代码来源:ResourceTreeDropTarget.java

示例6: drop

import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde)
{
    //UIGlobal.debugPrintf(this,"drop:%s\n",dtde);
	
	DropTargetContext dtc = dtde.getDropTargetContext();
	Component comp = dtc.getComponent();
	Point p=dtde.getLocation();
	
    // II : get data: 
	Transferable data = dtde.getTransferable();
	
	// check dropped data: 
	if (VTransferData.canConvertToVRLs(data))
	{
		// I: accept drop: 
       dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);

        // Implementation now in VTransferHandler: 
        VTransferHandler.getDefault().interActiveDrop(comp,p,data); 
        
        // III: complete the drag ! 
        dtde.getDropTargetContext().dropComplete(true);
	}
	else
	{
		dtde.rejectDrop(); 
	}
	
}
 
开发者ID:NLeSC,项目名称:vbrowser,代码行数:30,代码来源:NodeDropTarget.java

示例7: 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


注:本文中的java.awt.dnd.DropTargetDropEvent.getDropTargetContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。