|
|
|
Re: [0.9] Passing our own TransactionalEditingDomain [message #1005474 is a reply to message #918862] |
Fri, 25 January 2013 15:29 |
Cedric Moonen 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03305 seconds