Community
Participate
Working Groups
In Eclipse 3.2, the SWT StructuredViewer was enhanced to support mapping of data objects to TreeItems through an elementMap. This elementMap was specifically added in order to support a one-to-many mapping where the same data item is shown multiple times in the tree. For reference, see the Javadoc for StructuredViewer#findItems(Object element): http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/StructuredViewer.html#findItems(java.lang.Object) This is exactly the kind of use-case that's needed by the RSE SystemView. Migrating the SystemView to this new SWT concept will help to reduce code, improve performance (through faster item lookups), and make the whole SystemView more configurable because the element comparer is exchangeable. Supposedly, the following changes are required: 1.) In the SystemView constructors, call setUseHashlookup(true) 2.) In order to properly compare elements by both "absoluteName" and object, set a comparer: setComparer(new IElementComparer() { boolean equals(Object a, Object b) { if(a==b) return true; if(a==null || b==null) return false; if(a.equals(b)) return true; IRemoteObjectIdentifier identa; if(a instanceof IRemoteObjectIdentifier) { identa = ((IRemoteObjectIdentifier)a).getAbsoluteName(); } else if(a instanceof IAdaptable) { identa = (IRemoteObjectIdentifier) ((IAdaptable)a).getAdapter(IRemoteObjectIdentifier.class); } if(identa != null) { IRemoteObjectIdentifier identb; if(b instanceof IRemoteObjectIdentifier) { identb = ((IRemoteObjectIdentifier)b).getAbsoluteName(); } else if(b instanceof IAdaptable) { identb = (IRemoteObjectIdentifier) ((IAdaptable)b).getAdapter(IRemoteObjectIdentifier.class); } if(identa.equals(identb)) return true; } return false; } int hashCode(Object element) { IRemoteObjectIdentifier ident=null; if(element instanceof IRemoteObjectIdentifier) { ident = (IRemoteObjectIdentifier)element; String absName = ident.getAbsoluteName(); if(absName!=null) return absName.hashCode(); return element.hashCode(); } if(element instanceof IAdaptable) { ident = (IRemoteObjectIdentifier) ((IAdaptable)b).getAdapter(IRemoteObjectIdentifier.class); if(ident!=null) { String absName = ident.getAbsoluteName(); if(absName!=null) return absName.hashCode(); return ident.hashCode(); } } return element.hashCode(); } }); 3.) Get rid of methods recursiveFindAllRemoteItemReferences() and similar, using StructuredViewer.findElements() wherever possible
Please consider for M6. It's not only for performance and extensibility, but also brings us closer to the Eclipse Platform, so it might help migrating SystemView to other good concepts from the Platform like the Virtual Treeviewer, or the Asynchronous Treeviewer (currently in debug.internal but planned to become API)
SystemView now makes use of the elementMap where possible and falls back to recursive methods where the map fails.
[target cleanup] 2.0 M6 was the original target milestone for this bug