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; }
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); }
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; }
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); } }
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; }
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()); } } } } }
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); } }
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()); } } } }