Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 224116

Summary: Zest Graph throws IndexOutOfBoundsException when clearing selection after highlighting nodes and edges
Product: [Tools] GEF Reporter: GianMaria Romanato <gm.romanato>
Component: GEF-Legacy ZestAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse
Version: 3.3.1   
Target Milestone: 3.5.0 (Galileo) M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Snippet to reproduce the prolem
none
org.eclipse.zest.core
none
mylyn/context/zip none

Description GianMaria Romanato CLA 2008-03-26 10:52:00 EDT
Created attachment 93610 [details]
Snippet to reproduce the prolem

Build ID: M20071023-1652

Steps To Reproduce:
1. Run the included snippet (modified from a Zest sample)
2. Click over a graph node
3. Click any place in the white area around the graph


More information:
This bug may be rejected as I am using a CVS snaphsot of org.eclipse.zest in Eclipse 3.3.1.1  M20071023-1652 which is is probably an unsupported configuration, but I'm reporting the problem anyway hoping that this information may be useful. 

Use the attached snippet (modified from a zest sample), run it and when the graph shows up, first click over a graph node, then click any point in the white area. You will get an IndexOutOfBoundsException. The exception does not show up if you DO NOT highlight nodes AND edges.


The stack trace: 
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: -2, Size: 21
at java.util.ArrayList.add(Unknown Source)
at org.eclipse.zest.core.widgets.internal.ZestRootLayer.unHighlightNode(ZestRootLayer.java:110)
at org.eclipse.zest.core.widgets.Graph.unhighlightNode(Graph.java:790)
at org.eclipse.zest.core.widgets.GraphNode.unhighlight(GraphNode.java:486)
at org.eclipse.zest.core.widgets.Graph.clearSelection(Graph.java:702)
at org.eclipse.zest.core.widgets.Graph.access$3(Graph.java:697)
at org.eclipse.zest.core.widgets.Graph$DragSupport.mousePressed(Graph.java:636)
at org.eclipse.draw2d.Figure.handleMousePressed(Figure.java:873)
at org.eclipse.draw2d.SWTEventDispatcher.dispatchMousePressed(SWTEventDispatcher.java:214)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseDown(LightweightSystem.java:513)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:178)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
at org.eclipse.mylar.zest.examples.jface.GraphJFaceSnippet3.main(GraphJFaceSnippet3.java:131)
Comment 1 Ian Bull CLA 2008-06-17 01:25:35 EDT
Created attachment 105132 [details]
org.eclipse.zest.core

fix.
Comment 2 Ian Bull CLA 2008-06-17 01:25:40 EDT
Created attachment 105133 [details]
mylyn/context/zip
Comment 3 Ian Bull CLA 2008-06-17 01:27:16 EDT
Thanks for finding this. It looks like I am calling highlight twice on the node.  The first time when you programmatically call it, and then on the selection.  If a node is already highlighted, it should not be highlighted again.

This patch should fix that. I would like to do a bit more testing before I commit this.
Comment 4 Ian Bull CLA 2008-06-17 01:49:11 EDT
patch committed.