Project

General

Profile

Revision 89ecaa7f

ID89ecaa7f4a952346be62de6cfaed27611a4f33fb
Parent ab56e292
Child 49c5c069

Added by Cherian Mathew about 8 years ago

added comparator for polytomous key list

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/PolytomousKeyContentProvider.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.navigation.key.polytomous;
5 5

  
6
import java.util.Collections;
7
import java.util.Comparator;
6 8
import java.util.List;
7 9

  
8 10
import org.eclipse.jface.viewers.IStructuredContentProvider;
......
27 29
	@Override
28 30
	public Object[] getElements(Object inputElement) {
29 31
		if(inputElement instanceof List){
32
			
33
			Collections.sort((List)inputElement,new PolytomousKeyComparator());
30 34
			return ((List) inputElement).toArray();
31 35
		}
32 36
		return null;
33 37
	}
38
	
39
	public class PolytomousKeyComparator implements Comparator<Object> {
40

  
41
		@Override
42
		public int compare(Object o1, Object o2) {
43
			if(o1 == null && o2 == null) {
44
				return 0;
45
			} else if (o1 == null) {
46
				return -1;
47
			} else if(o2 == null) {
48
				return +1;
49
			} else {
50
				return o1.toString().compareTo(o2.toString());
51
			}
52
		}
53
		
54
	}
34 55

  
35 56
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)