Project

General

Profile

Revision df366db5

IDdf366db549e422a21b550372b78a70b1f68f05a2
Parent bdcfdeab
Child 2ebeb1a9

Added by Katja Luther over 3 years ago

ref #4232: some more comparators to adapt

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/ReferenceSortProvider.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
22 22
public class ReferenceSortProvider extends AbstractSortProvider<Reference> {
23 23

  
24 24
	/**
25
	 * 
25
	 *
26 26
	 */
27 27
	public ReferenceSortProvider() {
28 28
		comparators.put("Type", new ReferenceTypeComparator());
......
30 30
	}
31 31

  
32 32
	private class ReferenceYearComparator implements Comparator<Reference> {
33
		
33

  
34 34
		/**
35 35
		 * @param o1
36 36
		 * @return
37 37
		 */
38 38
		private String getYearString(Reference o) {
39
			TimePeriod datePublished = o == null ? null : o.getDatePublished(); 
39
			TimePeriod datePublished = o == null ? null : o.getDatePublished();
40 40
			return datePublished == null? null : datePublished.toString();
41 41
		}
42
		
42

  
43 43
		/* (non-Javadoc)
44 44
		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
45 45
		 */
46
		public int compare(Reference o1, Reference o2) {
46
		@Override
47
        public int compare(Reference o1, Reference o2) {
47 48
			String yearString1 = getYearString(o1);
48 49
			String yearString2 = getYearString(o2);
49 50
			if (yearString1 == null) {
......
58 59
			}
59 60
			int returnVal = yearString1.compareToIgnoreCase(yearString2);
60 61
			if (returnVal == 0) {
61
				return new TitleCacheComparator<Reference>().compare(o1, o2);
62
			} else {
63
				return returnVal;
62
				returnVal = new TitleCacheComparator<Reference>().compare(o1, o2);
63

  
64 64
			}
65
		}		
65
			return returnVal;
66

  
67
		}
66 68
	}
67
	
69

  
68 70
	private class ReferenceTypeComparator implements Comparator<Reference> {
69
		
71

  
70 72
		/* (non-Javadoc)
71 73
		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
72 74
		 */
73
		public int compare(Reference o1, Reference o2) {
75
		@Override
76
        public int compare(Reference o1, Reference o2) {
74 77
			String typeString1 = o1.getClass().toString();
75 78
			String typeString2 = o2.getClass().toString();
76 79
			if (typeString1 == null) {
......
85 88
			}
86 89
			int returnVal = typeString1.compareToIgnoreCase(typeString2);
87 90
			if (returnVal == 0) {
91
			    //the TitleCacheComparator already fulfills the comparator contract
88 92
				return new TitleCacheComparator<Reference>().compare(o1, o2);
89 93
			} else {
90 94
				return returnVal;
91 95
			}
92
		}		
96
		}
93 97
	}
94 98

  
95
	
99

  
96 100
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/sortprovider/TitleCacheComparator.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
21 21
 * @version 1.0
22 22
 */
23 23
public class TitleCacheComparator<T extends IIdentifiableEntity> implements Comparator<T> {
24
	
24

  
25 25
    private boolean fIgnoreCase;
26 26

  
27 27
	private String getTitleCache(T o) {
28 28
		return o == null ? null : o.getTitleCache();
29 29
	}
30
	
30

  
31 31
	/* (non-Javadoc)
32 32
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
33 33
	 */
34 34
	/** {@inheritDoc} */
35
	public int compare(T o1, T o2) {
35
	@Override
36
    public int compare(T o1, T o2) {
36 37
		String titleCache1 = getTitleCache(o1);
37 38
		String titleCache2 = getTitleCache(o2);
38 39
		if (titleCache1 == null && titleCache2 == null) {
......
43 44
		}
44 45
		if (titleCache2 == null) {
45 46
			return 1;
46
		}				
47
        return fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) : 
47
		}
48
        int result =  fIgnoreCase ? titleCache1.compareToIgnoreCase(titleCache2) :
48 49
        						titleCache1.compareTo(titleCache2);
50

  
51
        if (result == 0){
52
            result = o1.getUuid().compareTo(o2.getUuid());
53
        }
54
        return result;
49 55
	}
50 56
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
342 342
	}
