-
Notifications
You must be signed in to change notification settings - Fork 103
Edit
When we open an aird (doucle click on it),
A Session
is created containing a TransactionalEditingDomain
which contains a ResourceSet
containing all Resource(s)
loaded, containing all EObjects. It is editable through a ExecutionManager
.
-
EObject
is the EMF element (Function, Component, graphical element, etc) -
Resource
is the EMF representation of the XML files (aird, melodymodeller) containing all EObject -
ResourceSet
is the list of all Resources loaded (melodymodeller, aird, odesign, etc) -
TransactionalEditingDomain
allows to access element/model/diagrams in a Thread-safe environnement. All modifications in Capella are done within it. -
ExecutionManager
is the API main access to be able to edit an element. -
Session
is the API main access to Diagrams
org.eclipse.sirius.business.api.query
org.eclipse.sirius.diagram.business.api.query
Session session = SessionManager.INSTANCE.getSession(EObject object);
Session session = SessionManager.INSTANCE.getExistingSession(EcoreUtil2.getURI(airdFile));
TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
TransactionalEditingDomain domain = TransactionHelper.getEditingDomain(element)
TransactionalEditingDomain domain = TransactionHelper.getEditingDomain(resource)
Collection<EObject> subComponents = EObjectExt.getAll(element, CsPackage.Literals.COMPONENT)
ExecutionManager manager = TransactionHelper.getExecutionManager(element)
ExecutionManager manager = TransactionHelper.getExecutionManager(resource)
Create a new TransactionalEditingDomain for Capella models:
ExecutionManager manager = ExecutionManagerRegistry.getInstance().addNewManager();
TransactionalEditingDomain domain = manager.getEditingDomain();
EcoreUtil2.getFile(Resource)
EcoreUtil2.getURI(file)
element.eResource()
ResourcesPlugin.getWorkspace().getRoot().getProject("project").getFile("toto.melodymodeller");
Many helpers exist in Capella, they are mainly located inside following plugins and have *Ext name
org.polarsys.capella.core.data.helpers
org.polarsys.capella.core.model.helpers
CapellaElementExt.creationService(x)
Helps to create additional elements like if it was created from Add Element menu. (for instance, the Part aside the Component, or min/max cardinalities on a Property)
For instance
FunctionExt, FunctionalExchangeExt, ComponentExt
All capella elements have derived methods allowing direct access to other interesting elements. For instance, for an actor, actor.getAllocatedFunctions() retrieve the list of the allocated functions). These methods are computed in :
org.polarsys.capella.core.data.helpers
org.polarsys.capella.core.data.helpers.*.delegates.**Helper
It can be interesting to see how these methods are computed to understand how a reference between two element is stocked in the model.
IFile airdFile = ...
Session session = SessionManager.INSTANCE.getExistingSession(EcoreUtil2.getURI(airdFile));
for (DRepresentationDescriptor descriptor : DialectManager.INSTANCE.getAllRepresentationDescriptors(session)) {
descriptor.getRepresentation(); //will return the diagram
descriptor.getTarget()); //will return the element owning the diagram (for instance, the PhysicalComponent in a PAB diagram)
}
DDiagram diagram = (DDiagram)descriptor.getRepresentation(); //warning! directCast but there may have also DTable, DTree..
for (DDiagramElement element: diagram.getDiagramElements()) { //for all main elements in diagram
System.out.println(element); //here we have the graphical element
if (element instanceof DEdge) {
DEdge edge = (DEdge)element;
edge.getSourceNode()
edge.getTargetNode()
edge.getStyle()
} else if (element instanceof DNodeContainer, DNode, DNodeList) {
((DNodeContainer/DNode/DNodeList)element).getOwnedBorderedNodes()
((DNodeContainer/DNode/DNodeList)element).getStyle()
Node a = SiriusGMFHelper.getGmfNode(element); //here we have the GMF graphical element
System.out.println("located: "+a.getLayoutConstraint()); //display the location of the element
}
}
All editions in Capella is made through an TransactionalEditingDomain that guarantee a Thread-safe environnement. Any modification on model, diagram must be done through a command, like :
EObject element = ...
ExecutionManager manager = TransactionHelper.getExecutionManager(element).execute(new AbstractReadWriteCommand() {
@Override
public void run() {
if (element instanceof PhysicalComponent) {
PhysicalComponent pc = (PhysicalComponent)element;
pc.setName("toto");
CapellaElementExt.creationService(pc); //to create the related part
}
}
});
To create an element, you need to know its type (for instance by looking at the properties view) and know from which metamodel it comes from. See Metamodel Tutorial
EObject element = ... //an element from physical layer
ExecutionManager manager = TransactionHelper.getExecutionManager(element).execute(new AbstractReadWriteCommand() {
@Override
public void run() {
BlockArchitecture physicalArchitecture = BlockArchitectureExt.getRootBlockArchitexture(element);
PhysicalFunction pf = (PhysicalFunction)BlockArchitectureExt.getRootFunction(physicalArchitecture);
PhysicalFunction myNewFunc = PaFactory.eINSTANCE.createPhysicalFunction("new function");
pf.getOwnedPhysicalFunctions().add(myNewFunc);
}
});
EObject object = ...
element.eResource()
object.eContents() //returns all direct children of the element
object.eAllContents() //returns all children recursively
object.eClass() //returns the Metaclass of the given element
object.eClass().getAllReferences() //returns the Metaclass references of the given element
object.eClass().getAllAttributes() //returns the Metaclass references of the given element
object.eGet(object.eClass().getEStructuralFeature("name")) // returns the name of the element
//BUT, if you know the metaclass, it's faster to use getName() method. ((PhysicalFunction)object.getName()) for instance
object.eSet(object.eClass().getEStructuralFeature("name"), "newName") //set the name of the element
((EList)object.eGet(object.eClass().getEStructuralFeature("ownedElements"))).add(element) //add element to object.ownedElements
- Official Website
- Download
- Release-Notes 7.0.1 (current version)
- Release-Notes-7.0.0
- Release-Notes-6.1.0