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


Java DropTargetContext类代码示例

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


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

示例1: updatePositionIndicator

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 * Sets the position indicator according to the current cursor location.
 *
 * @param dtde
 *            DropTargetDragEvent
 */
private void updatePositionIndicator(DropTargetDragEvent dtde) {
    Point p = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    // Current path
    TreePath currentPath = tree.getPathForLocation(p.x, p.y);
    Rectangle bounds = tree.getPathBounds(currentPath);
    // Upper area of the tree node
    if (p.y <= bounds.y + visualTipOffset) {
        positionIndicator = BEFORE;
    }
    // Lower area of the tree node
    else if (p.y >= bounds.y + bounds.height - visualTipOffset) {
        positionIndicator = AFTER;
    }
    // Somewhere between the upper and the lower area of the tree node
    else {
        positionIndicator = CURRENT;
    }
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:27,代码来源:DOMDocumentTree.java

示例2: createDropTargetContext

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
private DropTargetContext createDropTargetContext() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
        InstantiationException, IllegalAccessException, InvocationTargetException {
    Constructor<DropTargetContext> c = DropTargetContext.class.getDeclaredConstructor(DropTarget.class);
    c.setAccessible(true);
    DropTargetContext inst = c.newInstance(dest.getDropTarget());
    inst.addNotify(createDropTargetContextPeer());
    return inst;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:DnDHandler.java

示例3: drop

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例4: getNode

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 * Gets the TreeNode from the DropTargetDragEvent
 *
 * @param dtde
 *            The DropTargetDragEvent
 * @return Associated TreeNode or null
 */
private TreeNode getNode(DropTargetDragEvent dtde) {
    Point p = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath path = tree.getPathForLocation(p.x, p.y);
    if (path == null || path.getLastPathComponent() == null) {
        return null;
    }
    return (TreeNode) path.getLastPathComponent();
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:18,代码来源:DOMDocumentTree.java

示例5: _getFiles

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例6: drop

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例7: getNodeForEvent

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
private TreeNode getNodeForEvent(DropTargetDragEvent dtde) {
	Point p = dtde.getLocation();
	DropTargetContext dtc = dtde.getDropTargetContext();
	JTree tree = (JTree) dtc.getComponent();
	TreePath path = tree.getClosestPathForLocation(p.x, p.y);
	return (TreeNode) path.getLastPathComponent();
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:8,代码来源:DragDropController.java

示例8: drop

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例9: WinDropTarget

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
public WinDropTarget(WinDTK dtk, DropTargetContext context) {
    this.dtk = dtk;
    this.context = context;

    ComponentInternals ci = ComponentInternals.getComponentInternals();
    NativeWindow w = ci.getNativeWindow(context.getComponent());
    hwnd = w.getId();
    dropTargetPtr = registerDropTarget();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:WinDropTarget.java

示例10: drop

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例11: drop

import java.awt.dnd.DropTargetContext; //导入依赖的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

示例12: getDropTargetContext

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 * @see DropTargetDragEvent
 */
public DropTargetContext getDropTargetContext () {
    return event.getDropTargetContext ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:WidgetAction.java

示例13: processExitMessage

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 *
 */

protected void processExitMessage(SunDropTargetEvent event) {
    Component         c   = (Component)event.getSource();
    DropTarget        dt  = c.getDropTarget();
    DropTargetContext dtc = null;

    if (dt == null) {
        currentDT = null;
        currentT  = null;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = null;

        return;
    }

    if (dt != currentDT) {

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDT  = dt;
        currentDTC = dt.getDropTargetContext();

        currentDTC.addNotify(this);
    }

    dtc = currentDTC;

    if (dt.isActive()) try {
        ((DropTargetListener)dt).dragExit(new DropTargetEvent(dtc));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        currentA  = DnDConstants.ACTION_NONE;
        currentSA = DnDConstants.ACTION_NONE;
        currentDA = DnDConstants.ACTION_NONE;
        currentDT = null;
        currentT  = null;

        currentDTC.removeNotify();
        currentDTC = null;

        local = null;

        dragRejected = false;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:SunDropTargetContextPeer.java

示例14: processMotionMessage

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 *
 */

protected void processMotionMessage(SunDropTargetEvent event,
                                  boolean operationChanged) {
    Component         c    = (Component)event.getSource();
    Point             hots = event.getPoint();
    int               id   = event.getID();
    DropTarget        dt   = c.getDropTarget();
    DropTargetContext dtc  = null;

    if (c.isShowing() && (dt != null) && dt.isActive()) {
        if (currentDT != dt) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDT  = dt;
            currentDTC = null;
        }

        dtc = currentDT.getDropTargetContext();
        if (dtc != currentDTC) {
            if (currentDTC != null) {
                currentDTC.removeNotify();
            }

            currentDTC = dtc;
            currentDTC.addNotify(this);
        }

        currentA = currentDT.getDefaultActions();

        try {
            DropTargetDragEvent dtde = new DropTargetDragEvent(dtc,
                                                               hots,
                                                               currentDA,
                                                               currentSA);
            DropTargetListener dtl = (DropTargetListener)dt;
            if (operationChanged) {
                dtl.dropActionChanged(dtde);
            } else {
                dtl.dragOver(dtde);
            }

            if (dragRejected) {
                currentDA = DnDConstants.ACTION_NONE;
            }
        } catch (Exception e) {
            e.printStackTrace();
            currentDA = DnDConstants.ACTION_NONE;
        }
    } else {
        currentDA = DnDConstants.ACTION_NONE;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:SunDropTargetContextPeer.java

示例15: processDropMessage

import java.awt.dnd.DropTargetContext; //导入依赖的package包/类
/**
 *
 */

protected void processDropMessage(SunDropTargetEvent event) {
    Component  c    = (Component)event.getSource();
    Point      hots = event.getPoint();
    DropTarget dt   = c.getDropTarget();

    dropStatus   = STATUS_WAIT; // drop pending ACK
    dropComplete = false;

    if (c.isShowing() && dt != null && dt.isActive()) {
        DropTargetContext dtc = dt.getDropTargetContext();

        currentDT = dt;

        if (currentDTC != null) {
            currentDTC.removeNotify();
        }

        currentDTC = dtc;
        currentDTC.addNotify(this);
        currentA = dt.getDefaultActions();

        synchronized(_globalLock) {
            if ((local = getJVMLocalSourceTransferable()) != null)
                setCurrentJVMLocalSourceTransferable(null);
        }

        dropInProcess = true;

        try {
            ((DropTargetListener)dt).drop(new DropTargetDropEvent(dtc,
                                                                  hots,
                                                                  currentDA,
                                                                  currentSA,
                                                                  local != null));
        } finally {
            if (dropStatus == STATUS_WAIT) {
                rejectDrop();
            } else if (dropComplete == false) {
                dropComplete(false);
            }
            dropInProcess = false;
        }
    } else {
        rejectDrop();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:SunDropTargetContextPeer.java


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