use of org.geotoolkit.sml.xml.v101.Classifier in project AGREE by loonwerks.
the class AgreeScopeProvider method getNamedElements.
private Map<String, NamedElement> getNamedElements(EObject ctx) {
Map<String, NamedElement> components = new HashMap<>();
if (ctx instanceof AadlPackage) {
components.put(((AadlPackage) ctx).getName(), (AadlPackage) ctx);
PublicPackageSection pubSec = ((AadlPackage) ctx).getPublicSection();
for (Element el : pubSec.getOwnedElements()) {
if (el instanceof DataImplementation || el instanceof DataType) {
components.put(((NamedElement) el).getName(), (NamedElement) el);
}
}
for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(((AadlPackage) ctx), AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
}
} else {
components.putAll(getNamedElementsFromClassifier((Classifier) ctx, false));
}
return components;
}
use of org.geotoolkit.sml.xml.v101.Classifier in project AGREE by loonwerks.
the class AgreeScopeProvider method getNamedElementsFromClassifier.
private Map<String, NamedElement> getNamedElementsFromClassifier(Classifier ctx, boolean fromCompImpl) {
Map<String, NamedElement> components = new HashMap<>();
components.putAll(getNamedElements(getAadlContainer(ctx)));
for (AnnexSubclause annex : AnnexUtil.getAllAnnexSubclauses(ctx, AgreePackage.eINSTANCE.getAgreeContractSubclause())) {
AgreeContract contract = (AgreeContract) ((AgreeContractSubclause) annex).getContract();
components.putAll(getNamedElementsFromSpecs(contract.getSpecs()));
}
Classifier extended = ctx.getExtended();
if (extended != null) {
components.putAll(getNamedElementsFromClassifier(extended, false));
}
if (ctx instanceof ComponentImplementation) {
components.putAll(getNamedElementsFromClassifier(((ComponentImplementation) ctx).getType(), true));
ArrayList<NamedElement> nes = new ArrayList<>();
nes.addAll(((ComponentImplementation) ctx).getAllSubcomponents());
nes.addAll(((ComponentImplementation) ctx).getAllConnections());
components.putAll(toNamedElementMap(nes));
} else if (ctx instanceof ComponentType) {
if (fromCompImpl) {
ArrayList<NamedElement> nes = new ArrayList<>();
nes.addAll(((ComponentType) ctx).getAllFeatures());
components.putAll(toNamedElementMap(nes));
} else {
ArrayList<NamedElement> nes = new ArrayList<>();
nes.addAll(((ComponentType) ctx).getOwnedFeatures());
components.putAll(toNamedElementMap(nes));
}
}
return components;
}
use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.
the class Aadl2LocationInFile method getSecondaryTextRegion.
public ITextRegion getSecondaryTextRegion(EObject obj, boolean typeName) {
if (obj instanceof ModelUnit || obj instanceof Classifier) {
ICompositeNode node = NodeModelUtils.getNode(obj);
INode endID = node.getLastChild().getPreviousSibling();
List<INode> nodes = null;
while (endID instanceof HiddenLeafNode) {
endID = endID.getPreviousSibling();
}
nodes = Collections.<INode>singletonList(endID);
if (endID instanceof ICompositeNode) {
ICompositeNode fullName = (ICompositeNode) endID;
if (obj instanceof AadlPackage) {
nodes = new ArrayList<INode>();
endID = fullName.getLastChild();
while (endID instanceof HiddenLeafNode) {
endID = endID.getPreviousSibling();
}
INode id = fullName.getFirstChild();
while (id instanceof HiddenLeafNode) {
id = id.getNextSibling();
}
if (id != null) {
nodes.add(id);
while (id != endID) {
id = id.getNextSibling();
nodes.add(id);
}
}
} else if (typeName) {
endID = fullName.getFirstChild();
while (endID instanceof HiddenLeafNode) {
endID = endID.getNextSibling();
}
nodes = Collections.<INode>singletonList(endID);
} else {
endID = fullName.getLastChild();
while (endID instanceof HiddenLeafNode) {
endID = endID.getPreviousSibling();
}
nodes = Collections.<INode>singletonList(endID);
}
}
return createRegion(nodes);
} else {
return null;
}
}
use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.
the class CreateFeaturePaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
return ctx.getTarget().getBusinessObject(EObject.class).map(targetBo -> {
final AadlOperationBuilder<Classifier> opBuilder = AadlOperationBuilder.classifiers().filter(c -> AadlFeatureUtil.canOwnFeatureType(c, featureType));
if (!opBuilder.canBuildOperation(targetBo)) {
return null;
}
return Operation.createWithBuilder(createOp -> {
// Create the feature
opBuilder.buildOperation(createOp, targetBo).modifyPreviousResult(owner -> {
final String newFeatureName = AadlNamingUtil.buildUniqueIdentifier(owner, "new_feature");
final NamedElement newFeature = AadlFeatureUtil.createFeature(owner, featureType);
newFeature.setName(newFeatureName);
// Set in or out based on target docking position
final boolean isRight = ctx.getDockingPosition() == DockingPosition.RIGHT;
if (newFeature instanceof DirectedFeature) {
if (!(newFeature instanceof FeatureGroup)) {
final DirectedFeature newDirectedFeature = (DirectedFeature) newFeature;
newDirectedFeature.setIn(!isRight);
newDirectedFeature.setOut(isRight);
}
} else if (newFeature instanceof Access) {
final Access access = (Access) newFeature;
access.setKind(isRight ? AccessType.PROVIDES : AccessType.REQUIRES);
}
if (owner instanceof ComponentType) {
((ComponentType) owner).setNoFeatures(false);
}
return StepResultBuilder.create().showNewBusinessObject(ctx.getTarget(), newFeature).build();
});
});
});
}
use of org.geotoolkit.sml.xml.v101.Classifier in project osate2 by osate.
the class OpenAssociatedDiagramHandler method setEnabled.
@Override
public void setEnabled(final Object evaluationContext) {
boolean enabled = false;
final List<BusinessObjectContext> selectedBusinessObjectContexts = AgeHandlerUtil.getSelectedBusinessObjectContexts();
if (selectedBusinessObjectContexts.size() == 1) {
final BusinessObjectContext selectedBusinessObjectContext = selectedBusinessObjectContexts.get(0);
final Object bo = selectedBusinessObjectContext.getBusinessObject();
enabled = (bo instanceof AadlPackage || bo instanceof Classifier || (bo instanceof Subcomponent && AadlSubcomponentUtil.getComponentClassifier(selectedBusinessObjectContext, (Subcomponent) bo) != null)) && ProjectUtil.getProjectForBo(bo).isPresent();
}
setBaseEnabled(enabled);
}
Aggregations