Example usage for org.eclipse.jface.viewers TreePath hashCode

List of usage examples for org.eclipse.jface.viewers TreePath hashCode

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TreePath hashCode.

Prototype

public int hashCode(IElementComparer comparer) 

Source Link

Document

Returns a hash code computed from the hash codes of the segments, using the given comparer to compute the hash codes of the segments.

Usage

From source file:eu.modelwriter.marker.internal.MarkerFactory.java

License:Open Source License

/**
 * @param selections//ww  w.  j a  v a 2  s.  c o m
 * @return
 */
public static String getQualifiedName(final ITreeSelection selections) {
    final TreePath[] paths = selections.getPaths();

    // Consider only not empty and single selection
    if (selections.isEmpty() || selections.size() > 1) {
        return null;
    }

    final TreePath path = paths[0];
    IElementComparer comparer = null;
    if (selections instanceof TreeSelection) {
        comparer = ((TreeSelection) selections).getElementComparer();
    }
    System.out.println(path.hashCode(comparer));
    for (int i = 1; i < path.getSegmentCount(); i++) {
        if (path.getSegment(i) instanceof ResourceFactoryImpl) {
            final EcoreResourceFactoryImpl eResourceFactory = (EcoreResourceFactoryImpl) path.getSegment(i);
            System.out.println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
        } else if (path.getSegment(i) instanceof ENamedElement) {
            final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
            System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
        } else {
            System.out.println("?");
        }
    }
    return null;
}