Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Display wizard when creating new node
Display wizard when creating new node [message #229343] Mon, 11 May 2009 13:09 Go to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
Hello,

I'd like to have some sort of custom wizard, that pops up when a new node
is created. The user could then select an entry out of a list and
depending on the selected entry, attributes and sub-elements of the
created node need to be changed/added.

Any hints on how to achieve that (or parts of it)?
Any tutorials or older newsgroup items about similar things?

Thanks in advance,
Peter
Re: Display wizard when creating new node [message #229693 is a reply to message #229343] Tue, 12 May 2009 15:17 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Peter,

You can modify corresponding XXXCreateCommand for this node or listen domain
model and show dialog then you get "new domain model element added" notification.

-----------------
Alex Shatalin
Re: Display wizard when creating new node [message #230318 is a reply to message #229693] Thu, 14 May 2009 18:27 Go to previous messageGo to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
Thanks, Alex.

I use a custom CreateCommand, displaying the wizard in
doDefaultElementCreation, and it works!

Is this what you meant?

Now I would like to cancel / undo node creation, when the user choses to
cancel the wizard. Any idea on that?
Re: Display wizard when creating new node [message #230350 is a reply to message #230318] Thu, 14 May 2009 19:40 Go to previous messageGo to next message
Tobias Neef is currently offline Tobias NeefFriend
Messages: 17
Registered: July 2009
Junior Member
Why do you first create the node and show the wizard afterwards? You can
ask for the values before the element creation and set the attributes
afterwards if the wizzard was not canceled. If it was canceled you just
about the creation by return a cancelledCommandRestult.

In code it is something like this:

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {

// start wizzard

...
if(dialogResult == Dialog.CANCEL){
return CommandResult.newCancelledCommandResult();
} else {
//get all attributes from dialog and save them
a1 = dialog.getAttribute();
return super.doExecuteWithResult(monitor, info);
}

}

@Override
protected void doConfigure(SAVEComponentInstance newElement,
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {

newElement.setAttribute(a1);
super.doConfigure(newElement, monitor, info);
}

Best Regards,
Tobias Neef
Re: Display wizard when creating new node [message #230445 is a reply to message #230350] Fri, 15 May 2009 11:07 Go to previous message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
Thanks a lot for the detailed answer, very much appreciated!

I created the node before showing the wizard, because I did not know how
to do better :)

It works now as expected, the only thing is that no doExecuteWithResult
and no doConfigure are being generated for my original CreateCommand, so I
do it all in my overridden CustomXxxCreateCommand.doExecuteWithResult:

Display the wizard, and if it succeeds, I call super.doExecuteWithResult,
retrieve the new element using getNewElement() afterwards, modify the
element and return a newOKCommandResult.

Are there any flaws with my solution that I cannot see right now?
Previous Topic:How to change source and target of a link in the generated code?
Next Topic:How to get Shortcut from a existing GMF editor not providing shortcut?
Goto Forum:
  


Current Time: Thu Apr 25 04:49:29 GMT 2024

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

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

Back to the top