Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » NullPointerException in AbstractEditPart.getRoot()
NullPointerException in AbstractEditPart.getRoot() [message #118524] Fri, 20 February 2004 13:24 Go to next message
Eclipse UserFriend
Originally posted by: daniel_nospam.enigmatec.net

Hi all,

I'm getting the above when I create a child EditPart following instructions
elsewhere in this newsgroup. The trace is as follows:

java.lang.NullPointerException
at org.eclipse.gef.editparts.AbstractEditPart.getRoot
(AbstractEditPart.java:575)
at org.eclipse.gef.editparts.AbstractEditPart.getRoot
(AbstractEditPart.java:575)
at org.eclipse.gef.editparts.AbstractEditPart.getViewer
(AbstractEditPart.java:627)
at org.eclipse.gef.editparts.AbstractEditPart.registerModel
(AbstractEditPart.java:788)
at org.eclipse.gef.editparts.AbstractEditPart.register
(AbstractEditPart.java:768)
at org.eclipse.gef.editparts.AbstractEditPart.addNotify
(AbstractEditPart.java:213)
at org.eclipse.gef.editparts.AbstractEditPart.addChild
(AbstractEditPart.java:182)
at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren
(AbstractEditPart.java:739)
at org.eclipse.gef.editparts.AbstractEditPart.refresh
(AbstractEditPart.java:691)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh
(AbstractGraphicalEditPart.java:519)
at org.eclipse.gef.editparts.AbstractConnectionEditPart.refresh
(AbstractConnectionEditPart.java:203)
at org.eclipse.gef.editparts.AbstractConnectionEditPart.setTarg et
(AbstractConnectionEditPart.java:271)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
(AbstractGraphicalEditPart.java:671)
at org.eclipse.gef.editparts.AbstractEditPart.removeNotify
(AbstractEditPart.java:881)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
(AbstractGraphicalEditPart.java:672)
at org.eclipse.gef.editparts.AbstractEditPart.removeChild
(AbstractEditPart.java:822)
at
org.eclipse.gef.editparts.FreeformGraphicalRootEditPart.setC ontents
(FreeformGraphicalRootEditPart.java:145)
at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents
(AbstractEditPartViewer.java:350)


It seems to happen when getRoot() is called in the parent EditPart, after
being called by the child's getRoot() (hence the two getRoots above).

I'm adding children by overriding the getModelChildren() and createChild()
methods.

It's as if the child is being configured before its parent, which it is
dependent on for this configuration.

I've seen similar issues with removeNotify(). I tried this workaround
(overriding removeNotify and only calling once) but no joy.

Viewing the stack trace in the debugger, it seems that this occurs when a
connection is removed and the setTarget() method on
AbstractConnectionEditPart is called with null. But this ends up trying to
add a child in refreshChildren()!? I think I must be ommitting to do
something when I create the child.

Hope this may provoke some memories!

Dan
Re: NullPointerException in AbstractEditPart.getRoot() [message #118530 is a reply to message #118524] Fri, 20 February 2004 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel_nospam.enigmatec.net

Yes, I see now, it seems to be adding a new child when the
refreshChildren() method is called, because I've overriden
getModelChildren() and createChild(). Maybe I should put some test code
in here, or ovverride refreshChildren()...

Dan Gravell <daniel_nospam@enigmatec.net> wrote in
news:Xns949588F128E01danielnospamenigmate@204.138.98.10:

> Hi all,
>
> I'm getting the above when I create a child EditPart following
> instructions elsewhere in this newsgroup. The trace is as follows:
>
> java.lang.NullPointerException
> at org.eclipse.gef.editparts.AbstractEditPart.getRoot
> (AbstractEditPart.java:575)
> at org.eclipse.gef.editparts.AbstractEditPart.getRoot
> (AbstractEditPart.java:575)
> at org.eclipse.gef.editparts.AbstractEditPart.getViewer
> (AbstractEditPart.java:627)
> at org.eclipse.gef.editparts.AbstractEditPart.registerModel
> (AbstractEditPart.java:788)
> at org.eclipse.gef.editparts.AbstractEditPart.register
> (AbstractEditPart.java:768)
> at org.eclipse.gef.editparts.AbstractEditPart.addNotify
> (AbstractEditPart.java:213)
> at org.eclipse.gef.editparts.AbstractEditPart.addChild
> (AbstractEditPart.java:182)
> at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren
> (AbstractEditPart.java:739)
> at org.eclipse.gef.editparts.AbstractEditPart.refresh
> (AbstractEditPart.java:691)
> at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh
> (AbstractGraphicalEditPart.java:519)
> at org.eclipse.gef.editparts.AbstractConnectionEditPart.refresh
> (AbstractConnectionEditPart.java:203)
> at org.eclipse.gef.editparts.AbstractConnectionEditPart.setTarg et
> (AbstractConnectionEditPart.java:271)
> at
> org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
> (AbstractGraphicalEditPart.java:671)
> at org.eclipse.gef.editparts.AbstractEditPart.removeNotify
> (AbstractEditPart.java:881)
> at
> org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
> (AbstractGraphicalEditPart.java:672)
> at org.eclipse.gef.editparts.AbstractEditPart.removeChild
> (AbstractEditPart.java:822)
> at
> org.eclipse.gef.editparts.FreeformGraphicalRootEditPart.setC ontents
> (FreeformGraphicalRootEditPart.java:145)
> at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents
> (AbstractEditPartViewer.java:350)
>
>
> It seems to happen when getRoot() is called in the parent EditPart,
> after being called by the child's getRoot() (hence the two getRoots
> above).
>
> I'm adding children by overriding the getModelChildren() and
> createChild() methods.
>
> It's as if the child is being configured before its parent, which it
> is dependent on for this configuration.
>
> I've seen similar issues with removeNotify(). I tried this workaround
> (overriding removeNotify and only calling once) but no joy.
>
> Viewing the stack trace in the debugger, it seems that this occurs
> when a connection is removed and the setTarget() method on
> AbstractConnectionEditPart is called with null. But this ends up
> trying to add a child in refreshChildren()!? I think I must be
> ommitting to do something when I create the child.
>
> Hope this may provoke some memories!
>
> Dan
>
Re: NullPointerException in AbstractEditPart.getRoot() [message #118850 is a reply to message #118530] Mon, 23 February 2004 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel_nospam.enigmatec.net

To anyone in a similar position - I fixed this by overriding getModel()
in my child EditPart and returned the string I used in getModelChildren()
to identify the EditPart. This meant the parent recognised it.

Cheers, Dan

Dan Gravell <daniel_nospam@enigmatec.net> wrote in
news:Xns9495898EF8CF1danielnospamenigmate@204.138.98.10:

> Yes, I see now, it seems to be adding a new child when the
> refreshChildren() method is called, because I've overriden
> getModelChildren() and createChild(). Maybe I should put some test code
> in here, or ovverride refreshChildren()...
>
> Dan Gravell <daniel_nospam@enigmatec.net> wrote in
> news:Xns949588F128E01danielnospamenigmate@204.138.98.10:
>
>> Hi all,
>>
>> I'm getting the above when I create a child EditPart following
>> instructions elsewhere in this newsgroup. The trace is as follows:
>>
>> java.lang.NullPointerException
>> at org.eclipse.gef.editparts.AbstractEditPart.getRoot
>> (AbstractEditPart.java:575)
>> at org.eclipse.gef.editparts.AbstractEditPart.getRoot
>> (AbstractEditPart.java:575)
>> at org.eclipse.gef.editparts.AbstractEditPart.getViewer
>> (AbstractEditPart.java:627)
>> at org.eclipse.gef.editparts.AbstractEditPart.registerModel
>> (AbstractEditPart.java:788)
>> at org.eclipse.gef.editparts.AbstractEditPart.register
>> (AbstractEditPart.java:768)
>> at org.eclipse.gef.editparts.AbstractEditPart.addNotify
>> (AbstractEditPart.java:213)
>> at org.eclipse.gef.editparts.AbstractEditPart.addChild
>> (AbstractEditPart.java:182)
>> at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren
>> (AbstractEditPart.java:739)
>> at org.eclipse.gef.editparts.AbstractEditPart.refresh
>> (AbstractEditPart.java:691)
>> at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh
>> (AbstractGraphicalEditPart.java:519)
>> at org.eclipse.gef.editparts.AbstractConnectionEditPart.refresh
>> (AbstractConnectionEditPart.java:203)
>> at org.eclipse.gef.editparts.AbstractConnectionEditPart.setTarg et
>> (AbstractConnectionEditPart.java:271)
>> at
>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
>> (AbstractGraphicalEditPart.java:671)
>> at org.eclipse.gef.editparts.AbstractEditPart.removeNotify
>> (AbstractEditPart.java:881)
>> at
>> org.eclipse.gef.editparts.AbstractGraphicalEditPart.removeNo tify
>> (AbstractGraphicalEditPart.java:672)
>> at org.eclipse.gef.editparts.AbstractEditPart.removeChild
>> (AbstractEditPart.java:822)
>> at
>> org.eclipse.gef.editparts.FreeformGraphicalRootEditPart.setC ontents
>> (FreeformGraphicalRootEditPart.java:145)
>> at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents
>> (AbstractEditPartViewer.java:350)
>>
>>
>> It seems to happen when getRoot() is called in the parent EditPart,
>> after being called by the child's getRoot() (hence the two getRoots
>> above).
>>
>> I'm adding children by overriding the getModelChildren() and
>> createChild() methods.
>>
>> It's as if the child is being configured before its parent, which it
>> is dependent on for this configuration.
>>
>> I've seen similar issues with removeNotify(). I tried this workaround
>> (overriding removeNotify and only calling once) but no joy.
>>
>> Viewing the stack trace in the debugger, it seems that this occurs
>> when a connection is removed and the setTarget() method on
>> AbstractConnectionEditPart is called with null. But this ends up
>> trying to add a child in refreshChildren()!? I think I must be
>> ommitting to do something when I create the child.
>>
>> Hope this may provoke some memories!
>>
>> Dan
>>
>
Re: NullPointerException in AbstractEditPart.getRoot() [message #119030 is a reply to message #118850] Mon, 23 February 2004 16:40 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The editpart factory should have set this "fake model" as the editpart's
model.

"Dan Gravell" <daniel_nospam@enigmatec.net> wrote in message
news:Xns94986FA0F7E8Cdanielnospamenigmate@204.138.98.10...
> To anyone in a similar position - I fixed this by overriding getModel()
> in my child EditPart and returned the string I used in getModelChildren()
> to identify the EditPart. This meant the parent recognised it.
>
> Cheers, Dan
Previous Topic:[Draw2D] Suggestions for implementing a non-right click popup
Next Topic:Bug in Polygon/PointList?
Goto Forum:
  


Current Time: Sat Dec 21 17:08:10 GMT 2024

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

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

Back to the top