Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » [0.9.1] Using Graphiti with external editing domain causes problem at clean up
[0.9.1] Using Graphiti with external editing domain causes problem at clean up [message #1006267] Wed, 30 January 2013 15:57 Go to next message
Cedric Moonen is currently offline Cedric Moonen
Messages: 274
Registered: August 2009
Senior Member
Hello,

I'm using a graphiti editor as a page inside a multi-page editor. In order to have the undo command stack working properly with the rest of the editor, I provide my own editing domain to graphiti (by overriding the DefaultUpdateBehavior). This works fine, but I have the requirement that if a specific element in my own editor (on another page) is removed, then the graphiti page has to be removed as well. Unfortunately, by doing so, graphiti does some clean-up with the TransactionalEditingDomain causing my application to throw exceptions after that (I can't close nor save my editor anymore for instance).

After a bit of investigation I saw that in the dispose method of the DiagramEditor, there are thinkgs like this:
		if (getEditDomain() != null && getEditDomain().getCommandStack() != null) {
			getEditDomain().getCommandStack().removeCommandStackEventListener(gefCommandStackListener);
			getEditDomain().getCommandStack().dispose();
		}


I could override the dispose method but there are things which I can't access, e.g. this piece of code:
		if (getConfigurationProvider() != null) {
			getConfigurationProvider().dispose();
		}

		if (paletteBehaviour != null) {
			paletteBehaviour.dispose();
		}

		markerBehavior.dispose();


Or even call the dispose method of the super class (GraphicalEditorWithFlyoutPalette) :
			try {
				super.dispose();
			} catch (RuntimeException e) {
				exc = e;
			}


How can I properly dispose my editor without breaking the full editing domain in this case ?
Re: [0.9.1] Using Graphiti with external editing domain causes problem at clean up [message #1006269 is a reply to message #1006267] Wed, 30 January 2013 16:10 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric Moonen
Messages: 274
Registered: August 2009
Senior Member
A potential solution (maybe): wouldn't it be possible to delegate the clean-up of the editing domain to the update behavior ? It is already its responsibility to dispose it, so why not also move those two calls there as well (in the disposeEditingDomain method for instance):

getEditDomain().getCommandStack().dispose();

		if (getEditDomain() != null) {
			getEditDomain().setCommandStack(null);
		}


If that would be the case, I could simply override the disposeEditingDomain method in my custom update behavior class and do nothing there.
Re: [0.9.1] Using Graphiti with external editing domain causes problem at clean up [message #1006387 is a reply to message #1006267] Thu, 31 January 2013 08:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1618
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Cedric,

not sure, but don't you mingle two different concepts here?

There's the EMF (transactional) edititing domain here that you use within
your multi page editor for EMF editing. That one is handled in
DefaultUpdateBehavior including its disposal; you should be able to override
that.

On the other side there is the GEF edit domain, which represents aspects of
a GEF-based editor. This is handled inside DiagramEditor and disposed within
its dispose method. Do you really need any aspects of that GEF edit domain
outside the graphical sub editor?

Regarding access to the method getConfigurationProvider: that's indeed an
issue in 0.9.1. We fixed that for Graphiti 0.10.0 (Kepler) and ported the
essential accessibility of the method down to Graphiti 0.9.2 (Juno SR2 to be
released February 22nd). See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=383768 for details. But as
stated above I think this is not needed in your case.

Michael
Re: [0.9.1] Using Graphiti with external editing domain causes problem at clean up [message #1006406 is a reply to message #1006387] Thu, 31 January 2013 09:26 Go to previous message
Cedric Moonen is currently offline Cedric Moonen
Messages: 274
Registered: August 2009
Senior Member
not sure, but don't you mingle two different concepts here?


Yes indeed you are right: I thought that the getEditDomain() method in DiagramEditor was returning my own domain model.

So I first tried to override the dispose method and things were working again. But the problem was not that this editing domain was cleaned, but rather the call to

DefaultUpdateBehavior behavior = getUpdateBehavior();
		behavior.dispose();


which was disposing my own editing domain. So indeed, if I only override the dispose method of the update behavior, this fixes the problem too.

I didn't know that GEF also had its own editing domain.
So indeed, I don't need to override the dispose method of the DiagramEditor.

Thanks for the reply !

[Updated on: Thu, 31 January 2013 09:26]

Report message to a moderator

Previous Topic:How to update existing diagrams, if domain model structure has changed?
Next Topic:Add actions/actionsets to the context-menu?
Goto Forum:
  


Current Time: Wed Oct 22 12:14:23 GMT 2014

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

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