Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Prevent Default Sirius ViewOrdering
Prevent Default Sirius ViewOrdering [message #1737580] Sun, 10 July 2016 17:02 Go to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Hi,

I ran into following problem:

I added some Dynamic Menuitems (via an extension) to my eclipse plugin, which show when I right click on a container. I want to use these to create different EObject instances for a selected Container.
So if I right click a container and click the menu item an Action is performed and the EMF resource tree is surprisingly locked in this Action, so I added a new RecordingCommand to the selected container's EditingDomain which executes an AddCommand.
This works, so no problems there.
The Problem is, everytime I created a new Instance Sirius seems to trigger it's ViewOrdering on the new container, therefore the container bounces arround.
I suppose the AbstractDiagramEditPart performs this ViewOrdering, but I dont't know when. I would like to prevent this.
I wrote ChangeBoundsrequests to move the new Container to a specific Location, which also works, but the ViewOrdering is always called as last.

How can I tell Sirius not to perform a ViewOrdering on this new Container?
I tried to refresh/full refresh the diagram before perfom the specific ChangeBoundsRequest, but the ViewOrdering seems always the last command to be performed.

Thanks.

Regards,
Matt
Re: Prevent Default Sirius ViewOrdering [message #1737602 is a reply to message #1737580] Mon, 11 July 2016 07:43 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Matt

I will need more information to be able to help you.

Le 10/07/2016 à 19:02, Matt Se a écrit :
> Hi,
>
> I ran into following problem:
>
> I added some Dynamic Menuitems (via an extension) to my eclipse plugin,
> which show when I right click on a container. I want to use these to
> create different EObject instances for a selected Container.

As I understand, is a container define by a ContainerMapping ? Is it
configured as FreeForm, List or one of the stack options ?

Are you in a standard diagram, a Sequence diagram ?

> So if I right click a container and click the menu item an Action is
> performed and the EMF resource tree is surprisingly locked in this
> Action, so I added a new RecordingCommand to the selected container's
> EditingDomain which executes an AddCommand.

If you modify the semantic model or the Sirius model, you will need a
command.

> This works, so no problems there. The Problem is, everytime I created a
> new Instance Sirius seems to trigger it's ViewOrdering on the new
> container, therefore the container bounces arround.

Could you show some screenshots of the issue ? The ViewOrdering might
depend on the the kind of mapping. In some situation it will corresponds
to the order of mappings and for each mapping the order of the semantic
candidates expression will be used to sort the produces children.

> I suppose the AbstractDiagramEditPart performs this ViewOrdering, but I
> dont't know when. I would like to prevent this.
> I wrote ChangeBoundsrequests to move the new Container to a specific
> Location, which also works, but the ViewOrdering is always called as last.
>
> How can I tell Sirius not to perform a ViewOrdering on this new Container?
> I tried to refresh/full refresh the diagram before perfom the specific
> ChangeBoundsRequest, but the ViewOrdering seems always the last command
> to be performed.
>

You could also take a look to the extension point
org.eclipse.sirius.diagram.ui.viewOrderingProvider

> Thanks.
>
> Regards,
> Matt


Regards,

--
Maxime - Obeo

Need training or 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: Prevent Default Sirius ViewOrdering [message #1737608 is a reply to message #1737602] Mon, 11 July 2016 08:53 Go to previous messageGo to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Hi Maxime,

thanks for your quick response.


>As I understand, is a container define by a ContainerMapping ? Is it
>configured as FreeForm, List or one of the stack options ?

>Are you in a standard diagram, a Sequence diagram ?

I use a standard sirius diagram with containers in it and their children are presented as list.

I added some menu items to create new containments for a container:

https://s32.postimg.org/3kkfx19sl/create+Instance via menu.png

The triggered dummy action from the widget looks like this:

	@Override
	public void widgetSelected(SelectionEvent e) {
		/* get the Editing domain from the DDiagram Element */
		TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(diagram);
		Aktuelle_Position newElement = IlmFactory.eINSTANCE.createAktuelle_Position();
		SetCommand command = new SetCommand(domain, target, IlmPackage.eINSTANCE.getStatus_Aktuelle_Position(),
				newElement);
		domain.getCommandStack().execute(command);

		domain.getCommandStack().execute(new RecordingCommand(domain) {

			@Override
			protected void doExecute() {
				/*
				 * Get the Editpart of the created newElement from the
				 * org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart
				 */
				AbstractGraphicalEditPart newChild = (AbstractGraphicalEditPart) IlmDiagramUtils
						.resolveEObjectsEditPart(newElement, diagramEditPart);
				/*Changeboundrequest to move the editpart to a specific location*/
				ChangeBoundsRequest move_req = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
				move_req.setEditParts(newChild);
				move_req.setMoveDelta(getPoint());
				Command cmd = newChild.getCommand(move_req);
				cmd.execute();
			}
		});
	}


First I create a new EObject then I use a setcommand to add it to it's parent ( where 'target' represents the resolved selected EObject in my diagram.
I then execute the command in the commandstack of the EditingDomain of my DDiagram.

Now I want to move the EditpartPart for the new created EObject to a specific location. Therefore I resolve the EditPart for my new EObject and use a ChangeBoundsRequest on it, now within a RecordingCommand but also in the CommandStack of my DDiagram's EditingDomain.

What happens (what is shown in the Diagram) is this:
First the ChangeBounds command is executed and the EditPart is at the desired location:
https://s32.postimg.org/oiqlv49n9/desired+location.png

But always as last the EditPart moves again to another location, which seems to be correlated to the sirius ViewOrdering:

https://s32.postimg.org/6h7gxbfmd/final+container location.png

So how do I accomplish this properly?

Many thanks in advance,

Matt
Re: Prevent Default Sirius ViewOrdering [message #1737612 is a reply to message #1737608] Mon, 11 July 2016 09:10 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Matt,

So for List elements, Sirius sorts by mapping first and then for each
mapping list elements are sorted regarding the result of the semantic
candidates expressions.

One solution to simply configure the order, might be to use a single
mapping for your list elements and use the semantic candidates
expression to return the element in the wanted order ?

Then you creation tools will have to put the created semantic elements
at the good position in the semantic model containment feature in order
to make the computed order correspond to your need. By default the
CreateInstance operation will add the element at the end of the list,
but you can later move it with a java service , or directly use a Java
Service to instantiate the domain element with you XXXFactory and add it
to its containment feature at the right place.

The change bounds request will have no impact on the list elements. As
the getModelChildren() is sorted using the rule explained at the
beginning of this message, then the list items editparts and figure are
created using this order and then ConstrainedToolbarLayout used for the
content pane simply take the order to place the elements as a list.

Regards.


Le 11/07/2016 à 10:53, Matt Se a écrit :
> Hi Maxime,
>
> thanks for your quick response.
>
>
>> As I understand, is a container define by a ContainerMapping ? Is it
>> configured as FreeForm, List or one of the stack options ?
>
>> Are you in a standard diagram, a Sequence diagram ?
>
> I use a standard sirius diagram with containers in it and their children
> are presented as list.
>
> I added some menu items to create new containments for a container:
>
>
>
> The triggered dummy action from the widget looks like this:
>
> @Override
> public void widgetSelected(SelectionEvent e) {
> /* get the Editing domain from the DDiagram Element */
> TransactionalEditingDomain domain =
> TransactionUtil.getEditingDomain(diagram);
> Aktuelle_Position newElement =
> IlmFactory.eINSTANCE.createAktuelle_Position();
> SetCommand command = new SetCommand(domain, target,
> IlmPackage.eINSTANCE.getStatus_Aktuelle_Position(),
> newElement);
> domain.getCommandStack().execute(command);
>
> domain.getCommandStack().execute(new RecordingCommand(domain) {
>
> @Override
> protected void doExecute() {
> /*
> * Get the Editpart of the created newElement from the
> *
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart
> */
> AbstractGraphicalEditPart newChild =
> (AbstractGraphicalEditPart) IlmDiagramUtils
> .resolveEObjectsEditPart(newElement,
> diagramEditPart);
> /*Changeboundrequest to move the editpart to a specific
> location*/
> ChangeBoundsRequest move_req = new
> ChangeBoundsRequest(RequestConstants.REQ_MOVE);
> move_req.setEditParts(newChild);
> move_req.setMoveDelta(getPoint());
> Command cmd = newChild.getCommand(move_req);
> cmd.execute();
> }
> });
> }
>
> First I create a new EObject then I use a setcommand to add it to it's
> parent ( where 'target' represents the resolved selected EObject in my
> diagram.
> I then execute the command in the commandstack of the EditingDomain of
> my DDiagram.
>
> Now I want to move the EditpartPart for the new created EObject to a
> specific location. Therefore I resolve the EditPart for my new EObject
> and use a ChangeBoundsRequest on it, now within a RecordingCommand but
> also in the CommandStack of my DDiagram's EditingDomain.
>
> What happens (what is shown in the Diagram) is this:
> First the ChangeBounds command is executed and the EditPart is at the
> desired location:
>
>
> But always as last the EditPart moves again to another location, which
> seems to be correlated to the sirius ViewOrdering:
>
>
>
> So how do I accomplish this properly?
>
> Many thanks in advance,
>
> Matt
>


--
Maxime - Obeo

Need training or 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: Prevent Default Sirius ViewOrdering [message #1737617 is a reply to message #1737612] Mon, 11 July 2016 10:03 Go to previous messageGo to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Thank you!!!
Finally this works properly. Don't ask how much time I spent on this issue...
Re: Prevent Default Sirius ViewOrdering [message #1737624 is a reply to message #1737617] Mon, 11 July 2016 11:48 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Le 11/07/2016 à 12:03, Matt Se a écrit :
> Thank you!!!
> Finally this works properly. Don't ask how much time I spent on this
> issue...
>

Could you indicate how you solved your issue ? With a good combination
semanticCandidatesExpression + creation tool operations ?


Regards

--
Maxime - Obeo

Need training or 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: Prevent Default Sirius ViewOrdering [message #1737992 is a reply to message #1737624] Thu, 14 July 2016 18:29 Go to previous messageGo to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Unfortunately it was premature to say I solved this.
It was a lucky coincidence, that the viewOrdering position was a match.

But I even found a away around it by adding a figurelistener to the Figure of my new editpart that get's called when its moved. After the viewOrdering is done, I can simply execute a ChangeboundsRequest, but this is kinda ugly and unsatisfying...

I then looked at what you suggested and did some digging in the Creation tools.

I found the org.eclipse.sirius.diagram.description.tool package with some classes that seem to do creation.
And especially the org.eclipse.sirius.diagram.ui.graphical.edit.policies.CreationUtil class.

Now my question is, how do I use this properly?
The ContainerCreationEditPolicy got me a little further. But I'm stuck at resolving how to create a org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription. I believe this class stores all Information for an editpart, but i could not figure out how to create it. All I got was the ContainerMappings of my viewpoint.

Any help is appreciated.

Thanks.

Re: Prevent Default Sirius ViewOrdering [message #1738245 is a reply to message #1737992] Mon, 18 July 2016 11:29 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Matt,

Could you send more visual details like a screenshot or a sketch showing
the current scenario, its current result and the result you would like
to see, it might help us to understand your issue in a better way.

Regards,

Le 14/07/2016 à 20:29, Matt Se a écrit :
> Unfortunately it was premature to say I solved this.
> It was a lucky coincidence, that the viewOrdering position was a match.
>
> But I even found a away around it by adding a figurelistener to the
> Figure of my new editpart that get's called when its moved. After the
> viewOrdering is done, I can simply execute a ChangeboundsRequest, but
> this is kinda ugly and unsatisfying...
>
> I then looked at what you suggested and did some digging in the Creation
> tools.
>
> I found the org.eclipse.sirius.diagram.description.tool package with
> some classes that seem to do creation.
> And especially the
> org.eclipse.sirius.diagram.ui.graphical.edit.policies.CreationUtil class.
>
> Now my question is, how do I use this properly? The
> ContainerCreationEditPolicy got me a little further. But I'm stuck at
> resolving how to create a
> org.eclipse.sirius.diagram.description.tool.ContainerCreationDescription. I
> believe this class stores all Information for an editpart, but i could
> not figure out how to create it. All I got was the ContainerMappings of
> my viewpoint.
>
> Any help is appreciated.
>
> Thanks.
>
>


--
Maxime - Obeo

Need training or 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: Prevent Default Sirius ViewOrdering [message #1738294 is a reply to message #1738245] Mon, 18 July 2016 17:40 Go to previous messageGo to next message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Hi Maxime,

scenario is still the same as shown in the post above.

Since I couldn't figure out how to adjust the semantic Candidates, I wonder how to use the sirius creation tools programmatically?

So is it possible to invoke the "Create Instance"? Or how do I use the CreationUtil class to create a new Editpart with a new EObject?

Thank you.
Re: Prevent Default Sirius ViewOrdering [message #1738336 is a reply to message #1738294] Tue, 19 July 2016 07:22 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Matt

Le 18/07/2016 à 19:40, Matt Se a écrit :
> Hi Maxime,
>
> scenario is still the same as shown in the post above.

I just sa the image on the forum website, it was not shwon in your
message displayed in Thunderbird.
>
> Since I couldn't figure out how to adjust the semantic Candidates, I
> wonder how to use the sirius creation tools programmatically?

Without the image, I misunderstood your issue and tought your were
trying to order/move the children of a Status, ie list elements.

For containers, the semantic candidates expression will not have the
same impact.

The ViewOrdering you mentionned is called only when the
getCommand(Request) method of the diagram edit part is call with an
ArrangeRequest as parameter, for exemple when the Arrange all is
triggered or when an element is created on the diagram (the arrange
selection is called with the new created elements as selection). Unless
you have defined an Ordered Tree layout in your odesign, the
ViewOrdering command you see populates/prepares the ordering for the
arrange all/selection.

I think you should just do your semantic command and let Sirius do the
job to create the view and the edit part. But you should be able to set
the position by giving the same layout hint than a tool which will store
the clicked location

>
> So is it possible to invoke the "Create Instance"? Or how do I use the
> CreationUtil class to create a new Editpart with a new EObject?

The org.eclipse.sirius.diagram.ui.graphical.edit.policies.CreationUtil
class might help you to see how to build a layout data and pass it to
Sirius: you will see that each getXXXCommand prepares a CompoundCommand
with two children: one with the result of createLayoutCommand, the other
one for the tool effect.

Note that
org.eclipse.sirius.diagram.ui.tools.internal.menu.PopupMenuContribution.buildOperationAction(OperationAction,
Collection<DSemanticDecorator>, EditDomain, IDiagramCommandFactory,
EditPart, Point) does the same but for popup menus define in the VSM, if
you want to keep your own menu definitions, you might just try something
like:

SiriusLayoutDataManager.INSTANCE.addData(new
RootLayoutData(primarySelection, currentMouseLocation.getCopy(), new
Dimension(-1, -1)));

called just before your command execution, with primarySelection = your
current selected edit part.

You should ot need a command to store the layout data as their will be
no model modification and your widgetSelected method is called when the
user has clicked on the menu.


>
> Thank you.

Regards


--
Maxime - Obeo

Need training or 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: Prevent Default Sirius ViewOrdering [message #1738792 is a reply to message #1738336] Sun, 24 July 2016 15:45 Go to previous message
Matt Se is currently offline Matt SeFriend
Messages: 29
Registered: February 2016
Junior Member
Hey Maxime,

I finally got this to work with SiriusLayoutDataManager.INSTANCE.addData(new
RootLayoutData(primarySelection, currentMouseLocation.getCopy(), new
Dimension(-1, -1))); . Indeed I didn't need a command for that.

Thank you very much.
Previous Topic:Export custom figures
Next Topic:Obeo designer 9.0 under Win 7 is not started
Goto Forum:
  


Current Time: Sat Apr 27 02:14:56 GMT 2024

Powered by FUDForum. Page generated in 0.02865 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top