Ejemplo n.º 1
0
 @Override
 public void init(IWorkbench workbench, IStructuredSelection selection) {
   super.init(workbench, selection);
   setWindowTitle("New ABS class");
   firstSelection = selection.getFirstElement();
   AbsNature nature = ABSContentOutlineUtils.getNatureForObject(firstSelection);
   if (nature != null) {
     project = nature.getProject();
   }
 }
Ejemplo n.º 2
0
 private void createMarkers(AbsNature nat, SemanticErrorList errs) {
   try {
     nat.createMarkers(errs);
   } catch (CoreException e) {
     // ignore
   }
 }
Ejemplo n.º 3
0
 /**
  * Lists all products in the current project's module, incl. a "<base>" product if no particular
  * product is selected.
  *
  * @param preSelected The product that should be preselected, or null for <base>.
  */
 protected void fillProductDropDownMenue(String preSelected) {
   productDropDown.removeAll();
   productDropDown.add("<base>");
   IProject proj = getSelectedProject();
   if (proj == null) {
     return;
   }
   AbsNature n = UtilityFunctions.getAbsNature(proj);
   Model m = n.getCompleteModel();
   if (m == null) return;
   Collection<Product> prods = m.getProducts();
   if (prods == null) return;
   int i = 1; /* base comes first */
   int selected = 0;
   for (Product p : prods) {
     final String name = p.qualifiedName();
     productDropDown.add(name);
     if (name.equals(preSelected)) {
       selected = i;
     }
     i++;
   }
   productDropDown.select(selected);
 }
Ejemplo n.º 4
0
  /**
   * Don't recommend to start projects which have errors. TODO: manipulating the error message here
   * does not cooperate well with isValid().
   */
  protected boolean updateErrors() {
    boolean res = true;
    String projectName = getSelectedProjectName();
    String prod = getSelectedProductName();
    if (this.lastProjectName != null
        && this.lastProd != null
        && this.lastProjectName.equals(projectName)
        && this.lastProd.equals(prod)) {
      // use result from last time, so that we do not have to do a full typecheck
      // every time something changes in the run configuration dialog
      return lastResult;
    }

    if (projectName != null) {
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
      try {
        AbsNature nat = UtilityFunctions.getAbsNature(project);
        assert nat != null;
        synchronized (nat.modelLock) {
          Model model = nat.getCompleteModel();
          /* E.g. errors in the project */
          if (model == null) return false;
          /* Check product if any */

          // work on a copy:
          model = model.parseTreeCopy();

          if (prod != null) {
            model.flattenForProduct(prod);
            /* Type check again */
            model.flushCache(); // #335, see IncrementalModelBuilder#flushAll()
          }
          SemanticErrorList errs = model.getErrors();
          if (errs != null && !errs.isEmpty()) {
            createMarkers(nat, errs);
            throw new AbsJobException(new TypeCheckerException(errs));
          }
          errs = model.typeCheck();
          if (errs != null && !errs.isEmpty()) {
            createMarkers(nat, errs);
            throw new AbsJobException(new TypeCheckerException(errs));
          }
        }
        setErrorMessage(null);
      } catch (AbsJobException e) {
        setErrorMessage(e.getMessage());
        res = false;
      } catch (WrongProgramArgumentException e) {
        setErrorMessage(e.getMessage());
        res = false;
      } catch (DeltaModellingException e) {
        setErrorMessage(e.getMessage());
        res = false;
      }
      getLaunchConfigurationDialog().updateMessage();
    }
    // cache the result
    lastProd = prod;
    lastProjectName = projectName;
    lastResult = res;
    return res;
  }