343 343

  
344 344

  
345
	class ReferencingClassComparator implements Comparator<CdmBase> {
345
	class ReferencingClassComparator implements Comparator<CdmBase>   {
346 346

  
347 347
		@Override
348 348
        public int compare(CdmBase o1, CdmBase o2) {
349 349
			String string1 = o1.getClass().getSimpleName();
350 350
			String string2 = o2.getClass().getSimpleName();
351
			int classCompare = string1.compareToIgnoreCase(string2);
352
			if (classCompare == 0) {
351
			int result = string1.compareToIgnoreCase(string2);
352
			if (result == 0) {
353 353
				string1 = DescriptionHelper.getObjectDescription(o1);
354 354
				string2 = DescriptionHelper.getObjectDescription(o2);
355 355

  
356
				return string1.compareToIgnoreCase(string2);
357
			} else {
358
				return classCompare;
356
				result = string1.compareToIgnoreCase(string2);
357
				if (result == 0){
358
				    return o1.getUuid().compareTo(o2.getUuid());
359
				}
359 360
			}
361
				return result;
360 362
		}
361 363
	}
362 364

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenu.java
170 170
	private class SortByTermTypeMessage implements Comparator<TermType> {
171 171
	    @Override
172 172
        public int compare(TermType t1, TermType t2) {
173
	        return t1.getMessage().compareTo(t2.getMessage());
173
	        if (t1.equals(t2)){
174
	            return 0;
175
	        }
176
	        int result = t1.getMessage().compareTo(t2.getMessage());
177
	        if (result == 0){
178
	            return t1.compareTo(t2);
179
	        }
180
	        return result;
174 181
	    }
175 182
	}
176 183

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ExportToFileDestinationWizardPage.java
68 68
	public static final String XML = "xml";
69 69

  
70 70
	public static final String CSV = "csv";
71
	
72
	
71

  
72

  
73 73

  
74 74
	public static final String ZIP = "zip";
75 75

  
76 76
    private static boolean csvExport = false;
77
    
77

  
78 78
    private static boolean csvNameExport = false;
79 79

  
80 80
	private static String CSV_PRINT_EXPORT ="CSV_PRINT_EXPORT";
......
91 91
	private final String extension;
92 92

  
93 93
    private Combo classificationSelectionCombo;
94
    
94

  
95 95
    private List<Classification> classifications;
96
    
96

  
97 97
    private Classification selectedClassification;
98 98

  
99 99
	/**
......
190 190
                "Export the contents of the currently selected database into Comma Separated Value format.",
191 191
                CSV);
192 192
    }
193
    
193

  
194 194
    /**
195 195
     * @return
196 196
     */
......
203 203
                "Export the names of the currently selected database into Semicolon Separated Value format.",
204 204
                CSV);
205 205
    }
206
    
206

  
207 207
    /**
208 208
     * @return
209 209
     */
......
240 240

  
241 241
                @Override
242 242
                public int compare(Classification o1, Classification o2) {
243
                    return o1.getTitleCache().compareTo(o2.getTitleCache());
243
                    if (o1.equals(o2)){
244
                        return 0;
245
                    }
246
                    int result = o1.getTitleCache().compareTo(o2.getTitleCache());
247
                    if (result == 0){
248
                        return o1.getUuid().compareTo(o2.getUuid());
249
                    }
250
                    return result;
244 251
                }
245 252
            });
246
			
253

  
247 254
			selectedClassification = classifications.iterator().next();
248 255
		}
249 256

  
......
251 258
		if(csvExport || csvPrintExport){
252 259
		    Label comboBoxLabel = new Label(composite, SWT.NONE);
253 260
		    comboBoxLabel.setText("Classification");
254
		   
261

  
255 262
		    createClassificationSelectionCombo(composite);
256 263
		    classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
257 264
		                true, false, 2, 1));
258 265
		}
259
		
260
		
266

  
267

  
261 268

  
262 269

  
263 270
		Label fileLabel = new Label(composite, SWT.NONE);
......
385 392
	@Override
386 393
	public void widgetSelected(SelectionEvent e) {
387 394
		selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
388
		
395

  
389 396
	}
390 397

  
391 398
	@Override
392 399
	public void widgetDefaultSelected(SelectionEvent e) {
393 400
		//not needed here
394
		
401

  
395 402
	}
396 403

  
397 404
	public UUID getSelectedClassificationUUID() {
398
		
405

  
399 406
		return selectedClassification.getUuid();
400 407
	}
401 408

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/GenericConfiguratorWizardPage.java
137 137
             */
138 138
            @Override
