[0.9] Passing our own TransactionalEditingDomain [message #918862] |
Fri, 21 September 2012 08:20  |
Eclipse User |
|
|
|
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 #1005474 is a reply to message #918862] |
Fri, 25 January 2013 10:29   |
Eclipse User |
|
|
|
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 10:30] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04622 seconds