Bug 231950 - NPE when using connection handles and the Palette is hidden
Summary: NPE when using connection handles and the Palette is hidden
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.0 (Ganymede) RC2   Edit
Assignee: James Bruck CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-05-13 17:44 EDT by James Bruck CLA
Modified: 2008-09-18 13:47 EDT (History)
3 users (show)

See Also:


Attachments
proposed patch. (1.91 KB, patch)
2008-05-13 17:45 EDT, James Bruck CLA
no flags Details | Diff
takes into account the tool from the palette root. (2.40 KB, patch)
2008-05-14 15:40 EDT, James Bruck CLA
ahunter.eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Bruck CLA 2008-05-13 17:44:06 EDT
If the Palette is hidden (i.e. on fast view) and a connection handle is used to create sn Edge, than a null pointer will be thrown because getPaletteViewer() returns null.  From this point on, nothing in the diagram is selectable until the diagram is closed and re-opened.



Below is the stack trace:

java.lang.NullPointerException
at org.eclipse.gef.EditDomain.loadDefaultTool(EditDomain.java:188)
at org.eclipse.gef.tools.AbstractTool.handleFinished(AbstractTool.java:692)
at org.eclipse.gmf.runtime.diagram.ui.tools.ConnectionCreationTool.handleFinished(ConnectionCreationTool.java:199)
at org.eclipse.gmf.runtime.diagram.ui.tools.ConnectionCreationTool.handleButtonUp(ConnectionCreationTool.java:187)
at org.eclipse.gmf.runtime.diagram.ui.internal.tools.ConnectionHandleTool.handleButtonUp(ConnectionHandleTool.java:132)
Comment 1 James Bruck CLA 2008-05-13 17:45:54 EDT
Created attachment 100064 [details]
proposed patch.
Comment 2 Randy Hudson CLA 2008-05-14 11:57:48 EDT
If there is a palette root but no palette viewer, shouldn't the palette root still determine what the default tool is?
Comment 3 James Bruck CLA 2008-05-14 15:00:59 EDT
... possibly. The current patch fixes my issue but I may be overlooking some other problem?   I will create another patch that tries to use the palette root.
- James.
Comment 4 James Bruck CLA 2008-05-14 15:40:25 EDT
Created attachment 100284 [details]
takes into account the tool from the palette root.
Comment 5 James Bruck CLA 2008-05-14 15:42:40 EDT
I've attached a second patch ... perhaps there is a way of "beautifying" it some more but it seems to be logically separated.  The first part sets the pallete viewer information and the second part sets the default tool.

I'm not sure if the second patch is really necessary.   Please feel free to modify the patch any way you see fit.
Comment 6 Anthony Hunter CLA 2008-05-15 14:21:12 EDT
Are we sure that this entry is correct? We say that the paletteView is null but the paletteRoot is not. 

setActiveTool(paletteRoot.getDefaultEntry().createTool());

I think James' original patch was correct, there is no visible palette so there is no active tool. setActiveTool(null) is correct in this case.
Comment 7 James Bruck CLA 2008-05-15 15:52:47 EDT
Randy, Anthony, you guys know way more about GEF than I do so whichever patch seems better is fine with me.  They both fix the issue.   

I was hoping this might be delivered during the RC stage of Ganymede since the NPE is a serious customer issue, basically preventing a user from continuing working with a diagram.
Comment 8 Randy Hudson CLA 2008-05-15 22:10:42 EDT
(In reply to comment #6)
> Are we sure that this entry is correct? We say that the paletteView is null but
> the paletteRoot is not.

Maybe someone wants to display a paletteRoot inside a Toolbar or something?? I guess it's safe to say no one is doing this yet though or they'd be seeing the original problem.
Comment 9 Nicolas Rousseau CLA 2008-05-25 23:22:28 EDT
I got the same problem since quite a long time now, thought first it could be a bug of the application, and not GEF...

And there is no palette in the toolbar or anything else like this.
Connections are created via a context menu, so we never use directly the palette to create the connections.

All of this worked well before we switch to eclipse 3.3 and gef 3.2.100.v20070620.
Bug appeared on both Windows & Linux.
Comment 10 Anthony Hunter CLA 2008-05-26 12:38:51 EDT
Committed the first patch to HEAD
Comment 11 Nicolas Rousseau CLA 2008-05-26 21:15:31 EDT
I don't know if a fix is planned also for version 3.3 ?

I don't especially want to change to eclipse 3.4 especially for this fix.

Thanks
Comment 12 Anthony Hunter CLA 2008-05-27 09:24:57 EDT
This will not be pushed back to a 3.3 release. There are only two maintenance releases for 3.3: Sept 2007 and Feb 2008.