Skip to main content



      Home
Home » Eclipse Projects » GEF » NPE in CreationTool
NPE in CreationTool [message #160806] Tue, 07 December 2004 10:44 Go to next message
Eclipse UserFriend
Hi all,

i actually get a NPE in CreationTool#handleButtonDown(int) when i want to
place an Element from my Palette to my GraphicalViewer and the creation
should not be allowed (this is done by my onw EditPolicy -
getTargetEditPart is overwritten and returns null in some cases). So the
targetEditPart in TargetingTool is null and in
CreationTool.handleButtonDown the line:
helper = (SnapToHelper)getTargetEditPart().getAdapter(SnapToHelper.cl ass);
throws the NPE because the method getTargetEditPart() returns null.

Is this a bug or i am wrong in use of the EditPolicy and the
targetEditPart should always be set and the Creation of an EditPart and
the corresponding model element should be disabled in the CreateCommand?

thanks for help

PS: In GEF 2.1.2 it has worked fine but now i have GEF 3.0 and the NPE was
thrown.
Re: NPE in CreationTool [message #160833 is a reply to message #160806] Tue, 07 December 2004 11:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Lamont_Gilbert.rigidsoftware.com

Donald Mehlhorn wrote:
> Hi all,
>
> i actually get a NPE in CreationTool#handleButtonDown(int) when i want
> to place an Element from my Palette to my GraphicalViewer and the
> creation should not be allowed (this is done by my onw EditPolicy -
> getTargetEditPart is overwritten and returns null in some cases). So the
> targetEditPart in TargetingTool is null and in
> CreationTool.handleButtonDown the line:
> helper = (SnapToHelper)getTargetEditPart().getAdapter(SnapToHelper.cl ass);
> throws the NPE because the method getTargetEditPart() returns null.
>
> Is this a bug or i am wrong in use of the EditPolicy and the
> targetEditPart should always be set and the Creation of an EditPart and
> the corresponding model element should be disabled in the CreateCommand?
>
> thanks for help
>
> PS: In GEF 2.1.2 it has worked fine but now i have GEF 3.0 and the NPE
> was thrown.
>

the editpart should alwasy be set. If there is no selection the parent
editpart is returned. You can filter it out in the Command if need be.

--
Respectfully,


CL Gilbert

"Verily, verily, I say unto you, He that entereth not by the door() into
the sheepfold{}, but climbeth up some other *way, the same is a thief
and a robber."

GnuPG Key Fingerprint:
82A6 8893 C2A1 F64E A9AD 19AE 55B2 4CD7 80D2 0A2D

For a free Java interface to Freechess.org see
http://www.rigidsoftware.com/Chess/chess.html
Re: NPE in CreationTool [message #160888 is a reply to message #160806] Tue, 07 December 2004 13:07 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Open a bugzilla. getTargetEditPart may return null, in which case we are
supposed to check for it.

"Donald Mehlhorn" <medo@hrz.tu-chemnitz.de> wrote in message
news:cp4j42$63m$1@www.eclipse.org...
> Hi all,
>
> i actually get a NPE in CreationTool#handleButtonDown(int) when i want to
> place an Element from my Palette to my GraphicalViewer and the creation
> should not be allowed (this is done by my onw EditPolicy -
> getTargetEditPart is overwritten and returns null in some cases). So the
> targetEditPart in TargetingTool is null and in
> CreationTool.handleButtonDown the line:
> helper = (SnapToHelper)getTargetEditPart().getAdapter(SnapToHelper.cl ass);
> throws the NPE because the method getTargetEditPart() returns null.
>
> Is this a bug or i am wrong in use of the EditPolicy and the
> targetEditPart should always be set and the Creation of an EditPart and
> the corresponding model element should be disabled in the CreateCommand?
>
> thanks for help
>
> PS: In GEF 2.1.2 it has worked fine but now i have GEF 3.0 and the NPE was
> thrown.
>
Previous Topic:Multi selection and Properties View
Next Topic:Moving Figure
Goto Forum:
  


Current Time: Sun Jun 15 15:58:11 EDT 2025

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

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

Back to the top