2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.combo
;
11 import java
.util
.Comparator
;
13 import eu
.etaxonomy
.cdm
.model
.reference
.OriginalSourceBase
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.OriginalSourceType
;
17 * @author pplitzner, k.luther
21 * Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp.
22 * PrimaryMediaSource which are always on top depending on the IdentifiableSource;
24 * The last two are always "Other" followed by "Unknown"
29 public class OriginalSourceTypeComparator
implements Comparator
<OriginalSourceType
>{
31 private OriginalSourceBase entity
;
33 public OriginalSourceTypeComparator(OriginalSourceBase entity
) {
41 public int compare(OriginalSourceType o1
, OriginalSourceType o2
) {
53 //both are either taxonomic or media
54 else if(o1
.equals(OriginalSourceType
.PrimaryTaxonomicSource
)
55 && o2
.equals(OriginalSourceType
.PrimaryMediaSource
)){
56 if(entity
!= null && entity
.getType().equals(OriginalSourceType
.PrimaryMediaSource
)){
63 else if(o2
.equals(OriginalSourceType
.PrimaryTaxonomicSource
)
64 && o1
.equals(OriginalSourceType
.PrimaryMediaSource
)){
65 if(entity
!= null && entity
.getType().equals(OriginalSourceType
.PrimaryMediaSource
)){
72 //one is not taxonomic or media
73 else if(o1
.equals(OriginalSourceType
.PrimaryTaxonomicSource
)
74 ||o1
.equals(OriginalSourceType
.PrimaryMediaSource
)){
78 else if(o2
.equals(OriginalSourceType
.PrimaryTaxonomicSource
)
79 || o2
.equals(OriginalSourceType
.PrimaryMediaSource
)){
82 //The last two are always "Other" followed by "Unknown"
83 else if(o1
.equals(OriginalSourceType
.Other
)){
84 if(o2
.equals(OriginalSourceType
.Unknown
)){
91 if(o2
.equals(OriginalSourceType
.Other
)){
95 String message1
= o1
.getKey();
96 String message2
= o2
.getKey();
97 return message1
.compareTo(message2
);