No figure drawn for EditPart [message #217369] |
Sat, 03 June 2006 06:47 |
Eclipse User |
|
|
|
Originally posted by: rahulrevo.gmail.com
Hi,
I am a newbie and needed help while creating a basic GEF editor.
I want to create a new editor for java files. The custom editor is opened
with the palette, but there is no Figure drawn. I have copied the
important parts of the code below.
CodeBrowserEditor where the model is an ICompilationUnit
protected void setInput(IEditorInput input) {
super.setInput(input);
IFile file = ((IFileEditorInput) input).getFile();
compilationUnit = JavaCore.createCompilationUnitFrom(file);
setPartName(compilationUnit.getElementName());
}
protected void initializeGraphicalViewer() {
super.initializeGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
viewer.setContents(compilationUnit); // set the contents of this editor
}
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new CompilationUnitEditPartFactory());
viewer.setRootEditPart(new ScalableFreeformRootEditPart());
}
CompilationUnitEditPartFactory
public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof ICompilationUnit) {
EditPart editPart = new CompilationUnitEditPart();
editPart.setModel(model);
return editPart;
}
}
CompilationUnitEditPart
protected IFigure createFigure() {
IFigure layer = new FreeformLayer();
layer.setBorder(new MarginBorder(3));
layer.setLayoutManager(new FreeformLayout());
IFigure rectangle = new RectangleFigure();
rectangle.setOpaque(true); // non-transparent figure
rectangle.setBackgroundColor(ColorConstants.green);
layer.add(rectangle);
return layer;
}
protected void createEditPolicies() {
}
protected void refreshVisuals() {
}
createFigure in CompilationUnitEditPart is called, but nothing is drawn.
Thanks for your help
Rahul
|
|
|
Powered by
FUDForum. Page generated in 0.10024 seconds