Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » [0.9] Passing our own TransactionalEditingDomain
[0.9] Passing our own TransactionalEditingDomain [message #918862] Fri, 21 September 2012 12:20 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I just upgraded from graphiti 0.8 to 0.9 and I saw that you can't pass a TransactionalEditingDomain anymore in the editor input.

In my case, the diagram editor is editing a part of a more complex model. I want to share the same editing domain for my complete model (and I don't have any other choice neither since if I try to modify my model without the use of the transactional editing domain, the one created by graphiti will throw an exception).

In the new version of graphiti, I saw that a new resource set and a new transactional editing domain is created (via the EmfService).

So, here are my questions:
1) Is there a way to pass my own editing domain to graphiti ? If yes, what would be the best practice to do so ? If no, how can I handle the scenario which I described ?
2) I saw that graphiti is using its own command stack (GFWorkspaceCommandStackImpl). What will be the implications if I provide my own editing domain (for which the command stack was created through:

WorkspaceEditingDomainFactory.INSTANCE.createEditingDomain(ResourceSet set)


Thanks
Re: [0.9] Passing our own TransactionalEditingDomain [message #919102 is a reply to message #918862] Fri, 21 September 2012 17:29 Go to previous messageGo to next message
Joao S is currently offline Joao SFriend
Messages: 51
Registered: January 2011
Member
Hey Cedric,

I think you should take a look at DefaultUpdateBehavior. Theres a method createEditingDomain() than you can override and provide your own implementation.

About your second question, i don´t know, but I would like to know the answer too Smile

As I understand you want to provide a different CommandStack, I think that it would be ok if it implements IWorkspaceCommandStack.

Thanks,
Joao

[Updated on: Fri, 21 September 2012 17:29]

Report message to a moderator

Re: [0.9] Passing our own TransactionalEditingDomain [message #921586 is a reply to message #919102] Mon, 24 September 2012 08:45 Go to previous messageGo to next message
Joao S is currently offline Joao SFriend
Messages: 51
Registered: January 2011
Member
Just one other thing,

I think this document is useful for keeping track of changes in Graphiti:

http://www.eclipse.org/graphiti/pages/whats-new-0.9.html

In your particular scenario I think this can be useful:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=336488

Best regards,
Joao
Re: [0.9] Passing our own TransactionalEditingDomain [message #1005474 is a reply to message #918862] Fri, 25 January 2013 15:29 Go to previous messageGo to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello Joao,

Thanks for the reply and sorry for the extremly long delay. I tried your solution but it didn't work so I dropped the case and stayed with version 0.8.

Here is the reason why it didn't work.

So, I already have my own editing domain and I would like to pass it to graphiti. So, what I did is add a constructor in my custom diagram editor and override the createUpdateBehavior method and pass my own editing domain to my custom EplUpdateBehavior:

public class EplDiagramEditor extends DiagramEditor {

	public static String EPL_DIAGRAM_EDITOR_ID = "be.fmtc.logan2.ui.editors.eplpattern.diagram.EplDiagramEditor";

	private TransactionalEditingDomain editingDomain;

	public EplDiagramEditor(TransactionalEditingDomain editingDomain) {
		this.editingDomain = editingDomain;
	}

	@Override
	protected DefaultUpdateBehavior createUpdateBehavior() {
		return new EplUpdateBehavior(this, editingDomain);
	}
}


Unfortunately this doesn't work, because the createUpdateBehavior is called in the constructor of DiagramEditor, which means that my own editing domain was not assigned yet in the editingDomain member of my class.

So, in my custom update behavior if I do this:

public class EplUpdateBehavior extends DefaultUpdateBehavior {

	private TransactionalEditingDomain editingDomain;

	public EplUpdateBehavior(DiagramEditor diagramEditor,
			TransactionalEditingDomain editingDomain) {
		super(diagramEditor);
		this.editingDomain = editingDomain;
	}

	@Override
	protected void createEditingDomain() {
		initializeEditingDomain(editingDomain);
	}
}


The call to initializeEditingDomain will raise a null pointer exception since the editingDomain is null.

Would it be possible to call all the create methods not in the constructor but in the void init(IEditorSite site, IEditorInput input) method ?

The diagram editor is used as a page inside a multi page editor, that is the reason why I can create the editor myself and pass the editing domain in the constructor.

If the diagram editor was used as a standalone editor, I don't even see how I would be able to pass my editing domain, since the default constructor of the diagram editor would be invoked and you have no way to pass the editing domain before the createUpdateBehavior method is called.

Or did I miss something here ?

[Updated on: Fri, 25 January 2013 15:30]

Report message to a moderator

Re: [0.9] Passing our own TransactionalEditingDomain [message #1005667 is a reply to message #1005474] Mon, 28 January 2013 07:42 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 211
Registered: July 2009
Senior Member
Have you considered using Sphinx? It helps a lot if you have a model combined from various models and more than one editor accessing it. I have written a short blog about Sphinx+Graphiti: http://5ise.quanxinquanyi.de/2013/01/09/why-you-should-consider-sphinx-for-your-modeling-projects/
Re: [0.9] Passing our own TransactionalEditingDomain [message #1005713 is a reply to message #1005474] Mon, 28 January 2013 11:22 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Cedric,

why don't you just add a setEditingDomain method to your EplDiagramEditor?
In that method you can simply forward the editing domain to the update
behavior where you would again need such a setter method; there you would
simply store that instance in a member and use it from within
createEditingDomain instead of creating a new one.

Michael
Re: [0.9] Passing our own TransactionalEditingDomain [message #1005730 is a reply to message #1005713] Mon, 28 January 2013 12:48 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Michael,

Yes indeed that works. I thought that the createEditingDomain method (on the DefaultUpdateBehavior) would also be called in the constructor but after looking at the graphiti code I saw that it is called only in the DiagramEditor::init method.

Thank you,
Cédric
Previous Topic:Accessing the modified objects after feature is executed
Next Topic:How to update existing diagrams, if domain model structure has changed?
Goto Forum:
  


Current Time: Fri Apr 19 22:04:51 GMT 2024

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

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

Back to the top