Project

General

Profile

« Previous | Next » 

Revision e7e642ee

Added by Patrick Plitzner about 3 years ago

ref #6774 Implement feature tree comparator

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/FeatureTreeViewerComparator.java
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.ViewerComparator;
14

  
15
import eu.etaxonomy.cdm.model.term.FeatureTree;
16

  
17
/**
18
 *
19
 * @author pplitzner
20
 * @since May 24, 2019
21
 *
22
 */
23
public class FeatureTreeViewerComparator extends ViewerComparator {
24

  
25
    @Override
26
    public int compare(Viewer viewer, Object e1, Object e2) {
27
        if(e1 instanceof FeatureTree && e2 instanceof FeatureTree) {
28
            return ((FeatureTree)e1).getTitleCache().toLowerCase().compareTo(((FeatureTree) e2).getTitleCache().toLowerCase());
29
        }
30
        return super.compare(viewer, e1, e2);
31
    }
32
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
10 10
package eu.etaxonomy.taxeditor.featuretree.e4;
11 11

  
12 12
import java.util.Arrays;
13
import java.util.Collections;
14 13
import java.util.HashMap;
15 14
import java.util.List;
16 15
import java.util.Map;
......
53 52
import eu.etaxonomy.cdm.model.term.FeatureTree;
54 53
import eu.etaxonomy.cdm.model.term.TermType;
55 54
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
55
import eu.etaxonomy.taxeditor.editor.definedterm.FeatureTreeViewerComparator;
56 56
import eu.etaxonomy.taxeditor.editor.definedterm.TermTransfer;
57 57
import eu.etaxonomy.taxeditor.featuretree.FeatureNodeTransfer;
58 58
import eu.etaxonomy.taxeditor.featuretree.FeatureTreeContentProvider;
......
136 136
        });
137 137

  
138 138
        List<FeatureTree> trees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
139
        Collections.sort(trees, (tree1, tree2) -> tree1.getTitleCache().compareTo(tree2.getTitleCache()));
139
        viewer.setComparator(new FeatureTreeViewerComparator());
140 140
        viewer.setInput(trees);
141 141

  
142 142
        //create context menu

Also available in: Unified diff