|
|
Re: Create Node from another model in diagram editor [message #1743763 is a reply to message #1743557] |
Mon, 19 September 2016 13:39 |
|
Hi Bo,
Are both models A and B in the same Modeling Project ? In that case they are already loaded in the same resource set, and in you can use java service / aql expression to retrieve them from the element on which you clicked to activate your tool.
If there are not in the same ModelingProject, you will need an additional step in your services to load the Model B.
If you want to display a selection wizard, either you use a Node Creation Tool, and you create an Select Model Element Variable as child of the element/container variable (child of the tool), or you create a JavaService with you code to create and display a wizard.
Another solution is to use a SelectionWizard tool, but you will need to write a precondition to replace the checks automatically done by Sirius for NodeCreationTool (see their mapping / extra mappings properties).
You can fin information in :
* Selection Wizard section in https://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#tools (the Select Model Element Variable can be configured in the same way)
* https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html
Regards
Maxime - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Create Node from another model in diagram editor [message #1743778 is a reply to message #1743763] |
Mon, 19 September 2016 14:53 |
Bo Liu Messages: 32 Registered: July 2016 |
Member |
|
|
Hi Maxime,
thanks for the reply.
Yes, both Models are in the same Modeling Project.
Can you explain how I can do that with java service / aql expression?
What I have in Mind is use the Node Creation Tool and Create the Model Instance in an External Java Action.
The Problem is how can I load the model instance that I need.
I have tried to use the LoadResourceDialog, although I select the model instance in the Dialog, but that Instance is not loaded.
When I call LoadResourceDialog.getUrls(), it has the value null....
best regards
Bo
[Updated on: Mon, 19 September 2016 14:54] Report message to a moderator
|
|
|
Re: Create Node from another model in diagram editor [message #1743905 is a reply to message #1743778] |
Tue, 20 September 2016 14:05 |
|
Hi Bo,
" both Models are in the same Modeling Project."
So Sirius has already loaded both models and they are present in the ResourceSet of your ModelingProject.
IMO, you should use a Java service (see https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html) and not an External Java Action.
You do not need to call the Load..Dialog as the model should be automatically loaded.
From you Java servie, you will need to retrieve your model A from your model B, several ways might lead to this:
. objectFromModelB.eResource().getResourceSet().getResources() -> iteration to find your modelB
. SessionManager.INSTANCE.getSession(objectFromModelB).getTransactionalEditingDomain().getResourceSet().getResources(), and the same
. SessionManager.INSTANCE.getSession(objectFromModelB).getSemanticResources() and the same
. You might already have a model reference from modelB to modelA, in this case, juste navigate your modelB from the object you pass as parameter to the one which should have the relation to modelA .
. In case your modelA would not be already loaded, just retrieve the session as mentioned in the previous list items and then use org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.addSemanticResource(URI, IProgressMonitor)
Regards
|
|
|
|
|
Re: Create Node from another model in diagram editor [message #1754587 is a reply to message #1754172] |
Mon, 20 February 2017 15:14 |
|
Hi Stephan,
If you have some model references from your model A to your model B, you might navigate them (in the same way than expression inside the same resource) to retreive the element from model B you want to add them on your diagram.
You might also reduce the amount of Java code by computing several parameters for your Service.
But if you need to to look for a resource, maybe load it if it not yet present, you will need to use the Java Service.
Note that your can find the AQL documentation here: https://www.eclipse.org/acceleo/documentation/aql.html and check the service it provides for Resource.
Regards
|
|
|
|
Powered by
FUDForum. Page generated in 0.02721 seconds