コード例 #1
0
ファイル: TriggerAspect.java プロジェクト: damende/puzzle
 protected static boolean _privk3_evalTrigger(
     final TriggerAspectTriggerAspectProperties _self_,
     final Trigger _self,
     final EList<String> events) {
   String _expression = _self.getExpression();
   return events.contains(_expression);
 }
コード例 #2
0
 private void markAsFragment(final Multimap<TerminalRule, AbstractRule> calledFrom) {
   Set<TerminalRule> _keySet = calledFrom.keySet();
   final Function1<TerminalRule, Boolean> _function =
       (TerminalRule it) -> {
         boolean _isFragment = it.isFragment();
         return Boolean.valueOf((!_isFragment));
       };
   Iterable<TerminalRule> _filter = IterableExtensions.<TerminalRule>filter(_keySet, _function);
   final Function1<TerminalRule, Boolean> _function_1 =
       (TerminalRule it) -> {
         Collection<AbstractRule> _get = calledFrom.get(it);
         return Boolean.valueOf(this.allAreTerminalRules(_get));
       };
   Iterable<TerminalRule> _filter_1 =
       IterableExtensions.<TerminalRule>filter(_filter, _function_1);
   final Function1<TerminalRule, Boolean> _function_2 =
       (TerminalRule it) -> {
         EObject _eContainer = it.eContainer();
         EList<AbstractRule> _hiddenTokens = ((Grammar) _eContainer).getHiddenTokens();
         boolean _contains = _hiddenTokens.contains(it);
         return Boolean.valueOf((!_contains));
       };
   Iterable<TerminalRule> _filter_2 =
       IterableExtensions.<TerminalRule>filter(_filter_1, _function_2);
   final Consumer<TerminalRule> _function_3 =
       (TerminalRule it) -> {
         it.setFragment(true);
       };
   _filter_2.forEach(_function_3);
 }
コード例 #3
0
ファイル: InheritedDecorator.java プロジェクト: go2zo/ju4pa
 /**
  * Tests if the node is an inherited element
  *
  * @param node a node
  * @return <code>true</code> if the node is an inherited element <code>false</code> if not
  */
 protected boolean isInherited(Node node) {
   EObject element = node.getElement();
   if (element instanceof Element) {
     EObject container = node.eContainer();
     EObject graphicalParent = null;
     if (container instanceof DecorationNode) {
       graphicalParent = ((DecorationNode) container).getElement();
     } else if (container instanceof View) {
       graphicalParent = ((View) container).getElement();
     }
     if (graphicalParent instanceof Property || graphicalParent instanceof Classifier) {
       Classifier classifier = null;
       if (graphicalParent instanceof Property) {
         Type type = ((Property) graphicalParent).getType();
         if (type instanceof Classifier) {
           classifier = (Classifier) type;
         }
       } else {
         classifier = (Classifier) graphicalParent;
       }
       if (classifier != null) {
         EList<NamedElement> inheritedMembers = classifier.getInheritedMembers();
         return inheritedMembers.contains(element);
       }
     }
   }
   return false;
 }
コード例 #4
0
  @Override
  public void execute() {
    for (ScatterSet ds : scatterSets) {
      // ok, we may have to add it to the chartset first
      ChartSet charts = parent.getParent();
      EList<SelectiveAnnotation> annots = charts.getSharedAxis().getAnnotations();
      SelectiveAnnotation host = null;
      for (SelectiveAnnotation annot : annots) {
        if (annot.getAnnotation().getName() != null
            && annot.getAnnotation().getName().equals(ds.getName())) {
          host = annot;
          break;
        }
      }

      if (host == null) {
        StackedchartsFactory factory = new StackedchartsFactoryImpl();
        host = factory.createSelectiveAnnotation();
        host.setAnnotation(ds);
        annots.add(host);
      }

      // check we're not already in that chart
      EList<Chart> appearsIn = host.getAppearsIn();
      if (!appearsIn.contains(parent)) {
        appearsIn.add(parent);
      }
    }
  }
コード例 #5
0
 /**
  * Test if a possibleSub eclass is a sub eclass
  *
  * @param aclass, cannot be null
  * @param possibleSubClasse, cannot be null
  * @return true if possible eclass is a subtype of a eclass or false
  */
 public boolean isSubClass(EClassifier aclass, EClass possibleSubClasse) {
   if (aclass.equals(possibleSubClasse)) {
     return true;
   }
   EList<EClass> superTypeList = possibleSubClasse.getEAllSuperTypes();
   if (superTypeList.contains(aclass)) {
     return true;
   }
   return false;
 }
