1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.editor.view.descriptive;
|
11
|
|
12
|
import org.eclipse.jface.viewers.Viewer;
|
13
|
import org.eclipse.jface.viewers.ViewerSorter;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
16
|
import eu.etaxonomy.taxeditor.model.DescriptionHelper;
|
17
|
|
18
|
/**
|
19
|
* @author n.hoffmann
|
20
|
* @created Dec 2, 2010
|
21
|
* @version 1.0
|
22
|
*/
|
23
|
public class DescriptiveViewerSorter extends ViewerSorter {
|
24
|
|
25
|
/* (non-Javadoc)
|
26
|
* @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
27
|
*/
|
28
|
@Override
|
29
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
30
|
if((e1 instanceof DescriptionElementBase) && (e2 instanceof DescriptionElementBase)){
|
31
|
return DescriptionHelper.getLabel((DescriptionElementBase)e1).compareTo(DescriptionHelper.getLabel((DescriptionElementBase)e2));
|
32
|
}
|
33
|
return super.compare(viewer, e1, e2);
|
34
|
}
|
35
|
|
36
|
}
|