Home » Eclipse Projects » Sirius » Selection Wizard problem - element variable returns container
Selection Wizard problem - element variable returns container [message #1623144] |
Thu, 19 February 2015 00:16 |
Leonardo Montecchi Messages: 10 Registered: September 2013 |
Junior Member |
|
|
Hello,
I am quite new to Sirius and I am trying to create my representations for an existing ecore model.
I am not sure I completely understood the behavior of the Selection Wizard, and Pane Based Selection Wizard tools. How can I access the elements that have been selected by the user? From my understanding they are in the 'element' variable.
However, in my setup such variable returns the element on which the user ran the tool (the one he clicked on), rather than the selected elements. Is this the intended behavior? If yes, where can I find the list of elements selected by the user?
Thanks,
Leonardo.
Leonardo Montecchi
Instituto de Computação, UNICAMP
http://ic.unicamp.br/~leonardo
http://laser.ic.unicamp.br/
|
|
|
Re: Selection Wizard problem - element variable returns container [message #1623689 is a reply to message #1623144] |
Thu, 19 February 2015 08:58 |
|
Hi Leonardo,
Le 19/02/2015 01:16, Leonardo Montecchi a écrit :
> Hello,
>
> I am quite new to Sirius and I am trying to create my representations
> for an existing ecore model.
>
> I am not sure I completely understood the behavior of the Selection
> Wizard, and Pane Based Selection Wizard tools. How can I access the
> elements that have been selected by the user? From my understanding they
> are in the 'element' variable.
The element variable (child of the Selection Wizard / Pane Based
Selection Wizard) and available for the model operation you will add to
specify the behavior of the tools will reference the selected elements.
It will be a Collection if the tool is a Pane Based Selection Wizard or
a Selection Wizard with Multiple set to true and and a single EObject if
the tool it a Selection Wizard with Multiple set to false (General tab
in the properties view when a Selection Wizard is selected).
Note that you can rename this variable (and all variables displayed as
children of the tools).
> However, in my setup such variable returns the element on which the user
> ran the tool (the one he clicked on), rather than the selected elements.
> Is this the intended behavior? If yes, where can I find the list of
> elements selected by the user?
You should have the selected element. I tried on a simple VSM with a
SelectionWizard and a PaneBaedSelectionWizard and in the model
operations I get the element(s) selected in the wizard as value of the
element variable.
Which version of Sirius do you use ? In which operation or which
interpreted expression do you observe this isssue ?
>
> Thanks,
> Leonardo.
>
>
Regards
--
Maxime - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
--
[1]
https://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#selection_wizard
[2]
https://www.eclipse.org/sirius/doc/specifier/diagrams/Diagrams.html#pane_based_selection_wizard
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Selection Wizard problem - element variable returns container [message #1632818 is a reply to message #1623689] |
Tue, 24 February 2015 13:59 |
Leonardo Montecchi Messages: 10 Registered: September 2013 |
Junior Member |
|
|
Hi Maxime,
Maxime Porhel wrote on Thu, 19 February 2015 03:58
The element variable (child of the Selection Wizard / Pane Based
Selection Wizard) and available for the model operation you will add to
specify the behavior of the tools will reference the selected elements.
It will be a Collection if the tool is a Pane Based Selection Wizard or
a Selection Wizard with Multiple set to true and and a single EObject if
the tool it a Selection Wizard with Multiple set to false (General tab
in the properties view when a Selection Wizard is selected).
Note that you can rename this variable (and all variables displayed as
children of the tools).
Thank you for your answer. It is working now. I was accessing the variable directly, I did not realize that it was a collection.
From the documentation I understood that the definition of the tool would be executed N times, each time with the i-th element from the selected elements as context. That is my fault probably! However a sentence that the variable can be a collection may clarify.
[/quote]
Maxime Porhel wrote on Thu, 19 February 2015 03:58
You should have the selected element. I tried on a simple VSM with a
SelectionWizard and a PaneBaedSelectionWizard and in the model
operations I get the element(s) selected in the wizard as value of the
element variable.
Actually using the collection variable directly as context was returning return the container elmement. For example, adding a "Set" expression to set the name of the object, would change the name of the container element. I am not sure this is the expected behavior.
Maxime Porhel wrote on Thu, 19 February 2015 03:58
Which version of Sirius do you use ? In which operation or which
interpreted expression do you observe this isssue ?
It was something like:
changecontext(element)
set(name) = 'Test'
After executing this the name of the object on whith the pane based selection tool was applied was changed to 'Test'.
Thanks,
Regards,
Leonardo.
Leonardo Montecchi
Instituto de Computação, UNICAMP
http://ic.unicamp.br/~leonardo
http://laser.ic.unicamp.br/
|
|
|
Re: Selection Wizard problem - element variable returns container [message #1699845 is a reply to message #1632818] |
Sat, 27 June 2015 06:24 |
Le Chau Nguyen Messages: 19 Registered: August 2012 |
Junior Member |
|
|
Hi Leonardo, Maxime and everyone,
I have same this problem when using Selection Wizard.
The difference to Leonardo use-case is my operation after selecting item is I call Java External Action.
I checked "selections" parameter in "void execute(Collection<? extends EObject> selections, Map<String, Object> arg1)" in my Java Class which implements IExternalJavaAction.
It contains the EClass that's corresponding to the object on Canvas where I click before Selection Wizard is opened. Not the selected EClass in Selection Wizard as expect.
In VSM, I defined:
<ownedTools xsi:type="tool_1:SelectionWizardDescription" name="testSelectionWizard" label="testSelectionWizard" candidatesExpression="[Sequence{ Club::FootballClub,Club::DancingClub}/]" message="Select Club" windowTitle="Club Selection Wizard" >
<element name="element"/>
<containerView name="containerView"/>
<container name="container"/>
<initialOperation>
<firstModelOperations xsi:type="tool_1:ChangeContext" browseExpression="var:element">
<subModelOperations xsi:type="tool_1:ExternalJavaAction" name="CreateClubElementContainer" label="CreateClubElementContainer" id="com.test.action.CreateClubElementContainerID"/>
</firstModelOperations>
</initialOperation>
</ownedTools>
In Selection Wizard, I selected "Club::FootballClub" but in Java input parameters, I got "ClubImpl" which is Club implementation, not "FootballImpl" as expect.
That seems Selection Wizard pass to Java the "container", not "element". What the wrong thing I do? Could you please advise? Thanks.
[Updated on: Sat, 27 June 2015 06:29] Report message to a moderator
|
|
|
Re: Selection Wizard problem - element variable returns container [message #1699975 is a reply to message #1632818] |
Mon, 29 June 2015 13:53 |
|
Hi Leonardo,
Le 24/02/2015 14:59, Leonardo Montecchi a écrit :
> Hi Maxime,
>
> Maxime Porhel wrote on Thu, 19 February 2015 03:58
>> The element variable (child of the Selection Wizard / Pane Based
>> Selection Wizard) and available for the model operation you will add
>> to specify the behavior of the tools will reference the selected
>> elements. It will be a Collection if the tool is a Pane Based
>> Selection Wizard or a Selection Wizard with Multiple set to true and
>> and a single EObject if the tool it a Selection Wizard with Multiple
>> set to false (General tab in the properties view when a Selection
>> Wizard is selected).
>>
>> Note that you can rename this variable (and all variables displayed as
>> children of the tools).
>
>
> Thank you for your answer. It is working now. I was accessing the
> variable directly, I did not realize that it was a collection.
> From the documentation I understood that the definition of the tool
> would be executed N times, each time with the i-th element from the
> selected elements as context. That is my fault probably! However a
> sentence that the variable can be a collection may clarify.
> [/quote]
>
> Maxime Porhel wrote on Thu, 19 February 2015 03:58
>> You should have the selected element. I tried on a simple VSM with a
>> SelectionWizard and a PaneBaedSelectionWizard and in the model
>> operations I get the element(s) selected in the wizard as value of the
>> element variable.
>
>
> Actually using the collection variable directly as context was returning
> return the container elmement. For example, adding a "Set" expression to
> set the name of the object, would change the name of the container
> element. I am not sure this is the expected behavior.
If the result of the browse expression of a Change Context is a
collection, it will do nothing and the context will still be the same as
before the operation.
If you use a Selectin/PaneBased selection wizard with multiple=true and
want to place the context on the selection which will be a collection,
you have to use a For operation and use var:element as expression for
example. Then you have to put the Set operation as child of the For element.
>
>
>
> It was something like:
>
> changecontext(element)
> set(name) = 'Test'
>
> After executing this the name of the object on whith the pane based
> selection tool was applied was changed to 'Test'.
>
> Thanks,
> Regards,
> Leonardo.
>
>
Regards
--
Maxime - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Selection Wizard problem - element variable returns container [message #1699980 is a reply to message #1699845] |
Mon, 29 June 2015 14:08 |
|
Le 27/06/2015 08:24, Le Chau Nguyen a écrit :
> Hi Leonardo, Maxime and everyone,
>
> I have same this problem when using Selection Wizard.
> The difference to Leonardo use-case is my operation after selecting item
> is I call Java External Action.
> I checked selection return object in "void execute(Collection<? extends
> EObject> selections, Map<String, Object> arg1)" in my Java Class
> which implements IExternalJavaAction.
> It contains the EClass that's corresponding to the object on Canvas
> where I click before Selection Wizard is opened. Not the selected EClass
> in Selection Wizard as expect.
>
> In VSM, I defined:
>
> <ownedTools xsi:type="tool_1:SelectionWizardDescription"
> name="testSelectionWizard" label="testSelectionWizard"
> candidatesExpression="[Sequence{
> Club::FootballClub,Club::DancingClub}/]" message="Select Click Element"
> windowTitle="Element Selection Wizard" >
> <element name="element"/>
> <containerView name="containerView"/>
> <container name="container"/>
> <initialOperation>
> <firstModelOperations xsi:type="tool_1:ChangeContext"
> browseExpression="var:element">
> <subModelOperations xsi:type="tool_1:ExternalJavaAction"
> name="CreateClubElementContainer" label="CreateClubElementContainer"
> id="com.test.action.CreateClubElementContainerID"/>
> </firstModelOperations>
> </initialOperation>
> </ownedTools>
>
> In Selection Wizard, I selected "Club::FootballClub" but in Java result,
> I get "ClubImpl" which is Club implementation, not "FootballImpl" as
> expect.
> That seems Java return "container", not "element". What the wrong thing
> I do? Could you please advise? Thanks.
Could you put a breakpoint in your external java action ?
You should see the selected EClass in the selections parameter.
How do you ask the creation of an instance of the selected class ?
Regards
--
Maxime - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Goto Forum:
Current Time: Thu Mar 28 22:50:50 GMT 2024
Powered by FUDForum. Page generated in 0.07916 seconds
|