コード例 #6
0
  protected List<Type> getChoiceOfValues(org.eclipse.uml2.uml.Package package_) {
    List<Type> choiceOfValues = new ArrayList<Type>();

    Resource eResource = package_.eResource();
    ResourceSet resourceSet = eResource == null ? null : eResource.getResourceSet();

    if (resourceSet != null) {

      try {
        resourceSet.getResource(URI.createURI(UMLResource.UML_PRIMITIVE_TYPES_LIBRARY_URI), true);
      } catch (Exception e) {
        // ignore
      }

      try {
        resourceSet.getResource(URI.createURI(UMLResource.JAVA_PRIMITIVE_TYPES_LIBRARY_URI), true);
      } catch (Exception e) {
        // ignore
      }

      try {
        resourceSet.getResource(URI.createURI(UMLResource.ECORE_PRIMITIVE_TYPES_LIBRARY_URI), true);
      } catch (Exception e) {
        // ignore
      }

      try {
        resourceSet.getResource(URI.createURI(UMLResource.XML_PRIMITIVE_TYPES_LIBRARY_URI), true);
      } catch (Exception e) {
        // ignore
      }
    }

    if (eResource != null) {
      EList<NamedElement> members = package_.getMembers();
      TreeIterator<?> allContents =
          resourceSet == null ? eResource.getAllContents() : resourceSet.getAllContents();

      while (allContents.hasNext()) {
        Object object = allContents.next();

        if (object instanceof Type && !members.contains(object)) {
          Type type = (Type) object;

          if (type.getNearestPackage().makesVisible(type)) {
            choiceOfValues.add(type);
          }
        }
      }
    }

    Collections.<Type>sort(choiceOfValues, new TextComparator<Type>());

    return choiceOfValues;
  }
コード例 #7
0
 /**
  * @param copyObjs
  * @return 转换为粘贴对象
  */
 private Collection<Object> getPasteObjs(Collection<Object> copyObjs, EClass eclass) {
   List<Object> objs = new ArrayList<Object>();
   Map<EStructuralFeature, EStructuralFeature> map =
       new HashMap<EStructuralFeature, EStructuralFeature>();
   // 由第一个复制对象,找出复制对象和粘贴对象匹配的属性
   Iterator<Object> it = copyObjs.iterator();
   if (it.hasNext()) {
     Object obj = it.next();
     if (obj instanceof EObject) {
       EObject copyObj = (EObject) obj;
       // 如果是同一个编辑器内进行粘贴,直接返回复制对象集合
       if (copyObj.eClass().equals(eclass)) {
         return copyObjs;
       }
       // name一样,则表示属性匹配
       for (EStructuralFeature copyFeature : copyObj.eClass().getEAllStructuralFeatures()) {
         if (!exclude.contains(copyFeature)) {
           for (EStructuralFeature pasteFeature : eclass.getEAllStructuralFeatures()) {
             if (StringUtils.equals(copyFeature.getName(), pasteFeature.getName())) {
               map.put(copyFeature, pasteFeature);
               break;
             }
           }
         }
       }
     }
   }
   // 如果没有匹配的属性,则返回空集合
   if (map.isEmpty()) {
     return objs;
   }
   for (Object obj : copyObjs) {
     EObject copyObj = (EObject) obj;
     EObject pasteObj = eclass.getEPackage().getEFactoryInstance().create(eclass);
     for (Entry<EStructuralFeature, EStructuralFeature> entry : map.entrySet()) {
       EStructuralFeature copyFeature = entry.getKey();
       EStructuralFeature pasteFeature = entry.getValue();
       if (copyFeature instanceof EAttribute) {
         // 设置匹配属性值
         pasteObj.eSet(pasteFeature, copyObj.eGet(copyFeature));
       } else if (copyFeature instanceof EReference) {
         // 设置匹配子集
         Collection<Object> tmp = (Collection<Object>) copyObj.eGet(copyFeature);
         if (tmp != null) {
           pasteObj.eSet(
               pasteFeature,
               getPasteObjs(
                   EcoreUtil.copyAll(tmp), ((EReference) pasteFeature).getEReferenceType()));
         }
       }
     }
     objs.add(pasteObj);
   }
   return objs;
 }
コード例 #8
0
 /**
  * Unapply profiles duplicated for control action
  *
  * @param selection
  * @param target the resource target
  */
 private void unapplyDuplicateProfiles(final EObject selection, Resource target) {
   Package _package = (Package) selection;
   EList<Profile> allAppliedProfiles = _package.getAllAppliedProfiles();
   if (!allAppliedProfiles.isEmpty()) {
     for (Profile profile : new ArrayList<Profile>(_package.getAppliedProfiles())) {
       if (allAppliedProfiles.contains(profile)) {
         // profile is duplicated, unapply it
         ProfileApplicationHelper.removeProfileApplicationDuplication(_package, profile, true);
       }
     }
   }
 }
