Examples of TreePath


Examples of javax.swing.tree.TreePath

      for(int i = 0; i < node.getChildCount(); i++) {
        FavoriteNode child = (FavoriteNode)node.getChildAt(i);

        if(child.isDirectoryNode()) {
          collapseAll(child);
          collapsePath(new TreePath(child.getPath()));
        }
      }

      if(!node.equals(mRootNode)) {
        collapsePath(new TreePath(node.getPath()));
      }
    }
  }
View Full Code Here

Examples of javax.swing.tree.TreePath

        expand(child);
      }
    }

    if(node.wasExpanded()) {
      expandPath(new TreePath((this.getModel()).getPathToRoot(node)));
    } else {
      collapsePath(new TreePath((this.getModel()).getPathToRoot(node)));
    }
  }
View Full Code Here

Examples of javax.swing.tree.TreePath

    if(rowBounds.y + rowBounds.height < p.y) {
      row = this.getRowCount();
    }

    TreePath path = getPathForRow(row);

    if(path == null) {
      path = new TreePath(mRootNode);
    }

    if(mTransferNode != null && !new TreePath(mTransferNode.getPath()).isDescendant(path)) {
      FavoriteNode last = (FavoriteNode)path.getLastPathComponent();
      FavoriteNode pointed = last;

      int target = getTargetFor(pointed, p, row);

      if(target == -1 || (target == 1 && !isExpanded(new TreePath(pointed.getPath())))) {
        if(!last.isRoot()) {
          last = (FavoriteNode)last.getParent();
        }
      }

      if(mTarget == 0 && (System.currentTimeMillis() - mDragOverStart) > 1000 && isCollapsed(new TreePath(last.getPath())) && last.getChildCount() > 0) {
        expandPath(new TreePath(last.getPath()));

        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            mTarget = -2;
          }
View Full Code Here

Examples of javax.swing.tree.TreePath

        FavoriteNode node = mTransferNode;
        FavoriteNode parent = (FavoriteNode)node.getParent();

        int row = getClosestRowForLocation(e.getLocation().x, e.getLocation().y);

        TreePath path = new TreePath(mRootNode);

        if(getRowBounds(row).y + getRowBounds(row).height < e.getLocation().y) {
          row = this.getRowCount();
        } else {
          path = getPathForRow(row);
        }

        if(path == null) {
          path = new TreePath(mRootNode);
        }

        FavoriteNode last = (FavoriteNode)path.getLastPathComponent();
        FavoriteNode pointed = last;
        int target = getTargetFor(pointed, e.getLocation(), row);

        if(!new TreePath(node.getPath()).isDescendant(path)) {
          setSelectionPath(null);

          parent.remove(node);

          int n = -1;

          if(target == -1 || (target == 1 && !isExpanded(new TreePath(pointed.getPath())))) {
            if(last.isRoot()) {
              n = 0;
            } else {
              n = last.getParent().getIndex(last);
              last = (FavoriteNode)last.getParent();
            }
          }

          if(target == -1) {
            last.insert(node, n);
          } else if(target == 0) {
            if(isExpanded(new TreePath(last))) {
              last.insert(node, 0);
            } else {
              last.add(node);
            }
          }
          else if(row != getRowCount()) {
            last.insert(node, n + 1);
          } else {
            last.add(node);
          }

          expandPath(new TreePath(last.getPath()));

          mExpandListenerIsEnabled = false;
          expand(last);
          mExpandListenerIsEnabled = true;
        }
View Full Code Here

Examples of javax.swing.tree.TreePath

    if(value != null && value.length() > 0) {
      FavoriteNode node = new FavoriteNode(value);

      if(parent.equals(mRootNode) || parent.isDirectoryNode()) {
        parent.add(node);
        expandPath(new TreePath(parent.getPath()));
      } else {
        ((FavoriteNode)parent.getParent()).insert(node,parent.getParent().getIndex(parent));
      }

      reload((FavoriteNode)node.getParent());
View Full Code Here

Examples of javax.swing.tree.TreePath

    }

    int row = getRowForPath(getSelectionPath());

    if(row != -1) {
      TreePath path = getPathForRow(row+rowCount);

      if(path != null) {
        FavoriteNode srcParent = (FavoriteNode)src.getParent();


        FavoriteNode target = (FavoriteNode)path.getLastPathComponent();
        FavoriteNode tarParent = target.equals(mRootNode) ? mRootNode : ((FavoriteNode)target.getParent());

        int n = tarParent.getIndex(target);

        srcParent.remove(src);

        if(n > -1) {
          tarParent.insert(src,n);
        } else {
          tarParent.add(src);
        }

        reload(srcParent);
        reload(tarParent);

        setSelectionPath(new TreePath(src.getPath()));

        expandPath(new TreePath(tarParent.getPath()));

        mExpandListenerIsEnabled = false;
        expand(tarParent);
        mExpandListenerIsEnabled = true;
      }
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())) {
          setSelectionPath(path);
        }
