Package javax.swing.tree

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


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

    // 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

      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

        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

    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

    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

  }
 
  public void mouseReleased(MouseEvent e) {
    if(!e.isConsumed()) {
      if(SwingUtilities.isLeftMouseButton(e)) {
        final TreePath path = getClosestPathForLocation(tree, e.getX(), e.getY());
       
        if(path != null && !((DefaultMutableTreeNode)path.getLastPathComponent()).isLeaf() && ((mType == EXPAND_AND_COLLAPSE && (e.getWhen() - mMousePressedTime) < CLICK_WAIT_TIME) || mType != EXPAND_AND_COLLAPSE) && getPathBounds(tree,path).contains(e.getPoint())) {
          if(mClickedThread == null || !mClickedThread.isAlive()) {
            mClickedThread = new Thread("Single click tree UI double click") {
              public void run() {
                if(!tree.isExpanded(path)) {
                  tree.expandPath(path);
                  mWasExpanded = true;
                 
                  if(mType == AUTO_COLLAPSE_EXPAND && mLastSelectionPath != null && !mLastSelectionPath.isDescendant(path) && !path.isDescendant(mLastSelectionPath)) {
                    tree.collapsePath(mLastSelectionPath);
                  }
                }
                else if(mLastSelectionPath != null && tree.getSelectionPath().equals(mLastSelectionPath)){
                  tree.collapsePath(path);
View Full Code Here

    }
    return null;
  }

  public void reload(TreeNode node) {
    TreePath selection = PluginTree.getInstance() != null ? PluginTree.getInstance().getSelectionPath() : null;

    TreePath treePath = new TreePath(getPathToRoot(node));
    Enumeration<TreePath> e = null;

    if (treePath != null) {
      PluginTree t = PluginTree.getInstance();
      if (t != null) {
        e = PluginTree.getInstance().getExpandedDescendants(treePath);
      }
    }

    super.reload(node);

    if (e != null) {
      while (e.hasMoreElements()) {
        TreePath tree = e.nextElement();

        Object[] o = tree.getPath();

        for (int i = 1; i < o.length; i++) {
          TreeNode[] pathNodes = getPathToRoot((TreeNode) o[i]);

          if (node == null || pathNodes[0].toString().compareTo("Plugins") != 0) {
            TreeNode n1 = (TreeNode) o[i - 1];
            @SuppressWarnings("unchecked")
            Enumeration<DefaultMutableTreeNode> e1 = n1.children();

            while (e1.hasMoreElements()) {
              TreeNode n2 = e1.nextElement();
              if (n2.toString().compareTo(o[i].toString()) == 0) {
                o[i] = n2;
                break;
              }
            }
          }
        }

        tree = new TreePath(o);
        PluginTree.getInstance().expandPath(tree);
      }
    }

    if(selection != null) {
View Full Code Here

    setRootVisible(false);
    setShowsRootHandles(true);
    setRowHeight(17);

    expandPath(new TreePath(model.getRoot()));

    mInstance = this;
    /* remove the F2 key from the keyboard bindings of the JTree */
    InputMap inputMap = getInputMap();
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0);
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreePath

Copyright © 2018 www.massapicom. 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.