Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » The trigger when the node is moved
The trigger when the node is moved [message #1775794] Mon, 06 November 2017 13:06 Go to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi,

I have a question on the trigger move the node.

I have a question about the trigger when the node is moved.

I need to call an action when moving the node.
Is it possible, or how?

I tried to use the ResourceSetListener listener and the resourceSetChanged method, which could work, but I do not know if it is the right solution.

getDiagramEditPart().getEditingDomain().addResourceSetListener(new ResourceSetListener() {

	@Override
	public org.eclipse.emf.common.command.Command transactionAboutToCommit(ResourceSetChangeEvent event) throws RollbackException {
		return null;
	}

	@Override
	public void resourceSetChanged(ResourceSetChangeEvent event) {
		for (Iterator iter = event.getNotifications().iterator(); iter.hasNext();) {
			Object object = iter.next();
			if (object instanceof ENotificationImpl) {
				ENotificationImpl notification = (ENotificationImpl) object;
				Object notifier = notification.getNotifier();
				if (notifier instanceof BoundsImpl) {
					BoundsImpl bounds = (BoundsImpl) notifier;
					System.out.println(bounds);
				}
			}
		}
	}
    
    ...
    
});


Thanks for every advice.

Martin
Re: The trigger when the node is moved [message #1775864 is a reply to message #1775794] Tue, 07 November 2017 10:56 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi,

it really depends on what the "action" you want to call does. If your action needs to make any change to any of the EMF models inside the session, it must be a pre-commit listener (implemented as a command returned from transactionAboutToCommit). Otherwise (i.e. it will only impact some UI or non-EMF data structure), it's better to use a post-commit listener (implemented in resourceSetChanged as in your example).

Note the Sirius already has several pre and post-commit listeners registered, so depending on what you want to do you may need to make sure yours are invoked before or after Sirius's own. See Session.getEventBroker() which exposes an API to better control the ordering of pre-commit listeners (at least the ones that use it).

Regards,


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: The trigger when the node is moved [message #1776878 is a reply to message #1775864] Wed, 22 November 2017 12:51 Go to previous message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi,

Is there any other way of implementing how to call action after moving the node (move listener, drop listener)?

Specifically, I need to call Arrange All / Selection.

Thanks.

Martin
Previous Topic:Evaluating "If" condition in Acceleo/Sirius
Next Topic:show/hide certain diagram elements?
Goto Forum:
  


Current Time: Thu Apr 25 15:10:20 GMT 2024

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

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

Back to the top