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

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