コード例 #9
0
 @SuppressWarnings("unchecked")
 public static void addParameterObjectToList(
     EPlanElement element, String parameterName, Object object)
     throws UndefinedParameterException {
   EObject data = element.getData();
   EStructuralFeature feature = getParameterFeature(data, parameterName);
   Object value = data.eGet(feature);
   if (!(value instanceof EList)) {
     Logger logger = Logger.getLogger(ADParameterUtils.class);
     logger.warn("feature value '" + value + "' is not EList: " + parameterName);
     return;
   }
   EList list = (EList) value;
   if (object != null && !list.contains(object)) {
     list.add(object);
   }
 }
コード例 #10
0
  protected EClass selectNewObjectType(EObject oldObject) {
    ModelEnablementDescriptor enablements =
        TargetRuntime.getCurrentRuntime().getModelEnablements(oldObject);
    EClass newType = getBusinessObjectClass();

    // build a list of possible subclasses for the popup menu
    List<EClass> subtypes = new ArrayList<EClass>();
    for (EClassifier ec : Bpmn2Package.eINSTANCE.getEClassifiers()) {
      if (ec instanceof EClass) {
        if (((EClass) ec).isAbstract()) {
          continue;
        }
        EList<EClass> superTypes = ((EClass) ec).getEAllSuperTypes();
        if (superTypes.contains(newType) && enablements.isEnabled((EClass) ec)) {
          if (ec != Bpmn2Package.eINSTANCE.getBoundaryEvent()
              && ec != Bpmn2Package.eINSTANCE.getStartEvent()) {
            subtypes.add((EClass) ec);
          }
        }
      }
    }

    // show popup menu
    boolean doit = subtypes.size() > 0;
    if (doit) {
      newType = subtypes.get(0);
      if (subtypes.size() > 1) {
        PopupMenu popupMenu = new PopupMenu(subtypes, labelProvider);
        doit = popupMenu.show(Display.getCurrent().getActiveShell());
        if (doit) {
          newType = (EClass) popupMenu.getResult();
          return newType;
        }
      }
    }

    return null;
  }
コード例 #11
0
 public boolean contains(Object o) {
   return copy.contains(o);
 }
コード例 #12
0
  @SuppressWarnings("unchecked")
  public void execute() {
    // if the object into which this value is being added has other adapters execute those first
    executeIfNeeded(object);

    // remove this adapter from the value - this adapter is a one-shot deal!
    value.eAdapters().remove(this);
    try {
      Object o = object.eGet(feature);
    } catch (Exception e1) {
      try {
        Object o = value.eGet(feature);
        // this is the inverse add of object into value
        o = value;
        value = object;
        object = (EObject) o;
      } catch (Exception e2) {
      }
    }
    // if there are any EObjects contained or referenced by this value, execute those adapters first
    executeChildren(value);

    // set the value in the object
    boolean valueChanged = false;
    final EList<EObject> list = feature.isMany() ? (EList<EObject>) object.eGet(feature) : null;
    if (list == null) valueChanged = object.eGet(feature) != value;
    else valueChanged = !list.contains(value);

    if (valueChanged) {
      TransactionalEditingDomain domain = getEditingDomain();
      if (domain == null) {
        if (list == null) object.eSet(feature, value);
        else list.add(value);
        // assign the value's ID if it has one:
        // because of changes made by cascading InsertionAdapters,
        // the object could now be contained in a resource and hence
        // the setID() will need to be executed on the command stack.
        domain = getEditingDomain();
        if (domain == null) {
          ModelUtil.setID(value);
        } else {
          domain
              .getCommandStack()
              .execute(
                  new RecordingCommand(domain) {
                    @Override
                    protected void doExecute() {
                      ModelUtil.setID(value);
                    }
                  });
        }
      } else {
        domain
            .getCommandStack()
            .execute(
                new RecordingCommand(domain) {
                  @Override
                  protected void doExecute() {
                    ExtendedPropertiesAdapter adapter =
                        (ExtendedPropertiesAdapter)
                            AdapterUtil.adapt(object, ExtendedPropertiesAdapter.class);
                    if (adapter != null) {
                      adapter.getFeatureDescriptor(feature).setValue(value);
                    } else {
                      if (list == null) object.eSet(feature, value);
                      else list.add(value);
                    }
                    // assign the value's ID if it has one
                    ModelUtil.setID(value);
                  }
                });
      }
    }
  }
