Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Getting NPE using GEF?
Getting NPE using GEF? [message #145842] Sun, 01 August 2004 01:47 Go to next message
Marc Boorshtein is currently offline Marc BoorshteinFriend
Messages: 24
Registered: July 2009
Junior Member
I am using GEF to build a tree like structure by creating a custom
draw2d figure and adding new figures to a "contents" in the parent
figure. I then use an EditPart to create the child figure in the
createFigure method and then I add it to the parent in the
refreshVisuals method. The getChildren method returns object that will
generate an instance of the same editorpart as it's parent from the
factory. The first level works ok, but i get the following NPE when I
add a second level:

!ENTRY org.eclipse.ui 4 0 Jul 31, 2004 20:36:55.832
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
at org.eclipse.draw2d.FigureCanvas.layoutViewport(FigureCanvas. java:214)
at org.eclipse.draw2d.FigureCanvas.access$4(FigureCanvas.java:2 06)
at
org.eclipse.draw2d.FigureCanvas$3.notifyValidating(FigureCan vas.java:171)
at org.eclipse.draw2d.UpdateManager.fireValidating(UpdateManage r.java:93)
at
org.eclipse.draw2d.DeferredUpdateManager.validateFigures(Def erredUpdateManager.java:228)
at
org.eclipse.draw2d.DeferredUpdateManager.performUpdate(Defer redUpdateManager.java:132)
at
org.eclipse.draw2d.DeferredUpdateManager$UpdateRequest.run(D eferredUpdateManager.java:57)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:106)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:2748)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2538)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:668 )
at org.eclipse.jface.window.Window.open(Window.java:648)
at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java: 257)
at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog. java:319)
at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog. java:285)
at org.eclipse.ui.internal.Workbench$13.run(Workbench.java:1099 )
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:615)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1029)
at
org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConfigurer.java:167)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:652)
at org.eclipse.ui.internal.Workbench.init(Workbench.java:819)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1325)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:254)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:335)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
at org.eclipse.core.launcher.Main.run(Main.java:644)
at org.eclipse.core.launcher.Main.main(Main.java:628)


Does anyone know what this could be a symptom of?

Thanks!
Re: Getting NPE using GEF? [message #145871 is a reply to message #145842] Sun, 01 August 2004 15:48 Go to previous message
Eclipse UserFriend
Originally posted by: rlemaigr.ulb.ac.be

Hello,

> I am using GEF to build a tree like structure by creating a custom =

> draw2d figure and adding new figures to a "contents" in the parent =

> figure.

> I then use an EditPart to create the child figure in the createFigure =
=

> method and then I add it to the parent in the refreshVisuals method.

Maybe the problem is there ?

You must not add yourself the figure to the contentpane of the parent
EditPart in the refreshVisuals method. All the refreshVisuals method
has to do is updating the properties of the (already created and added
to the parent content pane) EditPart's Figure to match
the current state of the EditPart's model object.

GEF adds itself the IFigure returned by createFigure() to the content pa=
ne
of the parent EditPart when it is needed (when the EditPart is created).=



Maybe you already know this (sorry if you do) :

By overriding the refreshVisuals and createFigure methods in a child =

EditPart,
you provide GEF all the information it has to know to create and update =
=

(update
is done once by GEF just after the Figure is created) the Figure of that=
=

child
EditPart.

By overriding the getModelChildren, getContentPane in a parent EditPart,=

(and by implementing the EditPartFactory), you provide GEF all the =

information
it has to know to build the children of the parent EditPart, and where
it must put their Figures.

With these methods implemented, GEF has all it has to know to build the
view/controllers trees by itself, you must not do that yourself (like =

adding
a Figure to its content pane or adding an EditPart to its parent,etc.).

hope this will help,

r=E9gis


> The getChildren method returns object that will generate an instance o=
f =

> the same editorpart as it's parent from the factory. The first level =
=

> works ok, but i get the following NPE when I add a second level:
>
> !ENTRY org.eclipse.ui 4 0 Jul 31, 2004 20:36:55.832
> !MESSAGE java.lang.NullPointerException
> !STACK 0
> java.lang.NullPointerException
> at org.eclipse.draw2d.FigureCanvas.layoutViewport(FigureCanvas. java:2=
14)
> at org.eclipse.draw2d.FigureCanvas.access$4(FigureCanvas.java:2 06)
> at =

> org.eclipse.draw2d.FigureCanvas$3.notifyValidating(FigureCan vas.java:1=
71)
> at =

> org.eclipse.draw2d.UpdateManager.fireValidating(UpdateManage r.java:93)=

> at =

> org.eclipse.draw2d.DeferredUpdateManager.validateFigures(Def erredUpdat=
eManager.java:228)
> at =

> org.eclipse.draw2d.DeferredUpdateManager.performUpdate(Defer redUpdateM=
anager.java:132)
> at =

> org.eclipse.draw2d.DeferredUpdateManager$UpdateRequest.run(D eferredUpd=
ateManager.java:57)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at =

> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.jav=
a:106)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:2748=
)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2538)=

> at org.eclipse.jface.window.Window.runEventLoop(Window.java:668 )
> at org.eclipse.jface.window.Window.open(Window.java:648)
> at org.eclipse.jface.dialogs.ErrorDialog.open(ErrorDialog.java: 257)
> at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog. java:3=
19)
> at org.eclipse.jface.dialogs.ErrorDialog.openError(ErrorDialog. java:2=
85)
> at org.eclipse.ui.internal.Workbench$13.run(Workbench.java:1099 )
> at =

> org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatfor=
m.java:615)
> at org.eclipse.core.runtime.Platform.run(Platform.java:747)
> at org.eclipse.ui.internal.Workbench.restoreState(Workbench.jav a:1029=
)
> at =

> org.eclipse.ui.internal.WorkbenchConfigurer.restoreState(Wor kbenchConf=
igurer.java:167)
> at =

> org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvis=
or.java:652)
> at org.eclipse.ui.internal.Workbench.init(Workbench.java:819)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1325)
> at =

> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java=
:254)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:14=
1)
> at =

> org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:96)=

> at =

> org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActi=
vator.java:335)
> at =

> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.jav=
a:273)
> at =

> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.jav=
a:129)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at =

> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.j=
ava:39)
> at =

> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccess=
orImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:183)
> at org.eclipse.core.launcher.Main.run(Main.java:644)
> at org.eclipse.core.launcher.Main.main(Main.java:628)
>
>
> Does anyone know what this could be a symptom of?
>
> Thanks!
>



-- =

Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Previous Topic:Logic Example Documentation
Next Topic:attributes in Properties view don't appear for new objects
Goto Forum:
  


Current Time: Tue Jul 23 11:28:25 GMT 2024

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

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

Back to the top