Search in sources :

Example 31 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class ClassifierInfoView method createMemberNodeFromFlowImplementation.

public MemberNode createMemberNodeFromFlowImplementation(final ComponentImplementation ci, final FlowImplementation flowImpl) {
    final Classifier q = (Classifier) flowImpl.eContainer();
    final boolean isLocal = q.equals(ci);
    final FlowSpecification flowSpec = flowImpl.getSpecification();
    return new MemberNode(flowImpl, isLocal ? null : q, false, flowSpec.eIsProxy() ? null : createMemberNode(ci, flowSpec, ClassifierInfoView::getRefinedFlowSpec));
}
Also used : FlowSpecification(org.osate.aadl2.FlowSpecification) Classifier(org.osate.aadl2.Classifier)

Example 32 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PropertiesValidator method getMasterModes.

public List<Mode> getMasterModes(ContainedNamedElement cne) {
    List<Mode> masterModes = new ArrayList<Mode>();
    ComponentClassifier componentClassifier = null;
    Subcomponent lastSubcomponent = getLastSubcomponent(cne);
    if (null == lastSubcomponent) {
        Classifier classifier = cne.getContainingClassifier();
        if (classifier instanceof ComponentClassifier) {
            componentClassifier = (ComponentClassifier) classifier;
        }
    } else {
        componentClassifier = lastSubcomponent.getAllClassifier();
        if (null != componentClassifier) {
            masterModes = componentClassifier.getAllModes();
        }
    }
    if (null != componentClassifier) {
        masterModes = componentClassifier.getAllModes();
    }
    return masterModes;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) Mode(org.osate.aadl2.Mode) Subcomponent(org.osate.aadl2.Subcomponent) ArrayList(java.util.ArrayList) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier)

Example 33 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class AutoUnindentEditStrategy method internalCustomizeDocumentCommand.

