[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: GEF and RCP - Where do they meet?
|
Boris Bokowski wrote:
"Frank Gerhardt" <fg@xxxxxxxxxxxxxxxxx> wrote:
Kevin O'Riordan wrote:
Okay, so far my project is in two parts pretty much. I've written the GEF
stuff and I've written RCP code that displays a simple window with an
"Open" command to load stuff in. Where's my entry point to my GEF code.
When I run my "Open" action, what class should it instantize etc.?
If you have files (resources API), register an editor on a file extension.
That's the easiest.
If you don't have files, you'll have to implement IEditorInput (for an
example, see below). Then, you can open the editor like this:
MyEditorInput myEditorInput = new MyEditorInput();
myEditorInput.setModelRoot(modelRoot);
window.getActivePage().openEditor(myEditorInput, MyGraphicalEditor.ID);
In your editor's setInput method, downcast to MyEditorInput and use
getModelRoot get your top-level model object.
public class MyEditorInput implements IEditorInput {
private MyModelRoot modelRoot;
public boolean exists() {
return true;
}
public ImageDescriptor getImageDescriptor() {
return ImageDescriptor.getMissingImageDescriptor();
}
public String getName() {
return "no name yet";
}
public IPersistableElement getPersistable() {
return null;
}
public String getToolTipText() {
return "no tooltip yet";
}
public Object getAdapter(Class adapter) {
return null;
}
public MyModelRoot getModelRoot() {
return modelRoot;
}
public void setModelRoot(MyModelRoot modelRoot) {
this.modelRoot=modelRoot;
}
}
Okay I've done that.
Now I've a problem. I've written the following code in my Action command
for "Open"
try
{
OverallModel model=new OverallModel(filename);
MyEditorInput mei=new MyEditorInput();
mei.setModelRoot(model);
window.getActivePage().openEditor(mei, MyEditor.ID);
System.out.println("Opened editor");
}
catch (Exception e)
{
e.printStackTrace();
}
However I get error "Unable to create part" (no other information given).
I've gathered that the constructor of the MyEditor class is getting
called and the init method is getting called but no other method is
getting called. I figure the critical methods are the ones relating to
the Graphical Viewer but those aren't getting touched.
Have no idea where to go from here. Any ideas?
Kevin.