Bug 138608 [Viewers] JFace AbstractTreeViewer: itemExists doesn't handle equal tree entries
I use a TreeViewer with - setUseHashLookup(true) - without any sorter or filter - with a comparer When I try to add an object that is equal to an existing entry in the tree, it will not be added. This is because the method private boolean itemExists(Item[] items, Object element) { if(usingElementMap()) { return findItem(element) != null; } for (int i = 0; i < items.length; i++) { if(items[i].getData().equals(element)) { return true; } } return false; } takes a shortcut if there is an element map, but the shortcut doesn't handle the 'multiple equal elements' case. There is a workaround, however: Setting a dummy sorter will avoid the call to itemExists and multiple equal elements can be added to the tree.
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
}
    /**
     * Expands all nodes of the viewer's tree, starting with the root. This
     * method is equivalent to <code>expandToLevel(ALL_LEVELS)</code>.
     */
    public void expandAll() {
        expandToLevel(ALL_LEVELS);
    }
    /**
     * Expands the root of the viewer's tree to the given level.
     * 
     * @param level
     *           non-negative level, or <code>ALL_LEVELS</code> to expand all
     *           levels of the tree
     */
    public void expandToLevel(int level) {
        expandToLevel(getRoot(), level);
    }
    /**
     * Expands all ancestors of the given element or tree path so that the given element
     * becomes visible in this viewer's tree control, and then expands the
     * subtree rooted at the given element to the given level.
     * 
     * @param elementOrTreePath
     *           the element
     * @param level
     *           non-negative level, or <code>ALL_LEVELS</code> to expand all
     *           levels of the tree
     */
    public void expandToLevel(Object elementOrTreePath, int level) {