Exemple #1
0
    @Override
    protected void performAction(Node[] activatedNodes) {
      PathEditorPanel editor = new PathEditorPanel();
      Session session = SessionProvider.getCurrentSession();
      PathManager pm = PathProvider.getPathManager(session);
      // Load the current sourcepath into the editor.
      List<String> sourcepath = pm.getSourcePath();
      if (sourcepath != null && sourcepath.size() > 0) {
        editor.setPath(sourcepath);
      }

      // Display the editor in a simple dialog.
      String title = NbBundle.getMessage(SourcesView.class, "LBL_SourcesView_EditTitle");
      NotifyDescriptor desc =
          new NotifyDescriptor.Confirmation(
              editor, title, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.QUESTION_MESSAGE);
      Object result = DialogDisplayer.getDefault().notify(desc);
      if (result != NotifyDescriptor.OK_OPTION) {
        // User cancelled the editor.
        return;
      }

      // Save the new sourcepath setting.
      List<String> paths = editor.getPath();
      List<String> roots = new LinkedList<String>();
      for (String path : paths) {
        File file = new File(path);
        // It is possible for the user to add paths that don't exist.
        if (file.exists() && file.canRead()) {
          roots.add(path);
        }
      }
      pm.setSourcePath(roots);
    }
Exemple #2
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);
    }
  }
Exemple #3
0
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   // See if the current session's sourcepath has changed.
   Session session = SessionProvider.getCurrentSession();
   PathManager pm = PathProvider.getPathManager(session);
   Object src = evt.getSource();
   String prop = evt.getPropertyName();
   if (src.equals(pm) && prop.equals(PathManager.PROP_SOURCEPATH)) {
     buildTree();
   }
 }
Exemple #4
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);
   }
 }
Exemple #5
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);
   }
 }