Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] GEF editor inside Eclipse RCP

Hi Experts,
Im new to the world of RCP and also GEF.
Presently im trying to open a GEF editor inside Eclipse RCP application.
I have written an action which tries to open the gef editor in its run method.
I have also created my own editor input which implemnts IEditorInput interface via IPathEditorInput interface, as it was mentioned in the RCP tutorilas.
But the problem is that i want to open the gef editor without this input, as i dont have a input path to open the editor.
My question are
1)Is it mandatory to have an editor input.
2)Cant I open the gef editor without the input path? i just want to open an editor with pallete from the run method of the action class.
If yes then how ????

Below are the snap shot of the classes used.
-------------------------------------------------------------------
run method of the action class which open the editor.
 public void run() {
 IEditorInput input = new MyRCPEditorInput();          try {
            window.getActivePage().openEditor(input, MyRCPEditor.ID);
        } catch (PartInitException e) {
        }
   }
------------------------------------------------
Editor Class.
--------------------------------------------------------------
public class MyRCPEditor extends GraphicalEditorWithPalette {
    public static String ID = "com.rcp.core.actions.test.MyRCPEditor";
    private ContentsModel contentModel;
    public MyRCPEditor() {
        setEditDomain(new DefaultEditDomain(this));
    }
    protected void initializeGraphicalViewer() {
        GraphicalViewer viewer = getGraphicalViewer();
        ContentsModel parent = new ContentsModel();
        HelloModel child1 = new HelloModel();
        child1.setConstraint(new Rectangle(0, 0, -1, -1));
        parent.addChild(child1);
        HelloModel child2 = new HelloModel();
        child2.setConstraint(new Rectangle(30, 30, -1, -1));
        parent.addChild(child2);
        HelloModel child3 = new HelloModel();
        child3.setConstraint(new Rectangle(10, 80, 80, 50));
        parent.addChild(child3);
        viewer.setContents(parent);
    }
    public void doSave(IProgressMonitor monitor) {
    }
    public void doSaveAs() {
    }
    public void gotoMarker(IMarker marker) {
    }
    public boolean isDirty() {
        return false;
    }
    public boolean isSaveAsAllowed() {
        return false;
    }
    protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();
        GraphicalViewer viewer = getGraphicalViewer();
        viewer.setEditPartFactory(new MyEditPartFactory());
    }
    protected PaletteRoot getPaletteRoot() {
        PaletteRoot root = new PaletteRoot();
        PaletteGroup toolGroup = new PaletteGroup("");
        ToolEntry tool = new SelectionToolEntry();
        toolGroup.add(tool);
        root.setDefaultEntry(tool);
        tool = new MarqueeToolEntry();
        toolGroup.add(tool);
        PaletteDrawer drawer = new PaletteDrawer("Products");
        ImageDescriptor descriptor = ImageDescriptor.createFromFile(MyRCPEditor.class,
                "/icons/newModel.gif");
        CreationToolEntry creationEntry = new CreationToolEntry("TestEditor",
                "Adding Products", new SimpleFactory(HelloModel.class),
                descriptor, descriptor);
        drawer.add(creationEntry);
        root.add(toolGroup);
        root.add(drawer);
        return root;
    }
    @Override
    protected void setInput(IEditorInput input) {
        // TODO Auto-generated method stub
        super.setInput(input);
        MyRCPEditorInput rcpInput = ((MyRCPEditorInput) input);
        contentModel = rcpInput.getContentModel();
        setPartName(rcpInput.getName());
    }
}
------------------------------------------------------------------
Any help/suggestion will be great.
Thanks and Regards.
Ved


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

Back to the top