@Override
protected void internalCustomizeDocumentCommand(IDocument document, DocumentCommand command) throws BadLocationException {
    if (!isAutoComplete() || !isLineDelimiter(document, command)) {
        return;
    }
    String publicWord = isUseCapitalization() ? "PUBLIC" + System.lineSeparator() + "\t" : "public";
    String endWord = isUseCapitalization() ? "END" : "end";
    int lineNr = document.getLineOfOffset(command.offset);
    int firstOffsetOfLine = document.getLineOffset(lineNr);
    int lineLength = document.getLineLength(lineNr);
    String lineText = document.get(firstOffsetOfLine, lineLength);
    String[] tokens = lineText.trim().split("\\s+");
    if (tokens.length < 2) {
        return;
    }
    String keyword = findKeyWord(tokens);
    boolean hasExtends = false;
    for (int i = 0; i < tokens.length; i++) {
        if (tokens[i].equalsIgnoreCase("extends")) {
            hasExtends = true;
        }
    }
    NamedElement namedElement = null;
    if (keyword.equals("")) {
        namedElement = null;
        if (document instanceof IXtextDocument) {
            IXtextDocument xDoc = (IXtextDocument) document;
            namedElement = xDoc.readOnly(resource -> {
                EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();
                EObject eobj = helper.resolveElementAt(resource, command.offset);
                if (eobj == null) {
                    return null;
                } else if (eobj instanceof Classifier || eobj instanceof AadlPackage) {
                    return (NamedElement) eobj;
                }
                return null;
            });
        }
    }
    String elementId = findElementId(tokens, keyword);
    if (namedElement == null && keyword.equals("") && !hasExtends) {
        return;
    } else if (checkForExistingEnd(endWord, hasExtends, document.get(), elementId, namedElement, keyword, tokens, firstOffsetOfLine)) {
        return;
    }
    if (ComponentCategory.getByName(elementId.toLowerCase()) != null) {
        return;
    }
    if (keyword == null || keyword.equals("") || elementId == null || elementId.equals("")) {
        return;
    }
    int firstTokenIndex = lineText.indexOf(tokens[0]);
    String leadingString = lineText.substring(0, firstTokenIndex);
    String indent = "";
    String targetString = "";
    if (keyword.equalsIgnoreCase("package")) {
        if (lineText.endsWith(System.lineSeparator())) {
            lineText = lineText.substring(0, lineText.indexOf(System.lineSeparator()));
        }
    } else if (keyword.equalsIgnoreCase("property set")) {
        if (lineText.endsWith(System.lineSeparator())) {
            lineText = lineText.substring(0, lineText.indexOf(System.lineSeparator()));
        }
        if (isAutoIndent()) {
            indent = "\t";
        }
    }
    targetString = buildTargetString(lineText, leadingString, endWord, elementId, keyword, publicWord, indent);
    if (keyword.equalsIgnoreCase("package")) {
        if (isUseCapitalization()) {
            command.text = "";
        }
        command.offset = command.offset + (System.lineSeparator() + leadingString + publicWord).length();
    } else if (keyword.equalsIgnoreCase("property set")) {
        command.offset = command.offset + (System.lineSeparator() + leadingString + indent).length();
        command.text = "";
    }
    document.replace(firstOffsetOfLine, lineText.length(), targetString);
}
Also used : DocumentCommand(org.eclipse.jface.text.DocumentCommand) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Inject(com.google.inject.Inject) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) EObjectAtOffsetHelper(org.eclipse.xtext.resource.EObjectAtOffsetHelper) Logger(org.apache.log4j.Logger) IDocument(org.eclipse.jface.text.IDocument) AbstractTerminalsEditStrategy(org.eclipse.xtext.ui.editor.autoedit.AbstractTerminalsEditStrategy) Classifier(org.osate.aadl2.Classifier) ComponentCategory(org.osate.aadl2.ComponentCategory) BadLocationException(org.eclipse.jface.text.BadLocationException) IIndentationInformation(org.eclipse.xtext.formatting.IIndentationInformation) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) TextUtilities(org.eclipse.jface.text.TextUtilities) NamedElement(org.osate.aadl2.NamedElement) MembersInjector(com.google.inject.MembersInjector) OsateCorePlugin(org.osate.core.OsateCorePlugin) AadlPackage(org.osate.aadl2.AadlPackage) EObjectAtOffsetHelper(org.eclipse.xtext.resource.EObjectAtOffsetHelper) EObject(org.eclipse.emf.ecore.EObject) Classifier(org.osate.aadl2.Classifier) NamedElement(org.osate.aadl2.NamedElement) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument)

Example 34 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PrototypesModel method setBusinessObjectSelection.

/**
 * Refreshes the internal state of the model based on the specified business object selection
 */