View Full Code Here

Examples of javax.swing.tree.TreePath

        if(e.isPopupTrigger()) {
          showContextMenu(e.getPoint());
        }

        if(SwingUtilities.isLeftMouseButton(e)) {
          final TreePath path = getClosestPathForLocation(tree, e.getX(), e.getY());

          if(path != null && ((FavoriteNode)path.getLastPathComponent()).containsFavorite()) {
            mLastSelectionPath = path;
            if(e.getClickCount() >= 2) {
              ManageFavoritesDialog.getInstance().editSelectedFavorite();
            }
          }
          else if(path != null && ((FavoriteNode)path.getLastPathComponent()).isDirectoryNode() && (e.getWhen() - mMousePressedTime) < CLICK_WAIT_TIME && getPathBounds(tree,path).contains(e.getPoint())) {
            if(mClickedThread == null || !mClickedThread.isAlive()) {
              mClickedThread = new Thread("Double click favorite") {
                public void run() {
                  if(!isExpanded(path)) {
                    expandPath(path);
View Full Code Here

Examples of javax.swing.tree.TreePath

    }

    FavoriteNode parent = (FavoriteNode)node;

    if(parent.wasExpanded()) {
      tree.expandPath(new TreePath((tree.getModel()).getPathToRoot(node)));
    } else {
      tree.collapsePath(new TreePath((tree.getModel()).getPathToRoot(node)));
    }
  }
View Full Code Here

Examples of javax.swing.tree.TreePath

      m_componentTree = new JTree(model) {
        public String getToolTipText(MouseEvent e) {
          if ((getRowForLocation(e.getX(), e.getY())) == -1) {
            return null;
          }
          TreePath currPath = getPathForLocation(e.getX(), e.getY());
          if (currPath.getLastPathComponent() instanceof DefaultMutableTreeNode) {
            DefaultMutableTreeNode node =
              (DefaultMutableTreeNode)currPath.getLastPathComponent();
            if (node.isLeaf()) {
              JTreeLeafDetails leaf = (JTreeLeafDetails)node.getUserObject();
              return leaf.getToolTipText();
            }
          }
          return null;
        }     
      };

      m_componentTree.setEnabled(true);
      m_componentTree.setToolTipText("");
      m_componentTree.setRootVisible(false);
      m_componentTree.setShowsRootHandles(true);
      m_componentTree.setCellRenderer(new BeanIconRenderer());
      DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
      selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
      m_componentTree.setSelectionModel(selectionModel);

      m_componentTree.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

          if (((e.getModifiers() & InputEvent.BUTTON1_MASK)
              != InputEvent.BUTTON1_MASK) || e.isAltDown()) {
            boolean clearSelection = true;
            /*TreePath path =
                m_componentTree.getPathForLocation(e.getX(), e.getY());
              if (path != null) {
                DefaultMutableTreeNode tNode =
                  (DefaultMutableTreeNode)path.getLastPathComponent();

                if (tNode.isLeaf()) {
                  System.out.println("Rick click selection");

//                  m_componentTree.setSelectionPath(path);
                }
              }*/

            if (clearSelection) {
              // right click cancels selected component
              m_toolBarBean = null;
              m_mode = NONE;
              KnowledgeFlowApp.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
              m_componentTree.clearSelection();
            }
          }


          TreePath p = m_componentTree.getSelectionPath();
          if (p != null) {
            if (p.getLastPathComponent() instanceof DefaultMutableTreeNode) {
              DefaultMutableTreeNode tNode = (DefaultMutableTreeNode)p.getLastPathComponent();

              if (tNode.isLeaf()) {
//                System.err.println("Selected : " + tNode.getUserObject().toString());
                Object userObject = tNode.getUserObject();
                if (userObject instanceof JTreeLeafDetails) {
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.