use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class FeatureInstanceTooltipContributor method addTooltipContents.
@Override
public void addTooltipContents(final TooltipContributorContext ctx) {
ctx.getBusinessObjectContext().getBusinessObject(FeatureInstance.class).ifPresent(featureInstance -> {
final Feature feature = featureInstance.getFeature();
if (feature instanceof Feature || feature instanceof InternalFeature || feature instanceof ProcessorFeature) {
// Determine the feature classifier
final Classifier featureClassifier;
if (feature instanceof EventDataSource) {
final EventDataSource aadlFeature = (EventDataSource) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof PortProxy) {
final PortProxy aadlFeature = (PortProxy) feature;
featureClassifier = aadlFeature.getDataClassifier();
} else if (feature instanceof SubprogramProxy) {
final SubprogramProxy aadlFeature = (SubprogramProxy) feature;
featureClassifier = aadlFeature.getSubprogramClassifier();
} else if (feature instanceof Feature) {
final Feature aadlFeature = (Feature) feature;
featureClassifier = aadlFeature.getAllClassifier();
} else {
featureClassifier = null;
}
// Build the text to contribute to the tooltip
final StringBuffer tooltipContents = new StringBuffer();
if (featureClassifier instanceof ComponentClassifier) {
tooltipContents.append(((ComponentClassifier) featureClassifier).getCategory() + " " + featureClassifier.getQualifiedName());
} else if (featureClassifier instanceof FeatureGroupType) {
tooltipContents.append("feature group " + featureClassifier.getQualifiedName());
} else if (featureClassifier == null) {
tooltipContents.append("No Classifier");
} else {
tooltipContents.append(featureClassifier.getQualifiedName());
}
// Create the styled text describing the feature
final Label lbl = new Label(ctx.getTooltip(), SWT.NONE);
lbl.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
lbl.setText(tooltipContents.toString());
}
});
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class SetExtendedClassifierPropertySection method getExtendedClassifierLabel.
private static String getExtendedClassifierLabel(final List<Classifier> elements) {
final Iterator<Classifier> it = elements.iterator();
final Classifier extClassifier = getExtended(it.next());
while (it.hasNext()) {
if (extClassifier != getExtended(it.next())) {
return "<Multiple>";
}
}
return getClassifierName(extClassifier);
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class FeatureReferenceBindingType method setNodeDataClassifier.
/**
* Sets the classifier field of the node data and creates children.
* @param node the node for which to set the classifier and create children.
* @param classifierValue the new value for the classifier field
*/
private final void setNodeDataClassifier(final PrototypeBindingsModelNode node, final NamedElementOrDescription classifierValue) {
data(node).classifier = classifierValue;
data(node).children.clear();
if (classifierValue != null) {
// Only support children for business objects which support bindings
final Object bo = data(node).bo;
if (bo instanceof Classifier || bo instanceof Subcomponent || bo instanceof ComponentPrototype || bo instanceof FeatureGroupPrototype) {
// We need to get an actual EObject to determine children.
final EObject eobj = classifierValue.getResolvedValue(resourceSet);
final EObject prototypeSource = bo instanceof Classifier ? getExtendedOrImplemented(eobj) : eobj;
// Get all the prototypes for the business object and create a child node for each of them
AadlPrototypeUtil.getAllPrototypes(prototypeSource).forEachOrdered(c -> {
final PrototypeBindingsModelNode newChild = new PrototypeBindingsModelNode(node, c);
data(node).children.add(newChild);
data(newChild).bo = c;
});
}
}
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class FeatureReferenceBindingType method getExtendedOrImplemented.
/**
* Gets the extended classifier or the implemented type.
* @param bo the classifier for which to get the extended classifier or implemented type.
* @return the extended classifier or implemented type. Null of neither of those exists or if the business object is not a classifier.
*/
private static Classifier getExtendedOrImplemented(final EObject bo) {
if (!(bo instanceof Classifier)) {
return null;
}
final Classifier classifier = (Classifier) bo;
Classifier result = classifier.getExtended();
if (result == null && bo instanceof ComponentImplementation) {
result = ((ComponentImplementation) bo).getType();
}
return result;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class ClassifierPrototypeBindingsModel method loadData.
@Override
protected void loadData() {
final List<Classifier> classifiers = getBusinessObjectSelection().boStream(Classifier.class).collect(Collectors.toList());
// Don't support displaying or editing bindings when multiple classifiers are selected
if (classifiers.size() != 1) {
setMultipleValues(true);
return;
}
final Classifier classifier = classifiers.get(0);
// Don't populate data if classifier is null.
if (classifier == null) {
return;
}
PrototypeBindingsModelNode parent = null;
data(parent).bo = classifier;
setNodeDataClassifier(parent, classifier);
loadBindingData(parent, classifier.getOwnedPrototypeBindings());
}
Aggregations