Example usage for org.eclipse.jface.viewers IElementComparer equals

List of usage examples for org.eclipse.jface.viewers IElementComparer equals

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IElementComparer equals.

Prototype

boolean equals(Object a, Object b);

Source Link

Document

Compares two elements for equality

Usage

From source file:com.drgarbage.controlflowgraphfactory.actions.ActionUtils.java

License:Apache License

private static boolean reveal(PackageExplorerPart view, Object element) {
    if (view == null) {
        return false;
    }/*from ww  w .  java2  s . co  m*/
    view.selectReveal(new StructuredSelection(element));
    IElementComparer comparer = view.getTreeViewer().getComparer();
    Object selected = getSelectedElement(view);
    if (comparer != null ? comparer.equals(element, selected) : element.equals(selected)) {
        return true;
    }
    return false;
}

From source file:org.eclipse.jdt.internal.debug.ui.snippeteditor.ShowInPackageViewAction.java

License:Open Source License

private boolean reveal(PackageExplorerPart view, Object element) {
    if (view == null) {
        return false;
    }/*from w ww .ja v  a 2s  . co m*/
    view.selectReveal(new StructuredSelection(element));
    IElementComparer comparer = view.getTreeViewer().getComparer();
    Object selected = getSelectedElement(view);
    if (comparer != null ? comparer.equals(element, selected) : element.equals(selected)) {
        return true;
    }
    return false;
}

From source file:org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP.java

License:Open Source License

/**
 * Tries to select the given node in the given TreeViewer.
 * //from  w  w  w  . jav  a2  s .c  o m
 * @param o
 *            The Object to select
 * @param tv
 *            the TreeViewer
 * @return the object which should be selected if found in tree viewer, null
 *         otherwise
 */
public static Object selectNodeInTree(Object o, AbstractTreeViewer tv) {
    ISelection oldSelection = tv.getSelection();
    if (o != null) {
        tv.refresh();
        tv.expandToLevel(o, 0);
        tv.reveal(o);
        StructuredSelection newSelection = new StructuredSelection(o);
        tv.setSelection(newSelection);
        InteractionEventDispatcher.getDefault().fireProgammableSelectionEvent(newSelection);
        ISelection currSelection = tv.getSelection();
        if (currSelection instanceof StructuredSelection) {
            Object currObj = ((StructuredSelection) currSelection).getFirstElement();
            IElementComparer comparer = tv.getComparer();
            if (comparer != null) {
                if (comparer.equals(o, currObj)) {
                    return o;
                }
            } else {
                if (o.equals(currObj)) {
                    return o;
                }
            }
        }
    }
    tv.setSelection(oldSelection);
    return null;
}

From source file:org.eclipse.php.internal.ui.util.TreePath.java

License:Open Source License

public boolean equals(TreePath otherPath, IElementComparer comparer) {
    if (comparer == null)
        comparer = DefaultElementComparer.INSTANCE;
    if (otherPath == null)
        return false;
    if (fSegments.length != otherPath.fSegments.length)
        return false;
    for (int i = 0; i < fSegments.length; i++) {
        if (!comparer.equals(fSegments[i], otherPath.fSegments[i]))
            return false;
    }/*from  w ww . j a  v a2s.c  o  m*/
    return true;
}

From source file:org.eclipse.tcf.te.ui.views.internal.ViewViewerComparer.java

License:Open Source License

@Override
public boolean equals(Object a, Object b) {
    if (a == b)/*  ww w.j  av  a 2 s . c om*/
        return true;
    if (byDefault) {
        return a.equals(b);
    }
    IElementComparer comparer = (IElementComparer) Platform.getAdapterManager().getAdapter(a,
            IElementComparer.class);
    if (comparer == null) {
        comparer = (IElementComparer) Platform.getAdapterManager().getAdapter(b, IElementComparer.class);
    }
    if (comparer != null) {
        return comparer.equals(a, b);
    }
    return a.equals(b);
}

From source file:org.xmind.ui.viewers.CheckListViewer.java

License:Open Source License

/**
 * Returns the index of the given element in listMap, or -1 if the element
 * cannot be found. As of 3.3, uses the element comparer if available.
 * //from ww  w.jav a2 s .c  o m
 * @param element
 * @return the index
 */
protected int getElementIndex(Object element) {
    IElementComparer comparer = getComparer();
    if (comparer == null) {
        return listMap.indexOf(element);
    }
    int size = listMap.size();
    for (int i = 0; i < size; i++) {
        if (comparer.equals(element, listMap.get(i)))
            return i;
    }
    return -1;
}