Пример #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);
    }
Пример #2
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();
   }
 }