public void setBusinessObjectSelection(final BusinessObjectSelection value) {
    this.bos = Objects.requireNonNull(value, "value must not be null");
    final boolean singleSelection = this.bos.boStream(Classifier.class).limit(2).count() == 1;
    // Build set of all editable prototypes..
    prototypes = new ArrayList<>();
    value.bocStream().filter(boc -> boc.getBusinessObject() instanceof Classifier).forEachOrdered(boc -> {
        final Classifier c = (Classifier) boc.getBusinessObject();
        final String suffix = singleSelection ? "" : " [" + c.getQualifiedName() + "]";
        AadlPrototypeUtil.getAllPrototypes(boc.getBusinessObject()).forEach(p -> {
            final String name = p.getName();
            if (!Strings.isNullOrEmpty(name)) {
                prototypes.add(new EditablePrototype(boc, name + suffix, name, p));
            }
        });
    });
    // If a prototype was previously selected, update the selection based on the previously selected prototype's same classifier BOC and name.
    if (this.selectedPrototype != null) {
        selectedPrototype = prototypes.stream().filter(p -> {
            return p.classifierBoc == selectedPrototype.classifierBoc && p.name.equalsIgnoreCase(this.selectedPrototype.name);
        }).findAny().orElse(null);
    }
    triggerChangeEvent();
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) PrototypeType(org.osate.ge.swt.prototypes.PrototypeType) AadlPrototypeUtil(org.osate.ge.aadl2.internal.util.AadlPrototypeUtil) BaseObservableModel(org.osate.ge.swt.BaseObservableModel) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) ArrayList(java.util.ArrayList) ComponentClassifier(org.osate.aadl2.ComponentClassifier) BusinessObjectSelection(org.osate.ge.BusinessObjectSelection) Strings(com.google.common.base.Strings) BusinessObjectContext(org.osate.ge.BusinessObjectContext) EClass(org.eclipse.emf.ecore.EClass) Classifier(org.osate.aadl2.Classifier) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) WeakReference(java.lang.ref.WeakReference) Aadl2Package(org.osate.aadl2.Aadl2Package) MemoryPrototype(org.osate.aadl2.MemoryPrototype) Prototype(org.osate.aadl2.Prototype) ThreadPrototype(org.osate.aadl2.ThreadPrototype) VirtualProcessorPrototype(org.osate.aadl2.VirtualProcessorPrototype) SystemPrototype(org.osate.aadl2.SystemPrototype) VirtualBusPrototype(org.osate.aadl2.VirtualBusPrototype) ProcessPrototype(org.osate.aadl2.ProcessPrototype) ThreadGroupPrototype(org.osate.aadl2.ThreadGroupPrototype) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) AadlImportsUtil(org.osate.ge.aadl2.AadlImportsUtil) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) PrototypeDirection(org.osate.ge.swt.prototypes.PrototypeDirection) Objects(java.util.Objects) Consumer(java.util.function.Consumer) FeatureGroupType(org.osate.aadl2.FeatureGroupType) List(java.util.List) Stream(java.util.stream.Stream) PrototypesEditorModel(org.osate.ge.swt.prototypes.PrototypesEditorModel) AadlModelAccessUtil(org.osate.ge.aadl2.ui.AadlModelAccessUtil) Optional(java.util.Optional) AadlNamingUtil(org.osate.ge.aadl2.internal.AadlNamingUtil) NamedElement(org.osate.aadl2.NamedElement) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier)

Example 35 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PrototypesModel method setConstrainingClassifier.

@Override
public void setConstrainingClassifier(final EditablePrototype prototype, final NamedElementOrDescription value) {
    modifyPrototype("Set Constraining Classifier", prototype, p -> {
        final EObject classifier = value.getResolvedValue(prototype.prototype.eResource().getResourceSet());
        if (classifier != null) {
            // Import its package if necessary
            final AadlPackage pkg = (AadlPackage) p.getElementRoot();
            if (classifier instanceof Classifier && ((Classifier) classifier).getNamespace() != null && pkg != null) {
                final PackageSection section = pkg.getPublicSection();
                final AadlPackage selectedClassifierPkg = (AadlPackage) ((Classifier) classifier).getNamespace().getOwner();
                if (selectedClassifierPkg != null && pkg != selectedClassifierPkg) {
                    AadlImportsUtil.addImportIfNeeded(section, selectedClassifierPkg);
                }
            }
        }
        // Update the classifier
        if (p instanceof ComponentPrototype) {
            ((ComponentPrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
        } else if (p instanceof FeatureGroupPrototype) {
            ((FeatureGroupPrototype) p).setConstrainingFeatureGroupType((FeatureGroupType) classifier);
        } else if (p instanceof FeaturePrototype) {
            ((FeaturePrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
        }
    });
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) AadlPackage(org.osate.aadl2.AadlPackage) FeaturePrototype(org.osate.aadl2.FeaturePrototype) PackageSection(org.osate.aadl2.PackageSection) EObject(org.eclipse.emf.ecore.EObject) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Aggregations

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14