Esempio n. 1
0
  /** Builds the node tree for the current session. */
  private void buildTree() {
    // Populate the root node with children.
    List<Node> list = new LinkedList<Node>();
    SessionManager sm = SessionProvider.getSessionManager();
    Session session = sm.getCurrent();

    PathManager pm = PathProvider.getPathManager(session);
    List<String> roots = pm.getSourcePath();
    if (roots != null) {
      for (String root : roots) {
        FileObject fo = FileUtil.toFileObject(new File(root));
        if (fo != null) {
          // If archive, get the root of the archive.
          fo = PathConverter.convertToRoot(fo);
        }
        Node node = new SourceRootNode(fo);
        list.add(node);
      }
    }

    if (list.size() > 0) {
      Children children = new Children.Array();
      Node[] nodes = list.toArray(new Node[list.size()]);
      children.add(nodes);
      buildRoot(children);
    } else {
      buildRoot(Children.LEAF);
    }
  }
Esempio n. 2
0
 @Override
 protected void componentOpened() {
   super.componentOpened();
   // Build out the tree.
   buildTree();
   // Start listening to everything that affects our tree.
   SessionManager sm = SessionProvider.getSessionManager();
   sm.addSessionManagerListener(SourcesView.this);
   Iterator<Session> iter = sm.iterateSessions();
   while (iter.hasNext()) {
     Session session = iter.next();
     PathManager pm = PathProvider.getPathManager(session);
     pm.addPropertyChangeListener(SourcesView.this);
   }
 }
Esempio n. 3
0
 @Override
 protected void componentClosed() {
   super.componentClosed();
   // Clear the tree to release resources.
   buildRoot(Children.LEAF);
   // Stop listening to everything that affects our tree.
   SessionManager sm = SessionProvider.getSessionManager();
   sm.removeSessionManagerListener(this);
   Iterator<Session> iter = sm.iterateSessions();
   while (iter.hasNext()) {
     Session session = iter.next();
     PathManager pm = PathProvider.getPathManager(session);
     pm.removePropertyChangeListener(this);
   }
 }