| Summary: | ArrayIndeOfBounds Exception on org.eclipse.zest.core.viewers.GraphViewer.findGraphItem(Object) | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | marco <marcodonati> |
| Component: | GEF-Legacy Zest | Assignee: | Ian Bull <irbull> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | critical | ||
| Priority: | P3 | CC: | ahunter.eclipse |
| Version: | 3.4 | ||
| Target Milestone: | 3.5.0 (Galileo) M3 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
The java doc for this method report this note: * Note: This method returns an internal interface (GraphItem). You should * be able to cast this to either a IGraphModelNode or IGraphModelConnection * (which are also internal). These are internal because this API is not * stable. If use this method (to access internal nodes and edges), your * code may not compile between versions. I think this method it would be public and returning non-internal classes or interfaces. tnx cheers Marco I think the code should be: return (result.length == 0 || !(result[0] instanceof GraphItem)) ? null : (GraphItem) result[0]; If the length is 0 or the item is not a GraphItem, return null, otherwise, return the item. The API problem is no longer an issue. |
This is the code: public GraphItem findGraphItem(Object element) { Widget[] result = findItems(element); return (result.length == 0 && result[0] instanceof GraphItem) ? null : (GraphItem) result[0]; } probably the Exception was throw because when result.length==0. I think it would be: public GraphItem findGraphItem(Object element) { Widget[] result = findItems(element); return (result.length == 0) ? null : (result[0] instanceof GraphItem) ? (GraphItem) result[0] : null; }