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