Search in sources :

Example 1 with BusinessObjectSelection

use of org.osate.ge.BusinessObjectSelection 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)

Aggregations

Strings (com.google.common.base.Strings)1 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Stream (java.util.stream.Stream)1 EClass (org.eclipse.emf.ecore.EClass)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 Aadl2Package (org.osate.aadl2.Aadl2Package)1 AadlPackage (org.osate.aadl2.AadlPackage)1 AbstractPrototype (org.osate.aadl2.AbstractPrototype)1 BusPrototype (org.osate.aadl2.BusPrototype)1 Classifier (org.osate.aadl2.Classifier)1 ComponentClassifier (org.osate.aadl2.ComponentClassifier)1 ComponentPrototype (org.osate.aadl2.ComponentPrototype)1 DataPrototype (org.osate.aadl2.DataPrototype)1 DevicePrototype (org.osate.aadl2.DevicePrototype)1