Split programmatically the main representation into several representations [message #1630970] |
Mon, 23 February 2015 14:09 |
Adel Ziani Messages: 9 Registered: June 2014 |
Junior Member |
|
|
Is it possible to split programmatically the main representation "representations.aird" into several representations files in the same project ?
use case scenario:
1. create a new ModelingProject with "models" folder
CustomModelingProject
|-- models
| |
|-- representations.aird
2. create a new model "model1.myextesion" and extract its representation from "representations.aird" to "model1.aird"
CustomModelingProject
|-- models
| |-- model1.myextesion
| |-- model1.aird
|-- representations.aird
I succeeded to reproduce this scenario using UI Sirius menu "Extract to .aird file ..."
Programmatically, I'm using SiriusControlCommand but without any success. The command is not executed because my semanticRoot object doesn't have a container (Not controllable) !
Why it works when I'm using the UI ? How this command can be used programmatically ?
[Updated on: Mon, 23 February 2015 14:09] Report message to a moderator
|
|
|
Re: Split programmatically the main representation into several representation [message #1632595 is a reply to message #1630970] |
Tue, 24 February 2015 11:15 |
|
Le 23/02/2015 15:09, Adel Ziani a écrit :
> Is it possible to split programmatically the main representation
> "representations.aird" into several representations files in the same
> project ?
> use case scenario:
>
> 1. create a new ModelingProject with "models" folder
>
> CustomModelingProject
> |-- models
> | |
> |-- representations.aird
>
> 2. create a new model "model1.myextesion" and extract its representation
> from "representations.aird" to "model1.aird"
>
> CustomModelingProject
> |-- models
> | |-- model1.myextesion
> | |-- model1.aird
> |-- representations.aird
>
> I succeeded to reproduce this scenario using UI Sirius menu "Extract to
> .aird file ..."
> Programmatically, I'm using SiriusControlCommand but without any
> success.
This is not the command you are looking for :)
SiriusControlCommand is for controlling (using the EMF terminology) the
semantic model, and optionaly move the Sirius representations of the
newly controled semantic elements into a new .aird file.
Fragmented .aird files are not "controled" in the sense of EMF: they are
just models with normal reference between them.
It looks like in your scenario there is no actual control involved: the
semantic model is contained in a single resource.
I don't think we have a direct API to do this non-interactively, but you
can have a look at
org.eclipse.sirius.ui.tools.internal.wizards.ExtractRepresentationsWizard,
which is the wizard invoked by "Extract to .aird file ..." and does what
you want, which is basically:
1. Create a new .aird file properly configured.
2. Register it as a "referenced analysis" (*not* controled, just
referenced) from the main representations.aird.
3. Identify which actual representations from representations.aird you
want to move.
4. Perform the actual move using
org.eclipse.sirius.business.api.dialect.command.MoveRepresentationCommand.
> The command is not executed because my semanticRoot object
> doesn't have a container (Not controllable) ! Why it works when I'm
> using the UI ?
That's because "Extract to .aird file ..." does not involve any actual
controling, especially not on your semantic model.
--
Pierre-Charles David - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Re: Split programmatically the main representation into several representation [message #1634424 is a reply to message #1632940] |
Wed, 25 February 2015 09:04 |
|
Le 24/02/2015 16:29, Adel Ziani a écrit :
> Hi Pierre-Charles,
Hi.
> thanks a lot for your answer, it is much clear for me now :)
> I followed your instructions and it ended up working.. Just a problem:
> when creating my model and before the creation of the aird file i got
> the SmartDialogAnalysisSelector asking me to select one of the
> availables representations files!
You can set your own selector (with specific logic which does not
involve the UI) by using
((DAnalysisSession) session).setAnalysisSelector(yourSelector)
> I don't know if I correctly did the
> registration (referencing) of the secondary aird from the main one :
>
> mainSession.getReferencedSessionResources().add(resourceAird);
> is this the way to do?
Have a look at
org.eclipse.sirius.tools.internal.command.PrepareNewAnalysisCommand: it
does a little more (registering the semantic models of the main
DAnalysis into the new one).
--
Pierre-Charles David - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.01759 seconds