Example usage for org.eclipse.jface.util Util compare

List of usage examples for org.eclipse.jface.util Util compare

Introduction

In this page you can find the example usage for org.eclipse.jface.util Util compare.

Prototype

public static <T extends Comparable<? super T>> int compare(final List<T> left, final List<T> right) 

Source Link

Document

Compares two lists -- account for null.

Usage

From source file:org.embl.cca.utils.ui.view.filenavigator.FileSystemComparator.java

License:Apache License

public int compare(final Viewer viewer, final Object e1, final Object e2) {
    if (sort.equals(FileSortType.ALPHA_NUMERIC_DIRS_FIRST)) {
        final int cat1 = category(e1);
        final int cat2 = category(e2);
        if (cat1 != cat2)
            return cat1 - cat2;
    }//from w  w  w  .  j  a v  a2s . com
    final FileSystemEntryNode fn1 = (FileSystemEntryNode) e1;
    final FileSystemEntryNode fn2 = (FileSystemEntryNode) e2;
    switch (sort) {
    case ALPHA_NUMERIC:
    case ALPHA_NUMERIC_DIRS_FIRST:
        return Util.compare(fn1.getName(), fn2.getName());
    case SIZE: //TODO Sort the nulls at biggest: in current compare, those are least
        return Util.compare(fn1.getSize(), fn2.getSize());
    }
    return 0;
}