Search in sources :

Example 16 with ComponentPrototype

use of org.osate.aadl2.ComponentPrototype in project osate2 by osate.

the class PrototypesModel method addPrototype.

@Override
public void addPrototype() {
    bos.modify("Add Prototype", boc -> boc.getBusinessObject() instanceof Classifier, boc -> (Classifier) boc.getBusinessObject(), (c, boc) -> {
        // Create a new prototype
        final ComponentPrototype cp = (ComponentPrototype) c.createOwnedPrototype(Aadl2Package.eINSTANCE.getDataPrototype());
        // Assign a name
        final String newName = AadlNamingUtil.buildUniqueIdentifier(c, "new_prototype");
        cp.setName(newName);
        // Update the selected prototype
        selectedPrototype = new EditablePrototype(boc, newName, newName, cp);
    });
}
Also used : EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 17 with ComponentPrototype

use of org.osate.aadl2.ComponentPrototype in project osate2 by osate.

the class PrototypesModel method getConstrainingClassifier.

@Override
public NamedElementOrDescription getConstrainingClassifier(final EditablePrototype prototype) {
    final Prototype p = prototype.prototype;
    final NamedElement namedElement;
    if (p instanceof ComponentPrototype) {
        namedElement = ((ComponentPrototype) p).getConstrainingClassifier();
    } else if (p instanceof FeatureGroupPrototype) {
        namedElement = ((FeatureGroupPrototype) p).getConstrainingFeatureGroupType();
    } else if (p instanceof FeaturePrototype) {
        namedElement = ((FeaturePrototype) p).getConstrainingClassifier();
    } else {
        namedElement = null;
    }
    return namedElement == null ? null : new NamedElementOrDescription(namedElement);
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) 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) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) NamedElement(org.osate.aadl2.NamedElement) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 18 with ComponentPrototype

use of org.osate.aadl2.ComponentPrototype in project osate2 by osate.

the class PrototypesModel method getConstrainingClassifierOptions.

@Override
public Stream<NamedElementOrDescription> getConstrainingClassifierOptions(final EditablePrototype prototype) {
    if (prototype.prototype.eResource() == null) {
        return Stream.empty();
    }
    // Check the type of the prototype and get the EClass of the constraining classifier / constraining feature group type
    final Prototype p = prototype.prototype;
    final EClass filterEClass;
    if (p instanceof ComponentPrototype || p instanceof FeaturePrototype) {
        filterEClass = Aadl2Package.eINSTANCE.getComponentClassifier();
    } else if (p instanceof FeatureGroupPrototype) {
        filterEClass = Aadl2Package.eINSTANCE.getFeatureGroupType();
    } else {
        filterEClass = null;
    }
    // null is always a valid option
    Stream<NamedElementOrDescription> options = Stream.of((NamedElementOrDescription) null);
    // Concatenate all classifiers that match the supported EClass
    if (filterEClass != null) {
        options = Stream.concat(options, AadlModelAccessUtil.getAllEObjectsByType(prototype.prototype.eResource(), filterEClass).stream().map(NamedElementOrDescription::new));
    }
    return options;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) 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) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 19 with ComponentPrototype

use of org.osate.aadl2.ComponentPrototype in project osate2 by osate.

the class PrototypesModel method setPrototypeType.

@Override
public void setPrototypeType(final EditablePrototype prototype, final PrototypeType value) {
    // Check if the type is different by comparing EClass values
    final EClass currentEClass = prototype.prototype.eClass();
    final EClass newEClass = prototypeTypeToEClass(value);
    if (newEClass == currentEClass) {
        return;
    }
    modifyOwningClassifier("Set Prototype Type", prototype, c -> {
        getPrototypeByName(c, prototype.name).ifPresent(p -> {
            // Store location in list
            final int index = c.getOwnedPrototypes().indexOf(p);
            if (index == -1) {
                throw new RuntimeException("Unable to get index of prototype being modified");
            }
            // Store fields
            final String name = p.getName();
            final Prototype refined = p.getRefined();
            ComponentClassifier cc = null;
            FeatureGroupType fgt = null;
            boolean in = false;
            boolean out = false;
            boolean array = false;
            if (p instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) p;
                cc = cp.getConstrainingClassifier();
                array = cp.isArray();
            } else if (p instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) p;
                fgt = fp.getConstrainingFeatureGroupType();
            } else if (p instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) p;
                cc = fp.getConstrainingClassifier();
                in = fp.isIn();
                out = fp.isOut();
            }
            // Create new prototype
            final Prototype newPrototype = (Prototype) EcoreUtil.create(newEClass);
            c.getOwnedPrototypes().add(index, newPrototype);
            if (refined == null) {
                newPrototype.setName(name);
            } else {
                newPrototype.setRefined(refined);
            }
            // Set fields
            if (newPrototype instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) newPrototype;
                cp.setConstrainingClassifier(cc);
                cp.setArray(array);
            } else if (newPrototype instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) newPrototype;
                fp.setConstrainingFeatureGroupType(fgt);
            } else if (newPrototype instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) newPrototype;
                fp.setConstrainingClassifier(cc);
                fp.setIn(in);
                fp.setOut(out);
            }
            // Move property associations
            newPrototype.getOwnedPropertyAssociations().addAll(p.getOwnedPropertyAssociations());
            // Remove old prototype
            EcoreUtil.remove(p);
        });
    });
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EClass(org.eclipse.emf.ecore.EClass) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) 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) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 20 with ComponentPrototype

