Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » GEF editor in Eclipse RCP
GEF editor in Eclipse RCP [message #218780] Sat, 01 July 2006 09:57
Eclipse User
Originally posted by: vedgunjan.yahoo.com

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
Previous Topic:Unhandled event loop exception --> java.lang.NullPointerException
Next Topic:How see root figure image through transparent child
Goto Forum:
  


Current Time: Wed Oct 22 08:02:57 GMT 2014

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

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