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

Bug 237152

Summary: Graph#setSelection() doesn't work for GraphContainer objects
Product: [Tools] GEF Reporter: Stefan Tucker <stefan.tucker>
Component: GEF-Legacy ZestAssignee: Ian Bull <irbull>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: 3.5.0 (Galileo) M4   
Hardware: PC   
OS: Windows Server 2003   
Whiteboard:

Description Stefan Tucker CLA 2008-06-13 16:09:02 EDT
Build ID: I20080523-0100

Steps To Reproduce:
1. Create a GraphContainer object and add it to a Graph.

2. Call Graph#setSelection(new GraphNode[] { container });

3. Note that setSelection() highlights only objects that return GraphItem.NODE from getItemType().


More information:
Graph.java:
	public void setSelection(GraphItem[] nodes) {
		clearSelection();
		if (nodes != null) {
			for (int i = 0; i < nodes.length; i++) {
				if (nodes[i] != null && nodes[i].getItemType() == GraphItem.NODE) {
					selectedItems.add(nodes[i]);
					((GraphNode) nodes[i]).highlight();
				}
			}
		}
	}

Should probably be:

	public void setSelection(GraphItem[] nodes) {
		clearSelection();
		if (nodes != null) {
			for (int i = 0; i < nodes.length; i++) {
				if ((nodes[i] != null) && (nodes[i] instanceof GraphNode)) {
					selectedItems.add(nodes[i]);
					((GraphNode) nodes[i]).highlight();
				}
			}
		}
	}
Comment 1 Ian Bull CLA 2008-11-20 13:50:24 EST
Thanks,

Fixed.