/**
   * Updates the display to reflect potential changes in project activation and the resulting
   * changes in working-set config activation, if any.
   */
  private void updateForActivation() {
    // update all working-set configs that intersect this config
    Collection<IWorkingSetProxy.ISnapshot> unaffectedWorkingSets =
        new java.util.HashSet<IWorkingSetProxy.ISnapshot>(workspace.getWorkingSets());

    for (IProject project : currentConfig.getWorkingSet().resolveProjects()) {
      for (Iterator<IWorkingSetProxy.ISnapshot> iter = unaffectedWorkingSets.iterator();
          iter.hasNext(); ) {
        IWorkingSetProxy.ISnapshot next = iter.next();

        if (next.resolveProjects().contains(project)) {
          iter.remove();

          if (next.updateActiveConfigurations()) {
            // major change. Refresh it altogether
            tree.refresh(next);
          } else {
            // lighter-weight updates of its configs
            for (IWorkingSetConfiguration config : next.getConfigurations()) {
              tree.update(config, null);
            }
          }
        }
      }
    }

    updateButtons();
  }
  /** Handler for the "Add..." button. */
  private void addConfig() {
    InputDialog dlg =
        new InputDialog(
            tree.getTree().getShell(),
            WorkingSetMessages.WSConfigsController_addDlg_title,
            WorkingSetMessages.WSConfigsController_addDlg_msg,
            WorkingSetMessages.WSConfigsController_addDlg_defaultName,
            new IInputValidator() {

              public String isValid(String newText) {
                if (currentWorkingSet.getConfiguration(newText) != null) {
                  return WorkingSetMessages.WSConfigsController_addDlg_nameExists;
                }
                if (newText.length() == 0) {
                  return WorkingSetMessages.WSConfigsController_addDlg_emptyName;
                }
                return null;
              }
            });

    if (dlg.open() == IDialogConstants.OK_ID) {
      IWorkingSetConfiguration.ISnapshot newConfig =
          currentWorkingSet.createConfiguration(dlg.getValue());
      tree.refresh(currentWorkingSet);
      tree.setSelection(new StructuredSelection(newConfig), true);
      currentConfig = newConfig;
      currentWorkingSet = currentConfig.getWorkingSet();

      // this is a "recently used" working set
      IWorkingSet ws = currentWorkingSet.resolve();
      if (ws != null) {
        WorkingSetConfigurationManager.WS_MGR.addRecentWorkingSet(ws);
      }
    }
  }
 /** Handler for the "Remove" button. */
 private void removeConfig() {
   currentWorkingSet.removeConfiguration(currentConfig);
   tree.refresh(currentWorkingSet);
 }