Search in sources :

Example 1 with EditablePrototype

use of org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype in project osate2 by osate.

the class PrototypesModel method setRefined.

@Override
public void setRefined(final EditablePrototype prototype, final boolean value) {
    if (value) {
        // Create refinement
        modifySelectedClassifier("Refine Prototype", prototype, c -> {
            final Prototype refinement = (Prototype) c.createOwnedPrototype(prototype.prototype.eClass());
            refinement.setRefined(prototype.prototype);
            if (refinement instanceof FeaturePrototype) {
                final FeaturePrototype fpRefinement = ((FeaturePrototype) refinement);
                final FeaturePrototype fp = (FeaturePrototype) prototype.prototype;
                fpRefinement.setIn(fp.isIn());
                fpRefinement.setOut(fp.isOut());
            }
        });
    } else {
        // Remove refinement
        modifyPrototype("Remove Prototype Refinement", prototype, p -> EcoreUtil.remove(p));
    }
}
Also used : 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)

Example 2 with EditablePrototype

use of org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype 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 3 with EditablePrototype

use of org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype 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 4 with EditablePrototype

use of org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype in project osate2 by osate.

the class PrototypesModel method setPrototypeName.

@Override
public void setPrototypeName(EditablePrototype prototype, String value) {
    renamer.rename(new RenamePrototypeSupplier(prototype.classifierBoc), value, prototype.name);
    // Select will be lost on undo/redo but this will retain selection on the original rename.
    selectedPrototype = new EditablePrototype(prototype.classifierBoc, value, value, prototype.prototype);
}
Also used : EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype)

Example 5 with EditablePrototype

use of org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype 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)

Aggregations

EditablePrototype (org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype)7 ComponentPrototype (org.osate.aadl2.ComponentPrototype)6 AbstractPrototype (org.osate.aadl2.AbstractPrototype)5 BusPrototype (org.osate.aadl2.BusPrototype)5 DataPrototype (org.osate.aadl2.DataPrototype)5 DevicePrototype (org.osate.aadl2.DevicePrototype)5 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)5 FeaturePrototype (org.osate.aadl2.FeaturePrototype)5 MemoryPrototype (org.osate.aadl2.MemoryPrototype)5 ProcessPrototype (org.osate.aadl2.ProcessPrototype)5 ProcessorPrototype (org.osate.aadl2.ProcessorPrototype)5 Prototype (org.osate.aadl2.Prototype)5 SubprogramGroupPrototype (org.osate.aadl2.SubprogramGroupPrototype)5 SubprogramPrototype (org.osate.aadl2.SubprogramPrototype)5 SystemPrototype (org.osate.aadl2.SystemPrototype)5 ThreadGroupPrototype (org.osate.aadl2.ThreadGroupPrototype)5 ThreadPrototype (org.osate.aadl2.ThreadPrototype)5 VirtualBusPrototype (org.osate.aadl2.VirtualBusPrototype)5 VirtualProcessorPrototype (org.osate.aadl2.VirtualProcessorPrototype)5 EClass (org.eclipse.emf.ecore.EClass)3