139 139
            public int compare(Method o1, Method o2) {
140
                if (o1.equals(o2)){
141
                    return 0;
142
                }
140 143
                if(o1.getName()==null && o2.getName()!=null){
141 144
                    return -1;
142 145
                }
......
144 147
                    return 1;
145 148
                }
146 149
                if(o1.getName()==null && o2.getName()==null){
147
                    return 0;
150
                    return o1.toString().compareTo(o1.toString());
151
                }
152
                int result = o1.getName().compareTo(o2.getName());
153
                if (result == 0){
154
                    return o1.toString().compareTo(o1.toString());
148 155
                }
149
                return o1.getName().compareTo(o2.getName());
156
                return result;
150 157
            }
151 158
        });
152 159

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DefaultTermComparator.java
1 1
/**
2 2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
17 17
 * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
18 18
 * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
19 19
 * list will be alphabetically  sorted by label afterwards.
20
 * 
20
 *
21 21
 * @author n.hoffmann
22 22
 * @date Jan 18, 2012
23 23
 *
......
36 36
		}
37 37
		String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
38 38
		String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();
39
		return label1.compareTo(label2);
39
		int result = label1.compareTo(label2);
40
		if (result == 0){
41
		    return o1.getUuid().compareTo(o2.getUuid());
42
		}
43
		return result;
40 44
	}
41 45
};
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/FeatureNodeContainerTree.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
37 37

  
38 38
		@Override
39 39
		public int compare(DescriptionElementBase o1, DescriptionElementBase o2) {
40
			return DescriptionHelper.getLabel(o1).compareTo(DescriptionHelper.getLabel(o2));
40
		    if (o1.equals(o2)){
41
		        return 0;
42
		    }
43
			int result = DescriptionHelper.getLabel(o1).compareTo(DescriptionHelper.getLabel(o2));
44
			if (result == 0){
45
			    return o1.getUuid().compareTo(o2.getUuid());
46
			}
47
			return result;
41 48
		}
42 49
	};
43
	
50

  
44 51
	private Set<FeatureNodeContainer> featureNodeContainers = new HashSet<FeatureNodeContainer>();
45
	
52

  
46 53
	private FeatureNodeContainer root;
47 54
	private DescriptionBase description;
48 55
	private FeatureTree featureTree;
49
	
56

  
50 57
	public FeatureNodeContainerTree(DescriptionBase description, FeatureTree featureTree){
51 58
		this.description = description;
52 59
		this.featureTree = featureTree;
53
		
60

  
54 61
		root = new FeatureNodeContainer(this);
55
		
62

  
56 63
		buildTree();
57 64
	}
58
	
65

  
59 66
	/**
60 67
	 * Traverses the given {@link FeatureNode} and computes a FeatureNodeContainer branch if the
61 68
	 * given {@link TaxonDescription} has elements for the given feature node or any of its children
......
63 70
	 */
64 71
	public void buildTree(){
65 72
		List<FeatureNode> children = featureTree.getRootChildren();
66
		
73

  
67 74
//		if(description.getElements().isEmpty()){
68 75
//			return;
69 76
//		}
70
		
77

  
71 78
		for(FeatureNode featureNode : children){
72 79
			root.findLeaves(featureNode);
73 80
		}
74 81
	}
75
	
82

  
76 83
	/**
77 84
	 * <p>getFeatureNodeContainerForDescriptionElement</p>
78 85
	 *
......
81 88
	 */
