NullPointer Exception During initializeGraphicalViewer [message #528126] |
Mon, 19 April 2010 12:52 |
Chris Messages: 44 Registered: April 2010 |
Member |
|
|
Hi,
I'm currently working on a graphical editor for Eclipse (surprise!).
I tried to follow Elias Volanakis' ShapeEditor example as close as applicable for my task.
I wanted to have a very simple basis on which to expand later on:
The editor (simple window, no pallette required), the document model, one dummy document element and the corresponding EditPart and View. For reasons of simplicity, I did not concern myself with connections, yet. In my model there is only a list of rectangles with position and size, nothing else.
I set up the Model/EditPart/View infrastructure to the best of my knowlegde and then wanted to integrate it all into the editor. But during the initializeGraphicalViewer method there happens a nullpointer exception when registering the loaded diagram model to the viewer using setModel().
@Override
protected void initializeGraphicalViewer() {
GraphicalViewer viewer = getGraphicalViewer();
viewer.setContents(getModel()); // set the contents of this editor
//TODO: listen for dropped stuff
}
The stack trace is the following:
Quote: |
java.lang.NullPointerException
at org.eclipse.gef.editparts.AbstractEditPart.registerModel(Abs tractEditPart.java:777)
at org.eclipse.gef.editparts.AbstractEditPart.register(Abstract EditPart.java:757)
at org.eclipse.gef.editparts.FreeformGraphicalRootEditPart.regi ster(FreeformGraphicalRootEditPart.java:233)
at org.eclipse.gef.editparts.ScalableFreeformRootEditPart.regis ter(ScalableFreeformRootEditPart.java:150)
at org.eclipse.gef.editparts.AbstractEditPart.addNotify(Abstrac tEditPart.java:229)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotif y(AbstractGraphicalEditPart.java:219)
at org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:198)
at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
at edu.rwth.hci.codegestalt.editor.CgtEditor.initializeGraphica lViewer(CgtEditor.java:69)
at org.eclipse.gef.ui.parts.GraphicalEditor.createGraphicalView er(GraphicalEditor.java:153)
at org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:662)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:462)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:595)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:271)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1417)
at org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:942)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3506)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbe nch.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3885)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3506)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
|
As far as I can determine, the document was loaded fine and the model looks ok in the debugger (empty as the document, but not null).
I checked the model and the Editor in both my plug-in and the sample during runtime in the various stages of initialization (constructor, configureGraphicalViewer, initializeGraphicalViewer) and I could not find anything suspicious until the exception hits me.
It would be great to get any tips and insight on how to proceed from here.
Regards,
Chris
|
|
|
|
Powered by
FUDForum. Page generated in 0.03280 seconds