コード例 #1
0
  /**
   * Update the layouts tree.
   *
   * @param current The name of the current layout or <CODE>null</CODE> if none.
   */
  public void updateLayouts(Path current) throws PipelineException {
    DefaultMutableTreeNode root = null;
    {
      root = new DefaultMutableTreeNode(new TreeData(), true);

      {
        Path path = new Path(PackageInfo.getSettingsPath(), "layouts");
        rebuildTreeModel(path, new Path("/"), root);
      }

      DefaultTreeModel model = (DefaultTreeModel) pTree.getModel();
      model.setRoot(root);

      {
        Enumeration e = root.depthFirstEnumeration();
        if (e != null) {
          while (e.hasMoreElements()) {
            DefaultMutableTreeNode tnode = (DefaultMutableTreeNode) e.nextElement();
            pTree.expandPath(new TreePath(tnode.getPath()));
          }
        }
      }
    }

    pTree.clearSelection();
    if (current != null) {
      TreePath tpath = null;
      DefaultMutableTreeNode tnode = root;
      for (String comp : current.getComponents()) {
        DefaultMutableTreeNode next = null;
        Enumeration e = tnode.children();
        if (e != null) {
          while (e.hasMoreElements()) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) e.nextElement();
            TreeData data = (TreeData) child.getUserObject();
            if (data.toString().equals(comp)) {
              tpath = new TreePath(child.getPath());
              next = child;
              break;
            }
          }
        }

        if (next == null) break;

        tnode = next;
      }

      if (tpath != null) {
        pTree.setSelectionPath(tpath);
        pTree.makeVisible(tpath);
      }
    }
  }
コード例 #2
0
 /**
  * Returns all the paths that are located directly underneath a given path. From Globals
  *
  * @param w Wrapper class.
  * @param start The path to start the search underneath
  * @return
  * @throws PipelineException
  */
 public ArrayList<String> getChildrenNodes(MasterMgrClient mclient, String start)
     throws PipelineException {
   ArrayList<String> toReturn = new ArrayList<String>();
   TreeMap<String, Boolean> comps = new TreeMap<String, Boolean>();
   comps.put(start, false);
   NodeTreeComp treeComps = mclient.updatePaths(pUser, pView, comps);
   Path p = new Path(start);
   ArrayList<String> parts = p.getComponents();
   for (String comp : parts) {
     if (treeComps != null) treeComps = treeComps.get(comp);
   }
   for (String s : treeComps.keySet()) {
     toReturn.add(s);
   }
   return toReturn;
 }