예제 #1
0
 /** Destructor */
 public void terminate() {
   IWorkspace ws = ResourcesPlugin.getWorkspace();
   ws.removeResourceChangeListener(this);
   if (this.loadedSpec != null
       && PreferenceStoreHelper.getInstancePreferenceStore()
           .getBoolean(IPreferenceConstants.I_RESTORE_LAST_SPEC)) {
     PreferenceStoreHelper.getInstancePreferenceStore()
         .setValue(IPreferenceConstants.I_SPEC_LOADED, this.loadedSpec.getName());
   } else {
     PreferenceStoreHelper.getInstancePreferenceStore()
         .setValue(IPreferenceConstants.I_SPEC_LOADED, "");
   }
 }
  private void showOrHideProblemView() {
    boolean showProblems =
        PreferenceStoreHelper.getInstancePreferenceStore()
            .getBoolean(IPreferenceConstants.I_PARSER_POPUP_ERRORS);
    if (showProblems) {
      if (TLAMarkerHelper.currentSpecHasProblems()) {
        // This used to be in Activator. However,
        // at startup there might not be an
        // activePage which results in a
        // NullPointerException. Thus, have the
        // ProblemView check the parse status when
        // UI startup complete.
        ProblemView view = (ProblemView) UIHelper.getActivePage().findView(ProblemView.ID);
        // show
        if (view != null) {
          // already shown, hide
          UIHelper.hideView(ProblemView.ID);
        }

        // not shown, show
        UIHelper.openViewNoFocus(ProblemView.ID);
      } else {
        // hide
        UIHelper.hideView(ProblemView.ID);
      }
    }
  }
예제 #3
0
  /** Constructor */
  public WorkspaceSpecManager() {
    // initialize the spec life cycle manager
    lifecycleManager = new SpecLifecycleManager();

    IProgressMonitor monitor = null;

    IWorkspace ws = ResourcesPlugin.getWorkspace();

    String specLoadedName =
        PreferenceStoreHelper.getInstancePreferenceStore()
            .getString(IPreferenceConstants.I_SPEC_LOADED);

    IProject[] projects = ws.getRoot().getProjects();
    try {

      Spec spec = null;
      for (int i = 0; i < projects.length; i++) {
        // changed from projects[i].isAccessible()
        if (projects[i].isOpen()) {
          if (projects[i].hasNature(TLANature.ID)) {
            spec = new Spec(projects[i]);
            // Added by LL on 12 Apr 2011
            // If spec.rootFile = null, then this is a bad spec. So
            // we should report it and not perform addSpec(spec).  It
            // would be nice if we could report it to the user, but
            // it seems to be impossible to popup a window at this point
            // in the code.
            if (spec.getRootFile() == null) {
              Activator.getDefault()
                  .logError("The bad spec is: `" + projects[i].getName() + "'", null);
            } else {
              // This to threw a null pointer exception for Tom, probably causing the abortion
              // of the Toolbox start. But it started on the next attempt.  Should we catch the
              // and perhaps report the bad spec?
              addSpec(spec);
            }

            // load the spec if found
            if (spec.getName().equals(specLoadedName)) {
              this.setSpecLoaded(spec);
            }
          }
        } else {
          // DELETE closed projects
          projects[i].delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, monitor);
        }
      }

      if (specLoadedName != null && !specLoadedName.equals("") && this.loadedSpec == null) {
        // there was a spec loaded but it was not found
        // explicit un-set it
        setSpecLoaded(null);
      }

    } catch (CoreException e) {
      Activator.getDefault().logError("Error initializing specification workspace", e);
    }

    ws.addResourceChangeListener(this);

    Platform.getAdapterManager().registerAdapters(this, IProject.class);
  }