Examples of TreePath


Examples of javax.swing.tree.TreePath

  }
 
  private class DragController implements JTreeDragController {
    public boolean canPerformAction(JTree targetTree,
        Object draggedNode, int action, Point location) {
      TreePath pathTarget = targetTree.getPathForLocation(location.x, location.y);
      if (pathTarget == null) {
        targetTree.setSelectionPath(null);
        return false;
      }
      targetTree.setSelectionPath(pathTarget);
      if (action == DnDConstants.ACTION_COPY) {
        return false;
      } else if (action == DnDConstants.ACTION_MOVE) {
        Object targetNode = pathTarget.getLastPathComponent();
        return canMove(draggedNode, targetNode);
      } else {
        return false;
      }
    }
View Full Code Here

Examples of javax.swing.tree.TreePath

    }
  }
 
  private class DeleteAction extends AbstractAction {
    public void actionPerformed(ActionEvent event) {
      TreePath path = getSelectionPath();
      if (listener != null && path != null && path.getPathCount() == 2) {
        listener.deleteRequested(new Event(path));
      }
      ProjectExplorer.this.requestFocus();
    }
View Full Code Here

Examples of javax.swing.tree.TreePath

    public void mouseReleased(MouseEvent e) {
      checkForPopup(e);
    }
    private void checkForPopup(MouseEvent e) {
      if (e.isPopupTrigger()) {
        TreePath path = getPathForLocation(e.getX(), e.getY());
        if (path != null && listener != null) {
          JPopupMenu menu = listener.menuRequested(new Event(path));
          if (menu != null) {
            menu.show(ProjectExplorer.this, e.getX(), e.getY());
          }
View Full Code Here

Examples of javax.swing.tree.TreePath

        }
      }
    }
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() == 2) {
        TreePath path = getPathForLocation(e.getX(), e.getY());
        if (path != null && listener != null) {
          listener.doubleClicked(new Event(path));
        }
      }
    }
View Full Code Here

Examples of javax.swing.tree.TreePath

    //
    // TreeSelectionListener methods
    //
    public void valueChanged(TreeSelectionEvent e) {
      TreePath path = e.getNewLeadSelectionPath();
      if (listener != null) {
        listener.selectionChanged(new Event(path));
      }
    }
View Full Code Here

Examples of javax.swing.tree.TreePath

    // project/library file/circuit listener methods
    //
    public void projectChanged(ProjectEvent event) {
      int act = event.getAction();
      if (act == ProjectEvent.ACTION_SET_TOOL) {
        TreePath path = getSelectionPath();
        if (path != null && path.getLastPathComponent() != event.getTool()) {
          clearSelection();
        }
      } else if (act == ProjectEvent.ACTION_SET_FILE) {
        setFile(event.getLogisimFile());
      } else if (act == ProjectEvent.ACTION_SET_CURRENT) {
View Full Code Here

Examples of javax.swing.tree.TreePath

      dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
    }

    /* Methods for DragGestureListener */
    public final void dragGestureRecognized(DragGestureEvent dge) {
      TreePath path = tree.getSelectionPath();
      if (path != null) {
        draggedNode = path.getLastPathComponent();
        if (drawImage) {
          Rectangle pathBounds = tree.getPathBounds(path); // getpathbounds
                                    // of
                                    // selectionpath
          JComponent lbl = (JComponent) tree
              .getCellRenderer()
              .getTreeCellRendererComponent(
                  tree,
                  draggedNode,
                  false,
                  tree.isExpanded(path),
                  tree.getModel() .isLeaf(path.getLastPathComponent()),
                  0, false);// returning the label
          lbl.setBounds(pathBounds);// setting bounds to lbl
          image = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
              java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);// buffered
                                      // image
View Full Code Here

Examples of javax.swing.tree.TreePath

        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;
          }
View Full Code Here

Examples of javax.swing.tree.TreePath

    TreePath[] sel = getSelectionPaths();
    if (sel == null || sel.length == 0) return Collections.emptyList();
   
    ArrayList<SelectionItem> ret = new ArrayList<SelectionItem>();
    for (int i = 0; i < sel.length; i++) {
      TreePath path = sel[i];
      Object last = path.getLastPathComponent();
      ComponentNode n = null;
      Object opt = null;
      if (last instanceof OptionNode) {
        OptionNode o = (OptionNode) last;
        n = o.parent;
View Full Code Here

Examples of javax.swing.tree.TreePath

    if(!e.isConsumed()) {
      if(!tree.isFocusOwner()) {
        tree.requestFocusInWindow();
      }
     
      TreePath path = getClosestPathForLocation(tree, e.getX(), e.getY());
     
      if(path != null && getPathBounds(tree,path).contains(e.getPoint())) {
        tree.setSelectionPath(path);
      }
      else {
        tree.setSelectionPath(new TreePath(getModel().getRoot()));
      }
     
      mMousePressedTime = e.getWhen();
     
      checkForClickInExpandControl(getClosestPathForLocation(tree, e.getX(), e.getY()),e.getX(),e.getY());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.