コード例 #13
0
  protected void synchronizeMissingAssociations(
      FormContainer o,
      List<FormElement> children,
      AbstractClass real_class,
      Set<FormGroup> groups,
      String filterNS) {

    List<Association> allAssociations = real_class.getAllSourceAssociations();

    // get FormElement that miss
    ArrayList<Association> missAtt = new ArrayList<Association>();

    if (allAssociations != null) {
      missAtt.addAll(allAssociations);
    }

    for (FormElement formElement : children) {
      ModelElement ref = formElement.getRef();
      if (ref != null && ref instanceof Association) {
        // linked element is attribute so remove this attribute from the missing list
        missAtt.remove(ref);
      }
    }

    EList<FormGroup> allSubGroups = o.getAllSubGroups();
    groups.addAll(allSubGroups);

    // now we have the attribute missing list
    // initialize missing Field
    for (Association ass : missAtt) {

      FormElement fieldForAssociation = null;
      if (o instanceof FormClass || o instanceof FormWorkflow) {
        fieldForAssociation = ClassDiagramUtils.getModelChoiceFieldForAssociation(ass, real_class);
      } else if (o instanceof FormSearch) {
        fieldForAssociation =
            ClassDiagramUtils.transformAssociationIntoModelChoiceSearchField(ass, real_class);
      }

      if (WorkflowInitialization.filterFormElement(filterNS, fieldForAssociation)) {

        // get where to add the field
        FormGroup parent = null;
        // mybe a group exist with ref to the attribute container

        // search for matching group

        for (FormGroup formGroup : groups) {
          ModelElement ref = formGroup.getRef();
          if (ref instanceof AbstractClass
              && ((AbstractClass) ref).getSourceAssociations().contains(ass)) {
            // matching group founded
            parent = formGroup;
            break;
          }
        }

        if (createMissingGroup && parent == null) {
          AbstractClass source = null;
          EList<AbstractClass> sources = ass.getSource();
          if (sources.size() == 1) {
            source = sources.get(0);
          } else {
            EList<AbstractClass> allLinkedAbstractClass = real_class.getAllLinkedAbstractClass();
            boolean contains = allLinkedAbstractClass.contains(sources.get(0));
            if (contains) {
              source = sources.get(0);
            } else {
              source = sources.get(1);
            }
          }
          parent = ClassInitialization.createGroup(source);
          addChild(o, parent);
        }

        // add new Field to the parent
        if (parent == null) {
          parent = o;
        }
        addChild(parent, fieldForAssociation);
      }
    }
  }
