Using GEF in a Shell opened by Eclipse RCP [message #248341] |
Wed, 15 April 2009 07:37 |
Eclipse User |
|
|
|
Hi,
Suppose I have a Model along with EditParts and an EditPartFactory, and I
want to display it in a graphical form in a Shell that is generated from
within an Eclipse plugin. How do I do that? I tried something like this:
----------------------------
public class GEFShellSample {
private Shell parent;
private ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
private RootEditPart rootEditPart = new ScalableFreeformRootEditPart();
private EditPartFactory editPartFactory = new MyGEFEditPartFactory();
private MyModel model;
public void makeShell() {
parent = new Shell(Display.getDefault());
model = new MyModel();
viewer.createControl(parent);
viewer.setRootEditPart(rootEditPart);
viewer.setEditPartFactory(editPartFactory);
viewer.setContents(model);
viewer.getControl().setBackground(new Color(null, 255,255,255));
parent.pack();
parent.open();
}
}
----------------------------
This doesn't work. When calling makeShell() I can't see any graphical
viewer, just an empty Shell. However, if I copy the makeShell() body
(minus the lines about the Shell) and past them into the
createPartControl(Composite parent) of a ViewPart, there it seems to work.
What am I missing? Shouldn't the viewer.createControl() method create the
canvas automatically?
Thanks,
Alessandro
|
|
|
Powered by
FUDForum. Page generated in 0.27076 seconds