use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class ClassifierInfoView method createMemberNodeFromFlowImplementation.
public MemberNode createMemberNodeFromFlowImplementation(final ComponentImplementation ci, final FlowImplementation flowImpl) {
final Classifier q = (Classifier) flowImpl.eContainer();
final boolean isLocal = q.equals(ci);
final FlowSpecification flowSpec = flowImpl.getSpecification();
return new MemberNode(flowImpl, isLocal ? null : q, false, flowSpec.eIsProxy() ? null : createMemberNode(ci, flowSpec, ClassifierInfoView::getRefinedFlowSpec));
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class PropertiesValidator method getMasterModes.
public List<Mode> getMasterModes(ContainedNamedElement cne) {
List<Mode> masterModes = new ArrayList<Mode>();
ComponentClassifier componentClassifier = null;
Subcomponent lastSubcomponent = getLastSubcomponent(cne);
if (null == lastSubcomponent) {
Classifier classifier = cne.getContainingClassifier();
if (classifier instanceof ComponentClassifier) {
componentClassifier = (ComponentClassifier) classifier;
}
} else {
componentClassifier = lastSubcomponent.getAllClassifier();
if (null != componentClassifier) {
masterModes = componentClassifier.getAllModes();
}
}
if (null != componentClassifier) {
masterModes = componentClassifier.getAllModes();
}
return masterModes;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class AutoUnindentEditStrategy method internalCustomizeDocumentCommand.
@Override
protected void internalCustomizeDocumentCommand(IDocument document, DocumentCommand command) throws BadLocationException {
if (!isAutoComplete() || !isLineDelimiter(document, command)) {
return;
}
String publicWord = isUseCapitalization() ? "PUBLIC" + System.lineSeparator() + "\t" : "public";
String endWord = isUseCapitalization() ? "END" : "end";
int lineNr = document.getLineOfOffset(command.offset);
int firstOffsetOfLine = document.getLineOffset(lineNr);
int lineLength = document.getLineLength(lineNr);
String lineText = document.get(firstOffsetOfLine, lineLength);
String[] tokens = lineText.trim().split("\\s+");
if (tokens.length < 2) {
return;
}
String keyword = findKeyWord(tokens);
boolean hasExtends = false;
for (int i = 0; i < tokens.length; i++) {
if (tokens[i].equalsIgnoreCase("extends")) {
hasExtends = true;
}
}
NamedElement namedElement = null;
if (keyword.equals("")) {
namedElement = null;
if (document instanceof IXtextDocument) {
IXtextDocument xDoc = (IXtextDocument) document;
namedElement = xDoc.readOnly(resource -> {
EObjectAtOffsetHelper helper = new EObjectAtOffsetHelper();
EObject eobj = helper.resolveElementAt(resource, command.offset);
if (eobj == null) {
return null;
} else if (eobj instanceof Classifier || eobj instanceof AadlPackage) {
return (NamedElement) eobj;
}
return null;
});
}
}
String elementId = findElementId(tokens, keyword);
if (namedElement == null && keyword.equals("") && !hasExtends) {
return;
} else if (checkForExistingEnd(endWord, hasExtends, document.get(), elementId, namedElement, keyword, tokens, firstOffsetOfLine)) {
return;
}
if (ComponentCategory.getByName(elementId.toLowerCase()) != null) {
return;
}
if (keyword == null || keyword.equals("") || elementId == null || elementId.equals("")) {
return;
}
int firstTokenIndex = lineText.indexOf(tokens[0]);
String leadingString = lineText.substring(0, firstTokenIndex);
String indent = "";
String targetString = "";
if (keyword.equalsIgnoreCase("package")) {
if (lineText.endsWith(System.lineSeparator())) {
lineText = lineText.substring(0, lineText.indexOf(System.lineSeparator()));
}
} else if (keyword.equalsIgnoreCase("property set")) {
if (lineText.endsWith(System.lineSeparator())) {
lineText = lineText.substring(0, lineText.indexOf(System.lineSeparator()));
}
if (isAutoIndent()) {
indent = "\t";
}
}
targetString = buildTargetString(lineText, leadingString, endWord, elementId, keyword, publicWord, indent);
if (keyword.equalsIgnoreCase("package")) {
if (isUseCapitalization()) {
command.text = "";
}
command.offset = command.offset + (System.lineSeparator() + leadingString + publicWord).length();
} else if (keyword.equalsIgnoreCase("property set")) {
command.offset = command.offset + (System.lineSeparator() + leadingString + indent).length();
command.text = "";
}
document.replace(firstOffsetOfLine, lineText.length(), targetString);
}
use of org.geotoolkit.sml.xml.v100.Classifier 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();
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class PrototypesModel method setConstrainingClassifier.
@Override
public void setConstrainingClassifier(final EditablePrototype prototype, final NamedElementOrDescription value) {
modifyPrototype("Set Constraining Classifier", prototype, p -> {
final EObject classifier = value.getResolvedValue(prototype.prototype.eResource().getResourceSet());
if (classifier != null) {
// Import its package if necessary
final AadlPackage pkg = (AadlPackage) p.getElementRoot();
if (classifier instanceof Classifier && ((Classifier) classifier).getNamespace() != null && pkg != null) {
final PackageSection section = pkg.getPublicSection();
final AadlPackage selectedClassifierPkg = (AadlPackage) ((Classifier) classifier).getNamespace().getOwner();
if (selectedClassifierPkg != null && pkg != selectedClassifierPkg) {
AadlImportsUtil.addImportIfNeeded(section, selectedClassifierPkg);
}
}
}
// Update the classifier
if (p instanceof ComponentPrototype) {
((ComponentPrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
} else if (p instanceof FeatureGroupPrototype) {
((FeatureGroupPrototype) p).setConstrainingFeatureGroupType((FeatureGroupType) classifier);
} else if (p instanceof FeaturePrototype) {
((FeaturePrototype) p).setConstrainingClassifier((ComponentClassifier) classifier);
}
});
}
Aggregations