82 89
	public FeatureNodeContainer getFeatureNodeContainerForDescriptionElement (DescriptionElementBase descriptionElement) {
83 90
		List<FeatureNodeContainer> leafs = root.getLeafs();
84
		
91

  
85 92
		for(FeatureNodeContainer container : leafs){
86 93
			if(container.getDescriptionElements().contains(descriptionElement)){
87 94
				return container;
......
89 96
		}
90 97
		return null;
91 98
	}
92
	
99

  
93 100
	/**
94 101
	 * Returns all elements contained in the given {@link DescriptionBase description} that have the given {@link Feature feature}.
95
	 * 
102
	 *
96 103
	 * @param description
97 104
	 * @param feature
98 105
	 * @return a list of description elements with the given feature alphabetically sorted by {@link DescriptionHelper#getLabel(Object)}
99 106
	 */
100 107
	public List<DescriptionElementBase> getDescriptionsElementsForFeature(Feature feature) {
101 108
		List<DescriptionElementBase> featureElements = new ArrayList<DescriptionElementBase>();
102
		
109

  
103 110
		Set<DescriptionElementBase> elements = description.getElements();
104
		
111

  
105 112
		if (elements != null) {
106 113
			for (DescriptionElementBase element : elements) {
107
				Feature elementFeature = (Feature) HibernateProxyHelper.deproxy(element.getFeature());
108
				
114
				Feature elementFeature = HibernateProxyHelper.deproxy(element.getFeature());
115

  
109 116
				if (feature.equals(elementFeature)) {
110 117
					featureElements.add(element);
111 118
				}
112 119
			}
113 120
		}
114
		
121

  
115 122
		if(featureElements.size() != 0){
116 123
			Collections.sort(featureElements, comparator);
117 124
		}
118
		
125

  
119 126
		return featureElements;
120 127
	}
121
	
122
	
123
	public FeatureNodeContainer getFeatureNodeContainer(Feature feature) {		
128

  
129

  
130
	public FeatureNodeContainer getFeatureNodeContainer(Feature feature) {
124 131
		List<FeatureNodeContainer> leafs = root.getLeafs();
125
		
132

  
126 133
		for(FeatureNodeContainer container : leafs){
127 134
			if(container.getFeature().equals(feature)){
128 135
				return container;
......
130 137
		}
131 138
		return null;
132 139
	}
133
	
140

  
134 141
	public FeatureNodeContainer getFeatureNodeContainer(FeatureNode featureNode){
135 142
		List<FeatureNodeContainer> leafs = root.getLeafs();
136
		
143

  
137 144
		for(FeatureNodeContainer container : leafs){
138 145
			if(container.getFeatureNode().equals(featureNode)){
139 146
				return container;
......
141 148
		}
142 149
		return null;
143 150
	}
144
	
151

  
145 152
	public void addContainer(FeatureNodeContainer container){
146 153
		featureNodeContainers.add(container);
147 154
	}
148 155

  
149 156
	/**
150
	 * 
157
	 *
151 158
	 */
152 159
	public void removeContainer(FeatureNodeContainer container) {
153 160
		featureNodeContainers.remove(container);
154 161
	}
155
	
162

  
156 163
	public FeatureNodeContainer getRoot() {
157 164
		return root;
158 165
	}
......
164 171
	public FeatureTree getFeatureTree() {
165 172
		return featureTree;
166 173
	}
167
	
174

  
168 175
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmEnumSelectionDialog.java
49 49

  
50 50
	private ConversationHolder conversation;
51 51

  
52
	protected List<T> model;	
53
	private String settings;	
54
	
55
	
56
	
52
	protected List<T> model;
53
	private String settings;
54

  
55

  
56

  
57 57
	/**
58 58
	 * <p>Constructor for AbstractFilteredCdmResourceSelectionDialog.</p>
59 59
	 *
60 60
	 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
61
	 * @param conversation 
61
	 * @param conversation
62 62
	 * @param title a {@link java.lang.String} object.
63 63
	 * @param multi a boolean.
64 64
	 * @param settings a {@link java.lang.String} object.
65 65
	 * @param cdmEnum a T object.
66 66
	 * @param <T> a T object.
67 67
	 */
68
	protected AbstractFilteredCdmEnumSelectionDialog(Shell shell, 
69
			ConversationHolder conversation, 
70
			String title, 
71
			boolean multi, 
68
	protected AbstractFilteredCdmEnumSelectionDialog(Shell shell,
69
			ConversationHolder conversation,
70
			String title,
71
			boolean multi,
72 72
			String settings,
73 73
			T cdmEnum) {
74 74
		super(shell, multi);
75 75
		setTitle(title);
76 76
		setMessage("Use * for wildcard, or ? to see all entries");
77 77
		this.settings = settings;
78
		
78

  
79 79
		this.conversation = conversation;
80
		
80

  
81 81
		init();
82
		
82

  
83 83
		initModel();
84
		
84

  
85 85
		String objectTitle = getTitle(cdmEnum);
86 86
		if (objectTitle != null) {
87 87
			setInitialPattern(objectTitle);
88 88
		}
89
		
89

  
90 90
		setListLabelProvider(createListLabelProvider());
91 91
		setDetailsLabelProvider(createDetailsLabelProvider());
92
		
92

  
93 93
		setSelectionHistory(new ResourceSelectionHistory());
94 94
	}
95
	
95

  
96 96
	/**
97 97
	 * By default, we are returning the standard list label provider
98
	 * 
99
	 * Override in subclasses if you want different behavior 
100
	 * 
98
	 *
99
	 * Override in subclasses if you want different behavior
100
	 *
101 101
	 * @return
102 102
	 */
103 103
	protected ILabelProvider createDetailsLabelProvider() {
......
105 105
	}
106 106

  
107 107
	/**
108
	 * 
108
	 *
109 109
	 * @return
110 110
	 */
111 111
	protected ILabelProvider createListLabelProvider() {
......
117 117
	 * Will run before initModel()
118 118
	 */
119 119
	protected void init() {
120
		
120

  
121 121
	}
122
	
122

  
123 123
	/**
124 124
	 * <p>getSelectionFromDialog</p>
125 125
	 *
......
128 128
	 * @return a TYPE object.
129 129
	 */
130 130
	protected static <TYPE extends IEnumTerm> TYPE getSelectionFromDialog(AbstractFilteredCdmEnumSelectionDialog<TYPE> dialog) {
131
		
131

  
132 132
		int result = dialog.open();
133
		
133

  
134 134
		if (result == Window.CANCEL) {
135 135
			return null;
136 136
		}
137
		
137

  
138 138
		return dialog.getSelectedEnumTerm();
139 139
	}
140 140

  
......
148 148
	protected String getTitle(T cdmEnum) {
149 149
		return cdmEnum.getMessage();
150 150
	}
151
	
151

  
152 152

  
153 153
	/** {@inheritDoc} */
154 154
	@Override
155 155
	public void refresh() {
156
		initModel();		
156
		initModel();
157 157
		super.refresh();
158 158
	}
159
	
159

  
160 160
	/**
161 161
	 * <p>initModel</p>
162 162
	 */
......
177 177
			public boolean equalsFilter(ItemsFilter filter) {
178 178
				return false;
179 179
			}
180
			
180

  
181 181
			@Override
182 182
			public boolean isConsistentItem(Object item) {
183 183
				return false;
......
193 193
				}
194 194
				return text != null ? matches(text) : false;
195 195
			}
196
			
196

  
197 197
		};
198 198
	}
199
	
199

  
200 200

  
201 201
	/**
202 202
	 * Set the filter input to the Agent's title cache
......
204 204
	 * @param cdmObject a T object.
205 205
	 */
206 206
	protected void setPattern(T cdmObject) {
207
		// FilteredSelection does some very tricky caching to make sure it 
208
		// runs with high performance. 
207
		// FilteredSelection does some very tricky caching to make sure it
208
		// runs with high performance.
209 209
		// This works for most use cases, but we want to change the model while the dialog is open
210 210
		// and all the clever caching prevents the content provider from knowing that the model has changed
211
		// I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient 
211
		// I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
212 212
		// way to solve the problem.
213 213
		try {
214 214
			Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
......
223 223
		} catch (IllegalAccessException e) {
224 224
			MessagingUtils.error(getClass(), e);
225 225
		}
226
		
227
		// this also is not the nicest way to do it. 
226

  
227
		// this also is not the nicest way to do it.
228 228
		// I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
229 229
		// once it was opened. Am I doing it wrong?
230 230
		String pattern = getTitle(cdmObject);
231 231
		((Text) getPatternControl()).setText(pattern);
232 232
	}
233
	
233

  
234 234
	/* (non-Javadoc)
235 235
	* @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
236 236
	*/
......
240 240
		ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
241 241
		throws CoreException {
242 242
		try {
243
			if(model != null){				
243
			if(model != null){
244 244
				progressMonitor.beginTask("Looking for entities", model.size());
245 245
				for(T element : model){
246 246
					contentProvider.add(element, itemsFilter);
......
288 288
	@Override
289 289
	protected Comparator getItemsComparator() {
290 290
		return new Comparator<IEnumTerm>() {
291
			public int compare(IEnumTerm entity1,
291
			@Override
292
            public int compare(IEnumTerm entity1,
292 293
					IEnumTerm entity2) {
293
				Collator collator = Collator.getInstance();
294
				return collator.compare(entity1.getMessage(), entity2.getMessage());
294
				if (entity1.equals(entity2)){
295
				    return 0;
296
				}
297
			    Collator collator = Collator.getInstance();
298

  
299
				int result = collator.compare(entity1.getMessage(), entity2.getMessage());
300
				if (result == 0){
301
				    return entity1.getUuid().compareTo(entity2.getUuid());
302
				}
303
				return result;
295 304
			}
296 305
		};
297 306
	}
......
304 313
	protected IStatus validateItem(Object item) {
305 314
		return Status.OK_STATUS;
306 315
	}
307
	
316

  
308 317
	/**
309 318
	 * <p>getSelectedUuidAndTitleCache</p>
310 319
	 *
......
314 323
		Object[] result = getResult();
315 324
		return result[0] == null ? null : (T) result[0];
316 325
	}
317
	
326

  
318 327
	/**
319 328
	 * <p>Getter for the field <code>settings</code>.</p>
320 329
	 *
......
326 335
		}
327 336
		return settings;
328 337
	}
329
	
338

  
330 339
	/**
331
	 * 
340
	 *
332 341
	 * @author n.hoffmann
333 342
	 * @created Oct 19, 2009
334 343
	 * @version 1.0
......
337 346
	    /*
338 347
	    * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
339 348
	   	*/
340
		protected Object restoreItemFromMemento(IMemento element) {
349
		@Override
350
        protected Object restoreItemFromMemento(IMemento element) {
341 351
			return element.getString("resource"); //$NON-NLS-1$
342 352
	  	}
343 353
	  	/*
344 354
	  	 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
345 355
	  	 *      org.eclipse.ui.IMemento)
346 356
	  	 */
347
		protected void storeItemToMemento(Object item, IMemento element) {
357
		@Override
358
        protected void storeItemToMemento(Object item, IMemento element) {
348 359
			element.putString("resource", item.toString()); //$NON-NLS-1$
349 360
		}
350 361
	}
351
	
362

  
352 363
	/**
353 364
	 * <p>getNewWizardLinkText</p>
354 365
	 *
355 366
	 * @return a {@link java.lang.String} object.
356 367
	 */
357 368
	protected abstract String getNewWizardLinkText();
358
	
369

  
359 370
	/**
360 371
	 * <p>getNewEntityWizard</p>
361
	 * @param parameter 
372
	 * @param parameter
362 373
	 * @return a {@link eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard} object.
363 374
	 */
364 375
	protected abstract AbstractNewEntityWizard getNewEntityWizard(String parameter);
365
	
376

  
366 377
	public class FilteredCdmResourceLabelProvider extends LabelProvider {
367
		public String getText(Object element) {
378
		@Override
379
        public String getText(Object element) {
368 380
			if (element == null) {
369 381
				return null;
370 382
			}
371 383
			return ((IEnumTerm) element).getMessage();
372
		}			
384
		}
373 385
	};
374 386

  
375 387
	/* (non-Javadoc)
......
386 398
		}
387 399
		return null;
388 400
	}
389
	
401

  
390 402
	protected SelectionListener getNewWizardLinkSelectionListener(){
391 403
		return new SelectionAdapter() {
392
			
404

  
393 405
			/* (non-Javadoc)
394 406
			 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
395 407
			 */
396 408
			@Override
397 409
			public void widgetSelected(SelectionEvent e) {
398
				
410

  
399 411
				AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
400 412
				wizard.init(null, null);
401 413
				WizardDialog dialog = new WizardDialog(getShell(), wizard);
402 414
				int status = dialog.open();
403
				
415

  
404 416
				if (status == IStatus.OK) {
405
					
417

  
406 418
					T entity = (T) wizard.getEntity();
407 419

  
408 420
					refresh();
......
412 424
			}
413 425
		};
414 426
	}
415
	
427

  
416 428
	/**
417 429
	 * <p>getConversationHolder</p>
418 430
	 *
419 431
	 * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
420 432
	 */
421
	public ConversationHolder getConversationHolder() {
433
	@Override
434
    public ConversationHolder getConversationHolder() {
422 435
		return conversation;
423 436
	}
424
	
437

  
425 438
	/** {@inheritDoc} */
426
	public void update(CdmDataChangeMap changeEvents) {}
439
	@Override
440
    public void update(CdmDataChangeMap changeEvents) {}
427 441

  
428 442
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
140 140

  
141 141
                @Override
142 142
                public int compare(Classification o1, Classification o2) {
143
                    return o1.getTitleCache().compareTo(o2.getTitleCache());
143
                    if (o1.equals(o2)){
144
                        return 0;
145
                    }
146
                    int result = o1.getTitleCache().compareTo(o2.getTitleCache());
147
                    if (result == 0){
148
                        return o1.getUuid().compareTo(o2.getUuid());
149
                    }
150
                    return result;
144 151
                }
145 152
            });
146 153
			if (this.cdmBaseToBeFiltered == null){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)