Project

General

Profile

Download (1.31 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2018 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.editor.definedterm;
11

    
12
import org.eclipse.jface.viewers.Viewer;
13
import org.eclipse.jface.viewers.ViewerSorter;
14

    
15
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
16

    
17
/**
18
 * @author pplitzner
19
 * @date 13.02.2018
20
 *
21
 */
22
public class DefinedTermSorter extends ViewerSorter {
23

    
24
    @Override
25
    public int compare(Viewer viewer, Object e1, Object e2) {
26
        // the comparison value in this method determines the
27
        // location <-> add term method used in the MoveDefinedTermOperation
28
        // execute call
29
        if(e1 instanceof OrderedTermBase && e2 instanceof OrderedTermBase) {
30
            OrderedTermBase otbe1 = (OrderedTermBase)e1;
31
            OrderedTermBase otbe2 = (OrderedTermBase)e2;
32
            if(otbe1.getOrderIndex() == otbe2.getOrderIndex()) {
33
                return 0;
34
            } else if (otbe1.getOrderIndex() < otbe2.getOrderIndex()){
35
                return -1;
36
            } else{
37
                return 1;
38
            }
39
        } else {
40
            return super.compare(viewer, e1, e2);
41
        }
42
    }
43
}
(5-5/9)