Exemplo n.º 1
0
  private ArrayList<Predicate> parseGlobalPredicates(MID mid, PrTPanel prtNet)
      throws ParseException {
    String GLOBAL_KEYWORD = "GLOBAL";
    ArrayList<Predicate> globalPredicates = new ArrayList<Predicate>();
    DataLayerInterface net = prtNet.getModel();
    AnnotationNote[] annotationNotes = net.getLabels();
    for (AnnotationNote annotation : annotationNotes) {
      String text = annotation.getText();
      if (text.startsWith(GLOBAL_KEYWORD)) {
        String globalPredicateString = text.substring(GLOBAL_KEYWORD.length()).trim();
        try { // abuse transition declaration for global predicate - same syntax
          Predicate signaturePredicate =
              MIDParser.parseTransitionSignatureString(globalPredicateString);
          globalPredicates.add(signaturePredicate);
          mid.addPlace(signaturePredicate.getName());

        } catch (ParseException e) {
          throw new ParseException(
              modelNameMessage(prtNet)
                  + text
                  + ": "
                  + LocaleBundle.bundleString("Incorrect GLOBAL annotation"));
        }
      }
    }
    return globalPredicates;
  }
Exemplo n.º 2
0
 private void parseMarkingAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.INIT_KEYWORD)) parseMainModelAnnotationMarking(mid, text);
   }
   if (editor.getKernel().getSystemOptions().isNetHierarchyEnabled())
     parseSubModelMarkingAnnotations(mid);
 }
Exemplo n.º 3
0
 private int numberOfNumerationAnnotations(PrTPanel prtNet) {
   int numberOfEnumerations = 0;
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.ENUM_KEYWORD)) numberOfEnumerations++;
   }
   return numberOfEnumerations;
 }
Exemplo n.º 4
0
 private void parseConstantsAnnotations(PrTPanel prtNet) throws ParseException {
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.CONSTANTS_KEYWORD))
       parseConstants(text, XMIDProcessor.CONSTANTS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.ENUM_KEYWORD))
       parseEnumeration(text, XMIDProcessor.ENUM_KEYWORD);
   }
 }
Exemplo n.º 5
0
 protected ArrayList<Marking> parseSubModelMarkingAnnotations(
     PrTPanel subPrtPanel, String markingKeyword) throws ParseException {
   ArrayList<Marking> markings = new ArrayList<Marking>();
   DataLayerInterface net = subPrtPanel.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(markingKeyword)) {
       Marking marking = parseSubModelAnnotationMarking(text, markingKeyword);
       if (marking != null) markings.add(marking);
     }
   }
   return markings;
 }
Exemplo n.º 6
0
 private void parseAssertionPropertyAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.ASSERTION_KEYWORD)) {
       String assertionString = text.substring(XMIDProcessor.ASSERTION_KEYWORD.length());
       if (!assertionString.trim().equals("")) {
         try {
           AssertionProperty assertion = MIDParser.parseAssertionPropertyString(assertionString);
           mid.addAssertionProperty(assertion);
         } catch (ParseException e) {
           throw new ParseException(text + ". " + e.toString());
         }
       }
     }
   }
 }
Exemplo n.º 7
0
 private void parseOtherAnnotations(MID mid, PrTPanel prtNet) throws ParseException {
   DataLayerInterface net = prtNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.UNITTESTS_KEYWORD))
       parseUnitTests(mid, text, XMIDProcessor.UNITTESTS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SINKS_KEYWORD))
       parseSinkEvents(mid, text, XMIDProcessor.SINKS_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SINK_KEYWORD))
       parseSinkEvents(mid, text, XMIDProcessor.SINK_KEYWORD);
     else if (text.startsWith(XMIDProcessor.NONNEGATIVE_KEYWORD))
       parseNonNegativeEvents(mid, text, XMIDProcessor.NONNEGATIVE_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SEQUENCESFILE_KEYWORD))
       parseSequencesFile(mid, text, XMIDProcessor.SEQUENCESFILE_KEYWORD);
     else if (text.startsWith(XMIDProcessor.SEQUENCES_KEYWORD))
       parseSequencesFile(mid, text, XMIDProcessor.SEQUENCES_KEYWORD);
   }
 }
Exemplo n.º 8
0
 private void parseDataAnnotations(MID mid) throws ParseException {
   DataLayerInterface net = mainNet.getModel();
   AnnotationNote[] annotationNotes = net.getLabels();
   for (AnnotationNote annotation : annotationNotes) {
     String text = annotation.getText();
     if (text.startsWith(XMIDProcessor.DATA_KEYWORD)) {
       String dataPath = text.substring(XMIDProcessor.DATA_KEYWORD.length()).trim();
       try {
         ExcelTestDataLoader excelTestDataLoader =
             new ExcelTestDataLoader(
                 editor.midFile.getParent() + File.separator + dataPath, mid.getPlaces());
         for (Marking initMarking : excelTestDataLoader.getInitMarkings()) {
           mid.addInitialMarking(initMarking);
         }
       } catch (Exception e) {
         throw new ParseException(text + " -> " + e.getMessage());
       }
     }
   }
 }