|
Re: Select newly inserted model element [message #548794 is a reply to message #548750] |
Fri, 23 July 2010 06:00 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Robert Wloch![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=robert%40rowlo.de) Messages: 109 Registered: July 2009 |
Senior Member |
|
|
Erich wrote on Thu, 22 July 2010 16:31 | Hi everyone,
I want to insert a new model element into the model during the execution of a RecordingCommand and then have it selected in the diagram.
Until now I managed to create the model element, then have it positioned in a org.eclipse.gmf.runtime.notation.Diagram. As I understand it, the selection is done by the org.eclipse.gef.GraphicalViewer. The viewer does not update its ShapeNodeEditParts until after the command is executed and the TransactionalEditingDomain commited.
Is there a way to write such a command?
|
Yes, in your RecordingCommand you can either invoke a Runnable on the Display or schedule a Job to select the figure.
This is an example for the Runnable:
Display display = PlatfromUI.getWorkbench().getDisplay();
display.asyncExec(new Runnable() {
public void run() {
// your code to select a figure goes here
}
});
This is an example for the UIJob:
Job job = new UIJob("Select figure") {
public IStatus runInUIThread(IProgressMonitor monitor) {
// your code to select a figure goes here
return Status.OK_STATUS;
}
});
job.schedule(50); // schedule after 50 ms
Beware, however, that Commands are undoable and the Runnable/Job will be executed during undo operations, too, if you don't prevent this.
Quote: | Best regards,
Erich
|
Rob
|
|
|
|
Powered by
FUDForum. Page generated in 0.02765 seconds