Additional diagram initialization code [message #204394] |
Thu, 04 September 2008 15:44 |
Eclipse User |
|
|
|
Originally posted by: martin.divbyzero.net
I'm trying to extend ???CreationWizard.performFinish() to add additional
diagram initialization code right after a new diagram has been created.
To be precise, I want to call the method setFoo() on the model element.
My current approach is to add the following code at the bottom of
performFinish():
> TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE
> .getEditingDomain(diagram.getResourceSet());
>
> Diagram d = (Diagram)(diagram.getContents().get(0));
> final MyModel model = (MyModel)(d.getElement());
>
> editingDomain.getCommandStack().execute(
> new RecordingCommand(editingDomain) {
> protected void doExecute() {
> model.setFoo("abc");
> }
> });
>
> System.out.println(model.getFoo());
The print statement in the last prints the correct value "abc", but
neither in the properties view of the graphical editor nor in the XMI
file the value for the Foo attribute shows up. Can someone spot my
mistake? Am I using the wrong editing domain?
When I call setFoo() in ???DiagramEditorUtil.createInitialModel()
instead, the value persists as expected. Unfortunately I'd like to
avoid going this route because extending performFinish() seems to be a
much cleaner approach.
Martin
|
|
|
|
Powered by
FUDForum. Page generated in 0.03752 seconds