[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Starting with a non empty Editor

Well, EditPartFactory should be set in:

protected void configureGraphicalViewer()
        {...}

rest of it is ok :)

Greg


Mirco Dunker wrote:
Hi Greg,
thx for your answer. At the moment I try this

 protected void initializeGraphicalViewer() {
        getGraphicalViewer().setEditPartFactory(new MyEditPartFactory());
        getGraphicalViewer().setContents(rootElement);
 }

Is this not correct?
Greeting Mirco

Well, how about this:

protected void initializeGraphicalViewer()
         {
         getGraphicalViewer.setContents(getDiagram());
         }

in YourEditorCalss.java :)

getDiagram() return diagram with elements in it.

Good luck ;)

Greg

Mirco Dunker wrote:

Hello,
I have a GEF-Tutorial that works fine and I can start with an empty editor so I can compose diagrams. But I want to start a non empty editor. If I create a new editor instance I want to have one of my model elements on this editor. But it doesn't work. My idear was to change this:
public class MyGraphicalEditor extends GraphicalEditorWithPalette {
[...]
protected void setInput(IEditorInput input) {
super.setInput(input);
IFile file = (IFile) input.getAdapter(IResource.class);
try {
InputStream is = file.getContents();
if (is.available() == 0) { rootElement = new RootElement();
//Adding the model element that should be shown
modelElement = new modelElement();
rootElement.addModelElement(modelElement);
} else {
ObjectInputStream ois = new ObjectInputStream(is);
rootElement = (RootElement) ois.readObject();
}
} catch (Exception e) {
[...]
}
}
[...]
When I start a new editor it contains only the root element. What have I to do that my model element is shown?
Greeting Mirco