use of org.osate.aadl2.ComponentPrototype in project osate2 by osate.

the class FeatureReferenceBindingType method getClassifierOptions.

@Override
public final Stream<NamedElementOrDescription> getClassifierOptions(final PrototypeBindingsModelNode node) {
    if (node == null) {
        return getClassifierOptionsForRoot();
    }
    final Object bo = data(node).bo;
    if (bo == null) {
        return Stream.empty();
    }
    final PrototypeBindingType type = getType(node);
    // Determine which EClasses and prototypes to show
    Stream<EClass> filterEClasses;
    Class<?> prototypeFilter;
    boolean includeNull = true;
    if (bo instanceof ComponentPrototype) {
        final ComponentCategory category = ((ComponentPrototype) bo).getCategory();
        filterEClasses = componentCategoryToPrototypeFilterTypeEClasses(category);
        prototypeFilter = ComponentPrototype.class;
    } else if (bo instanceof FeatureGroupPrototype) {
        filterEClasses = Stream.of(Aadl2Package.eINSTANCE.getFeatureGroupType());
        prototypeFilter = FeatureGroupPrototype.class;
    } else if (bo instanceof FeaturePrototype && type instanceof AccessSpecificationBindingType || type instanceof PortSpecificationBindingType) {
        filterEClasses = Stream.of(Aadl2Package.eINSTANCE.getComponentClassifier());
        prototypeFilter = null;
    } else if (bo instanceof FeaturePrototype && type instanceof FeatureReferenceBindingType) {
        filterEClasses = Stream.empty();
        prototypeFilter = FeaturePrototype.class;
        includeNull = false;
    } else {
        filterEClasses = Stream.empty();
        prototypeFilter = null;
        includeNull = false;
    }
    Stream<NamedElementOrDescription> options = includeNull ? Stream.of((NamedElementOrDescription) null) : Stream.empty();
    // Concatenate all classifiers that match the supported EClass
    options = Stream.concat(options, filterEClasses.flatMap(eclass -> AadlModelAccessUtil.getAllEObjectsByType(project, eclass).stream().map(NamedElementOrDescription::new)));
    // Show appropriate prototypes
    if (prototypeFilter != null) {
        options = Stream.concat(options, getReferenceablePrototypes().filter(prototypeFilter::isInstance).map(NamedElementOrDescription::new));
    }
    return options;
}
Also used : ComponentCategory(org.osate.aadl2.ComponentCategory) ComponentPrototype(org.osate.aadl2.ComponentPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FeaturePrototype(org.osate.aadl2.FeaturePrototype) EObject(org.eclipse.emf.ecore.EObject)

Aggregations

ComponentPrototype (org.osate.aadl2.ComponentPrototype)21 ComponentClassifier (org.osate.aadl2.ComponentClassifier)14 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)13 Classifier (org.osate.aadl2.Classifier)10 FeaturePrototype (org.osate.aadl2.FeaturePrototype)9 ComponentPrototypeBinding (org.osate.aadl2.ComponentPrototypeBinding)8 Prototype (org.osate.aadl2.Prototype)7 EObject (org.eclipse.emf.ecore.EObject)6 ComponentPrototypeActual (org.osate.aadl2.ComponentPrototypeActual)6 DataPrototype (org.osate.aadl2.DataPrototype)6 FeatureGroupType (org.osate.aadl2.FeatureGroupType)6 NamedElement (org.osate.aadl2.NamedElement)6 Subcomponent (org.osate.aadl2.Subcomponent)6 EClass (org.eclipse.emf.ecore.EClass)5 FeatureGroup (org.osate.aadl2.FeatureGroup)5 FeatureGroupPrototypeBinding (org.osate.aadl2.FeatureGroupPrototypeBinding)5 Feature (org.osate.aadl2.Feature)4 SubprogramPrototype (org.osate.aadl2.SubprogramPrototype)4 EditablePrototype (org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype)4 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)3