Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Select newly inserted model element(Select newly inserted model element)
Select newly inserted model element [message #548750] Thu, 22 July 2010 20:31 Go to next message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
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?

Best regards,
Erich
Re: Select newly inserted model element [message #548794 is a reply to message #548750] Fri, 23 July 2010 06:00 Go to previous messageGo to next message
Robert Wloch is currently offline Robert WlochFriend
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
Re: Select newly inserted model element [message #548914 is a reply to message #548794] Fri, 23 July 2010 13:19 Go to previous message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
Thanks Rob,

your solution works like a charm.

Best regards,
Erich
Previous Topic:Problems after update to Eclipse 3.6 with GMF 2.3.0
Next Topic:Can GMF support RAP?
Goto Forum:
  


Current Time: Sat Jul 27 10:59:26 GMT 2024

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

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

Back to the top