Examples of TreePath


Examples of javax.swing.tree.TreePath

  }
 
  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

Examples of javax.swing.tree.TreePath

    }
    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

Examples of javax.swing.tree.TreePath

    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

Examples of javax.swing.tree.TreePath

        Point ptDragOrigin = e.getDragOrigin();

        Point ptOffset = new Point();

        TreePath path = getPathForLocation(ptDragOrigin.x, ptDragOrigin.y);
        Point raPath = getPathBounds(path).getLocation();

        ptOffset.setLocation(ptDragOrigin.x - raPath.x, ptDragOrigin.y
            - raPath.y);
        mGhostRect.setRect(ptOffset.x, ptOffset.y,
View Full Code Here

Examples of javax.swing.tree.TreePath

      DataFlavor[] flavors = e.getCurrentDataFlavors();

      if (flavors != null && flavors.length == 1) {

        try {
          TreePath targetPath = ((PluginTree) ((DropTarget) e.getSource())
              .getComponent()).getPathForLocation(e.getLocation().x, e
              .getLocation().y);

          if (targetPath != null) {
            Node target = (Node)targetPath.getLastPathComponent();

            if(target.getProgramReceiveTarget() == null && targetPath.getPathCount() <= 2) {
              target = (Node) targetPath.getPathComponent(1);
            }

            if (flavors[0].getHumanPresentableName().equals("NodeExport")) {
              TreePath sourcePath = ((PluginTree) ((DropTarget) e.getSource())
                  .getComponent()).getSelectionPath();
              Node plugin = (Node) sourcePath.getPathComponent(1);

              if (!target.equals(plugin) && !targetPath.isDescendant(sourcePath) &&
                  !sourcePath.isDescendant(targetPath)) {
                if (target.equals(ReminderPlugin.getRootNode()
                    .getMutableTreeNode())) {
                  e.acceptDrag(e.getDropAction());
                  reject = false;
                  temp = ReminderPlugin.getInstance();
                  rejected = false;
                } else if(target.getProgramReceiveTarget() == null) {
                  PluginProxy[] pluginAccessArray = PluginProxyManager.getInstance().getActivatedPlugins();

                  for (PluginProxy pluginAccess : pluginAccessArray) {
                    if (pluginAccess.getRootNode() != null) {
                      if (pluginAccess.getRootNode().getMutableTreeNode().equals(target)) {
                        if (pluginAccess.canReceiveProgramsWithTarget()) {
                          e.acceptDrag(e.getDropAction());
                          reject = false;
                          temp = pluginAccess;
                          rejected = false;
                        } else {
                          mPlugin = null;
                          break;
                        }
                      }
                    }
                  }
                }
                else if(!target.equals(sourcePath.getLastPathComponent())){
                  e.acceptDrag(e.getDropAction());
                  reject = rejected = false;
                  temp = target.getProgramReceiveTarget();
                }
                else {
View Full Code Here

Examples of javax.swing.tree.TreePath

          e.printStackTrace();
        }

        if (flavors != null && flavors.length == 1) {
          try {
            TreePath targetPath = ((PluginTree) ((DropTarget) src)
                .getComponent()).getPathForLocation(loc.x, loc.y);
            Node target = (Node) targetPath.getLastPathComponent();

            if(target.getProgramReceiveTarget() == null && targetPath.getPathCount() <= 2) {
              target = (Node) targetPath.getPathComponent(1);
            }

            if (flavors[0].getHumanPresentableName().equals("NodeExport")) {

              TreePath sourcePath = ((PluginTree) ((DropTarget) src)
                  .getComponent()).getSelectionPath();
              Node plugin = (Node) sourcePath.getPathComponent(1);
              Node source = (Node) sourcePath.getLastPathComponent();

              if (target.equals(plugin) || targetPath.isDescendant(sourcePath) || sourcePath.isDescendant(targetPath)) {
                return;
              } else {
                Vector<Program> vec;
                if (source.isLeaf()) {
                  vec = new Vector<Program>();
View Full Code Here

Examples of javax.swing.tree.TreePath

  private void fireTreeModelChanged()
  {
    for (int i = 0; i < listeners.size(); i++)
    {
      final TreeModelListener l = (TreeModelListener) listeners.get(i);
      l.treeStructureChanged(new TreeModelEvent(this, new TreePath(root)));
    }
  }
View Full Code Here

Examples of javax.swing.tree.TreePath

    {
      if (configuration == null)
      {
        throw new IllegalStateException("Need a configuration");
      }
      final TreePath path = e.getPath();
      final Object lastPathElement = path.getLastPathComponent();
      if (lastPathElement instanceof ConfigTreeModuleNode)
      {
        final ConfigTreeModuleNode node = (ConfigTreeModuleNode) lastPathElement;
        final ConfigEditorPanel detailEditorPane = getDetailEditorPane();
        detailEditorPane.store();
View Full Code Here

Examples of javax.swing.tree.TreePath

      super.addListener(event, name, listener);
    }
  }

  private TreeItem[] getSelectedItems() {
    TreePath paths[] = tree.getSelectionPaths();
    if (paths == null)
      return new TreeItem[0];
    TreeItem items[] = new TreeItem[paths.length];
    for (int i = 0; i < paths.length; i++) {
      items[i] = (TreeItem) paths[i].getLastPathComponent();
View Full Code Here

Examples of javax.swing.tree.TreePath

  public void nodeChanged(TreeItem item) {
    ((DefaultTreeModel) tree.getModel()).nodeChanged(item);
  }

  private void setSelectedItems(TreeItem items[]) {
    TreePath paths[] = new TreePath[items.length];
    ArrayList pathItems = new ArrayList();

    for (int i = 0; i < items.length; i++) {
      TreeItem item = items[i];
      while (item != null) {
        pathItems.add(0, item);
        item = (TreeItem) item.getParent();
      }
      paths[i] = new TreePath(pathItems.toArray());
      pathItems.clear();
    }
    tree.setSelectionPaths(paths);
  }
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.