コード例 #14
0
 protected void addAdapter(Notifier notifier) {
   EList<Adapter> adapters = notifier.eAdapters();
   if (!adapters.contains(this)) {
     adapters.add(this);
   }
 }
  /**
   * Validate the model. All checks are performed for all automata in the file. This method checks
   * that
   *
   * <ul>
   *   <li>only allowed extension are used. Allowed extension are {@link
   *       org.ect.ea.extensions.clocks.AutomatonClocksProvider}, {@link
   *       org.ect.ea.extensions.clocks.TCADataConstraintsProvider}, {@link
   *       org.ect.ea.extensions.constraints.ConstraintExtensionProvider}, {@link
   *       org.ect.ea.extensions.startstates.StartStateExtensionProvider}, {@link
   *       org.ect.ea.extensions.portnames.AutomatonPortNamesProvider}, {@link
   *       org.ect.ea.extensions.portnames.TransitionPortNamesProvider}, {@link
   *       org.ect.ea.extensions.clocks.TransitionUpdateProvider}, {@link
   *       org.ect.ea.extensions.clocks.TransitionGuardProvider}, {@link
   *       org.ect.ea.extension.stateMemory.StateMemoryExtensionProvider} and {@link
   *       org.ect.ea.extensions.clocks.StateInvariantProvider}.
   *   <li>all required extensions are used. Required extensions are {@link
   *       org.ect.ea.extensions.startstates.StartStateExtensionProvider}, {@link
   *       org.ect.ea.extensions.portnames.AutomatonPortNamesProvider} and {@link
   *       org.ect.ea.extensions.portnames.TransitionPortNamesProvider}.
   *   <li>depending on whether the automaton is a CA or a TCA, some other extensions are required
   *       and forbidden:
   *       <ul>
   *         <li>Required extensions of TCA are {@link
   *             org.ect.ea.extensions.clocks.TCADataConstraintsProvider}, {@link
   *             org.ect.ea.extensions.clocks.AutomatonClocksProvider}, {@link
   *             org.ect.ea.extensions.clocks.TransitionGuardProvider}, {@link
   *             org.ect.ea.extensions.clocks.TransitionUpdateProvider} and {@link
   *             org.ect.ea.extensions.clocks.StateInvariantProvider}. These are also the forbidden
   *             extensions for CA.
   *         <li>Forbidden extensions of TCA are {@link
   *             org.ect.ea.extensions.constraints.ConstraintExtensionProvider}. These are also the
   *             required extensions for CA.
   *       </ul>
   *   <li>all names (except for memory cells and ports) are unique within the system.
   *   <li>memory cell names may occur more than once in one automaton, but must be unique between
   *       different automata, and must not equal any other name.
   *   <li>port names may be shared between automata, but must be different from all other names
   *   <li>there exists exactly one start state per automaton.
   *   <li>untimed CA (that means without clock extensions) do not have transitions with empty name
   *       set
   *   <li>TCA transition with empty name set do not have an associated data constraint
   *   <li>there exist no names {@link org.ect.ea.extensions.clocks.ClockUtils#GLOBAL_CLOCK} or
   *       {@link org.ect.ea.extensions.clocks.ClockUtils#NO_FLOW_NAME}
   *   <li>the range of data values is well-formed, i.e. either on the form
   *       <tt>lowerBound..upperBound</tt>, with <tt>lowerBound=0</tt>, <tt>upperBound>=1</tt>, or
   *       empty (for infinite data domain)
   *   <li>integer values in the data constraints lie within the given range
   *   <li>unfolding depth is at least 1
   *   <li>the target language is one of [mathsat,msat]
   *   <li>the output file name is not empty
   * </ul>
   */
  public IStatus validateGenModel(IGenModel genModel) {

    EList<Automaton> automata = ((Automaton) genModel.getTarget()).getModule().getAutomata();

    String projectName = genModel.getProperty(IGenModel.PROJECT_NAME);
    if (projectName == null || projectName.equals("")) {
      return new Status(IStatus.ERROR, PLUGIN_ID, "Project name cannot be empty.");
    }

    String rng = genModel.getProperty(CodegenUtils.PROPERTY_RANGE);
    // rng = rng.replace("..", ",");

    String targetlang = genModel.getProperty("targetlang");

    // for temporary usage
    // String tempS = "";
    EList<String> tempL = new BasicEList<String>();
    boolean tempB;

    /* check extensions */
    /* Every automaton must support the automaton port names, transition
     * port names, and start state extension, and may support the state
     * memory extension.
     * If the automaton is a CA (untimed), it must support the constraint
     * extension, and must not support the TCA data constraint,
     * automaton clocks, transition guard, transition update and
     * invariant extension.
     * If the automaton is a TCA (timed), it must support the TCA data
     * constraint, automaton clocks, transition guard, transition update and
     * invariant extension, and must not support the constraint extension.
     * */

    // check that only allowed extensions are used
    // note that not all these extensions can be used at the same time
    final EList<String> allowedExtensions = new BasicEList<String>();
    allowedExtensions.add(ClockUtils.STATE_MEMORY_ID);
    allowedExtensions.add(ClockUtils.AUTOMATON_CLOCKS_ID);
    allowedExtensions.add(ClockUtils.TRANSITION_GUARD_ID);
    allowedExtensions.add(ClockUtils.TRANSITION_UPDATE_ID);
    allowedExtensions.add(ClockUtils.INVARIANT_ID);
    allowedExtensions.add(ClockUtils.DATA_CONSTRAINT_ID);
    allowedExtensions.add(ClockUtils.CONSTRAINT_ID);
    allowedExtensions.add(ClockUtils.AUTOMATON_PORT_NAMES_ID);
    allowedExtensions.add(ClockUtils.TRANSITION_PORT_NAMES_ID);
    allowedExtensions.add(ClockUtils.START_STATE_ID);

    final EList<String> requiredExtensions = new BasicEList<String>();
    requiredExtensions.add(ClockUtils.START_STATE_ID);
    requiredExtensions.add(ClockUtils.AUTOMATON_PORT_NAMES_ID);
    requiredExtensions.add(ClockUtils.TRANSITION_PORT_NAMES_ID);

    final EList<String> requiredCAExtensions = new BasicEList<String>();
    requiredCAExtensions.add(ClockUtils.CONSTRAINT_ID);

    final EList<String> forbiddenCAExtensions = new BasicEList<String>();
    forbiddenCAExtensions.add(ClockUtils.DATA_CONSTRAINT_ID);
    forbiddenCAExtensions.add(ClockUtils.AUTOMATON_CLOCKS_ID);
    forbiddenCAExtensions.add(ClockUtils.TRANSITION_GUARD_ID);
    forbiddenCAExtensions.add(ClockUtils.TRANSITION_UPDATE_ID);
    forbiddenCAExtensions.add(ClockUtils.INVARIANT_ID);

    final EList<String> requiredTCAExtensions = new BasicEList<String>(forbiddenCAExtensions);
    final EList<String> forbiddenTCAExtensions = new BasicEList<String>(requiredCAExtensions);

    EList<String> names = new BasicEList<String>(); // to check uniqueness of names
    Set<String> portNames =
        new HashSet<
            String>(); // port names can be shared, but must be different from other names, use set
                       // to automatically remove duplicates

    boolean timed = false;
    boolean untimed = false;
    boolean allMem = false;
    boolean noMem = false;

    for (Automaton automaton : automata) {

      // add automaton name to global name set name
      names.add(automaton.getName());

      // check that only allowed extensions are used
      final EList<String> usedExtensions = automaton.getUsedExtensionIds();
      if (!allowedExtensions.containsAll(usedExtensions)) {
        tempL.clear();
        tempL.addAll(usedExtensions);
        tempL.removeAll(allowedExtensions);
        return new Status(
            IStatus.ERROR, PLUGIN_ID, "Extension(s) used but not supported: " + tempL);
      }

      // check that all required extensions are used
      if (!usedExtensions.containsAll(requiredExtensions)) {
        tempL.clear();
        tempL.addAll(requiredExtensions);
        tempL.removeAll(usedExtensions);
        return new Status(
            IStatus.ERROR, PLUGIN_ID, automaton.getName() + "must support extension(s): " + tempL);
      }

      // check that exactly one of the constraint extensions is used, infer CA or TCA from that
      if (usedExtensions.contains(ClockUtils.DATA_CONSTRAINT_ID)) {
        timed = true;
        if (untimed == true) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "All automata must support same constraint extension, either "
                  + ClockUtils.DATA_CONSTRAINT_ID
                  + " or "
                  + ClockUtils.CONSTRAINT_ID);
        }
      }
      if (usedExtensions.contains(ClockUtils.CONSTRAINT_ID)) {
        untimed = true;
        if (timed == true) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "All automata must support same constraint extension, either "
                  + ClockUtils.DATA_CONSTRAINT_ID
                  + " or "
                  + ClockUtils.CONSTRAINT_ID);
        }
      }
      if (!(timed || untimed)) { // no constraint extension is used
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "All automata must support same constraint extension, either "
                + ClockUtils.DATA_CONSTRAINT_ID
                + " or "
                + ClockUtils.CONSTRAINT_ID);
      }

      // if CA: check for required and forbidden extensions
      if (untimed) {
        if (!usedExtensions.containsAll(requiredCAExtensions)) {
          tempL.clear();
          tempL.addAll(requiredCAExtensions);
          tempL.removeAll(usedExtensions);
          return new Status(
              IStatus.ERROR, PLUGIN_ID, "Untimed CA must support extension(s): " + tempL);
        }
        tempL.clear();
        tempL.addAll(usedExtensions);
        tempL.addAll(forbiddenCAExtensions);
        tempL = new StringListExtension(tempL).getDuplicateEntries();
        if (!tempL.isEmpty()) {
          return new Status(
              IStatus.ERROR, PLUGIN_ID, "Untimed CA must not support extension(s): " + tempL);
        }
      }
      // if TCA: check for required and forbidden extensions
      if (timed) {

        if (!usedExtensions.containsAll(requiredTCAExtensions)) {
          tempL.clear();
          tempL.addAll(requiredTCAExtensions);
          tempL.removeAll(usedExtensions);
          return new Status(IStatus.ERROR, PLUGIN_ID, "TCA must support extension(s): " + tempL);
        }
        tempL.clear();
        tempL.addAll(usedExtensions);
        tempL.addAll(forbiddenTCAExtensions);
        tempL = new StringListExtension(tempL).getDuplicateEntries();
        if (!tempL.isEmpty()) {
          return new Status(
              IStatus.ERROR, PLUGIN_ID, "TCA must not support extension(s): " + tempL);
        }
      }

      // check that the automaton has states (otherwise, code generation does not make sense)
      if (automaton.getStates().isEmpty()) {
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "Automaton does not have states, code generation does not make sense.");
      }

      // check that the automaton has transitions (otherwise, code generation does not make sense)
      if (automaton.getTransitions().isEmpty()) {
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "Automaton does not have transitions, code generation does not make sense.");
      }

      // check for state memory extension
      if (usedExtensions.contains(ClockUtils.STATE_MEMORY_ID)) {
        allMem = true;
        if (noMem) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "State memory must be support by all automata or not at all.");
        }
      } else {
        noMem = true;
        if (allMem) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "State memory must be support by all automata or not at all.");
        }
      }

      // create EList of memory cell names (if memory cells are used)
      if (allMem) {
        EList<String> thisAutoMemCells = new BasicEList<String>();
        for (State s : automaton.getStates()) {
          try {
            tempL =
                StringListExtension.parse(s.findExtension(ClockUtils.STATE_MEMORY_ID).toString())
                    .getValues(); // memory cells of current state
            if (!tempL.isEmpty()) { // empty if state does not have memory cells
              thisAutoMemCells.addAll(tempL);
            }
          } catch (ParseException pe) {
            return new Status(
                IStatus.ERROR,
                PLUGIN_ID,
                "Unexpected error while trying to parse memory cells of " + s.getName());
          }
        }
        // remove duplicate cells from current automaton
        StringListExtension sle = new StringListExtension(thisAutoMemCells);
        sle.removeDuplicateEntries();
        // add names to global EList (checked later)
        tempL = sle.getValues();
        for (String s : tempL) {
          names.add(s);
        }
      }

      // add state names to global name set (checked later), and check for initial states
      tempB = false; // for initial states
      for (State s : automaton.getStates()) {
        if (s.getName() == null || s.getName().equals("")) {
          return new Status(IStatus.ERROR, PLUGIN_ID, "States must have a name.");
        }
        names.add(s.getName());
        if (CA.isStartState(s)) {
          if (tempB == true) {
            return new Status(
                IStatus.ERROR, PLUGIN_ID, "Each automaton must have exactly one initial location");
          }
          tempB = true;
        }
        if (!tempB) {
          return new Status(
              IStatus.ERROR, PLUGIN_ID, "Each automaton must have exactly one initial location");
        }
      }

      // untimed CA transitions must not have empty name set
      if (untimed) {
        for (Transition t : automaton.getTransitions()) {
          if (((StringListExtension) t.findExtension(ClockUtils.TRANSITION_PORT_NAMES_ID))
              .getValues()
              .isEmpty()) {
            return new Status(
                IStatus.ERROR, PLUGIN_ID, "Transitions of untimed CA must not have empty name set");
          }
        }
      }

      // TCA transitions with the empty name set must not have a data
      // constraint on ports (only memory cells)
      // actually this check should not be necessary, it is checked during editing (by the parser)
      // already
      if (timed) {
        for (Transition t : automaton.getTransitions()) {
          if (((StringListExtension) t.findExtension(ClockUtils.TRANSITION_PORT_NAMES_ID))
              .getValues()
              .isEmpty()) { // found transition with empty port set
            // get the constraint
            String cons = t.findExtension(ClockUtils.DATA_CONSTRAINT_ID).toString();
            TCADataParser parser = new TCADataParser(cons);
            try {
              tempL = parser.get_port_names();
              if (!tempL.isEmpty()) {
                return new Status(
                    IStatus.ERROR,
                    PLUGIN_ID,
                    "Invisible transitions (with empty port set) must not have a data constraint on ports.");
              }
            } catch (RecognitionException pe) {
              return new Status(
                  IStatus.ERROR, PLUGIN_ID, "Unexpected error while trying to parse " + cons);
            }
          }
        }
      }

      // add clock names to global name set (checked later)
      if (timed) {
        for (String c : ClockUtils.getClocks(automaton)) {
          names.add(c);
        }
      }

      // add port names to global port name set (checked later)
      for (String p :
          ((StringListExtension) automaton.findExtension(ClockUtils.AUTOMATON_PORT_NAMES_ID))
              .getValues()) {
        portNames.add(p);
      }
    }

    // check range of data values
    // either 'lowerBound..upperBound' or empty (=infinite)
    if (rng.trim().equals("")) {
      infinite = true;
    } else {
      infinite = false;
      if (!rng.contains("..")) {
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "Finite range must be given in the form '0..upperBound'.\nupperBound must be an integer value strictly greater than 0.");
      }
      try {
        lowerBound = Integer.parseInt(rng.substring(0, rng.indexOf(".")));
        if (lowerBound != 0) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "Finite range must be given in the form '0..upperBound'.\nLower bounds other than 0 are not (yet) supported.");
        }
      } catch (NumberFormatException nfe) {
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "Finite range must be given in the form '0..upperBound'.\nLower bounds other than 0 are not (yet) supported.");
      }
      try {
        upperBound = Integer.parseInt(rng.substring(rng.lastIndexOf(".") + 1, rng.length()));
        if (upperBound < 1) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "Finite range must be given in the form '0..upperBound'.\nupperBound must be an integer value strictly greater than 0.");
        }
      } catch (NumberFormatException nfe) {
        return new Status(
            IStatus.ERROR,
            PLUGIN_ID,
            "Finite range must be given in the form '0..upperBound'.\nupperBound must be an integer value strictly greater than 0.");
      }
    }

    // check that integer values used in data constraints are within the range (if finite)
    if (!infinite) {
      int min = -1;
      int max = 0;
      for (Automaton automaton : automata) {
        for (Transition t : automaton.getTransitions()) {
          String cons = t.findExtension(ClockUtils.DATA_CONSTRAINT_ID).toString();
          TCADataParser parser = new TCADataParser(cons);
          try {
            tempL = parser.get_minmax_int_values();
            min = Math.min(min, Integer.parseInt(tempL.get(0)));
            max = Math.max(max, Integer.parseInt(tempL.get(1)));
          } catch (RecognitionException re) {
            return new Status(
                IStatus.ERROR, PLUGIN_ID, "Unexpected error while trying to parse " + cons);
          }
        }
        if ((min < -1) || (max > this.upperBound)) {
          return new Status(
              IStatus.ERROR,
              PLUGIN_ID,
              "Integer values in data constraints are outside declared range.");
        }
      }
    }

    // check for spaces in all but port names
    for (String s : names) {
      if (s.contains(" ")) {
        return new Status(IStatus.ERROR, PLUGIN_ID, "Names must not contain spaces: '" + s + "'");
      }
    }

    // check for duplicate names in all but port names
    tempL = new StringListExtension(names).getDuplicateEntries();
    if (!tempL.isEmpty()) {
      return new Status(
          IStatus.ERROR,
          PLUGIN_ID,
          "Names (except for port names) must not be shared between automata: "
              + tempL.toString().replace("[", "").replace("]", ""));
    }

    // check for spaces in port names
    for (String p : portNames) {
      if (p.contains(" ")) {
        return new Status(IStatus.ERROR, PLUGIN_ID, "Names must not contain spaces: '" + p + "'");
      }
    }

    // compare port names with all other names, check for duplicates between the two sets
    StringListExtension sle = new StringListExtension(portNames);
    sle.removeDuplicateEntries();
    tempL = sle.getValues();
    tempL.addAll(names);
    tempL = new StringListExtension(tempL).getDuplicateEntries();
    if (!tempL.isEmpty()) {
      return new Status(
          IStatus.ERROR,
          PLUGIN_ID,
          "Names must be unique: " + tempL.toString().replace("[", "").replace("]", ""));
    }

    // check for reserved names CodegenUtils.NO_FLOW_NAME and CodegenUtils.GLOBAL_CLOCK
    if (names.contains(CodegenUtils.NO_FLOW_NAME)
        || portNames.contains(CodegenUtils.NO_FLOW_NAME)) {
      return new Status(
          IStatus.ERROR, PLUGIN_ID, "'" + CodegenUtils.NO_FLOW_NAME + "' is a reserved name. ");
    }
    if (names.contains(CodegenUtils.GLOBAL_CLOCK)
        || portNames.contains(CodegenUtils.GLOBAL_CLOCK)) {
      return new Status(
          IStatus.ERROR, PLUGIN_ID, "'" + CodegenUtils.GLOBAL_CLOCK + "' is a reserved name. ");
    }

    // check that the unfolding depth is at least 1
    try {
      unfoldingDepth = Integer.valueOf(genModel.getProperty(CodegenUtils.PROPERTY_DEPTH));
    } catch (NumberFormatException nfe) {
      return new Status(
          IStatus.ERROR, PLUGIN_ID, "Not a valid unfolding depth: chose an integer > 0");
    }
    if (!(unfoldingDepth > 0)) {
      return new Status(
          IStatus.ERROR, PLUGIN_ID, "Not a valid unfolding depth: chose an integer > 0");
    }

    // check that target language is one of the supported languages, hard code for the moment
    if (!targetlang.equalsIgnoreCase("mathsat") && !targetlang.equalsIgnoreCase("msat")) {
      return new Status(IStatus.ERROR, PLUGIN_ID, "Target language must be one of [mathsat|msat]");
    } else { // to standardise the property contents
      genModel.setProperty("targetlang", mathsat);
    }

    // check that output file name is not empty
    if (genModel.getProperty(CodegenUtils.PROPERTY_FILENAME).isEmpty()) {
      return new Status(IStatus.ERROR, PLUGIN_ID, "Output file name cannot be empty");
    }

    /* If none of the above occurs, the model is ok */
    return Status.OK_STATUS;
  }