Project

General

Profile

Revision bdcfdeab

IDbdcfdeab3e40b432992c487a829d1ad0d1133884
Parent fc758deb
Child df366db5

Added by Katja Luther over 3 years ago

ref #4232: adapt comparator of filteredSelection dialogs to fulfill the comparator contract

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java
365 365
			public int compare(UuidAndTitleCache entity1,
366 366
					UuidAndTitleCache entity2) {
367 367
				Collator collator = Collator.getInstance();
368
				return collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
368
				if (entity1.getUuid().equals(entity2.getUuid())){
369
				    return 0;
370
				}
371
				int result = collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
372
				if (result == 0){
373
				    result = entity1.getUuid().compareTo(entity2.getUuid());
374
				}
375
				return result;
369 376
			}
370 377
		};
371 378
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java
193 193
			@Override
194 194
			public int compare(UuidAndTitleCache entity1,
195 195
					UuidAndTitleCache entity2) {
196

  
197
			    if (entity1.getUuid().equals(entity2.getUuid())){
198
			        return 0;
199
			    }
196 200
				Collator collator = Collator.getInstance();
197 201
				String compareString1 = "";
198 202
				if (entity1.getAbbrevTitleCache() != null){
......
212 216
				}
213 217

  
214 218

  
215
				return collator.compare(compareString1, compareString2);
219
				int result =collator.compare(compareString1, compareString2);
220
				if (result == 0){
221
				    result = entity1.getUuid().compareTo(entity2.getUuid());
222
				}
223
				return result;
216 224
			}
217 225
		};
218 226
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalReferenceSelectionDialog.java
132 132
	};
133 133

  
134 134
	@Override
135
	protected Comparator getItemsComparator() {
136
		return new Comparator<UuidAndTitleCache>() {
137
			@Override
138
			public int compare(UuidAndTitleCache entity1,
139
					UuidAndTitleCache entity2) {
140
				Collator collator = Collator.getInstance();
141
				String compareString1 = "";
142
				if (entity1.getAbbrevTitleCache() != null){
143
					compareString1 = entity1.getAbbrevTitleCache();
144
				}
145
				if (entity1.getTitleCache() != null){
146
					compareString1 += entity1.getTitleCache();
147
				}
148
				String compareString2 = "";
149
				if (entity2.getAbbrevTitleCache() != null){
150
					compareString2 = entity2.getAbbrevTitleCache();
151
				}
152
				if (entity2.getTitleCache() != null){
153
					compareString2 += entity2.getTitleCache();
154
				}
155
				return collator.compare(compareString1, compareString2);
156
			}
157
		};
158
	}
159

  
135
    protected Comparator getItemsComparator() {
136
        return new Comparator<UuidAndTitleCache>() {
137
            @Override
138
            public int compare(UuidAndTitleCache entity1,
139
                    UuidAndTitleCache entity2) {
140

  
141
                if (entity1.getUuid().equals(entity2.getUuid())){
142
                    return 0;
143
                }
144
                Collator collator = Collator.getInstance();
145
                String compareString1 = "";
146
                if (entity1.getAbbrevTitleCache() != null){
147
                    compareString1 = entity1.getAbbrevTitleCache();
148
                }
149
                if (entity1.getTitleCache() != null){
150
                    compareString1 += entity1.getTitleCache();
151
                }
152

  
153

  
154
                String compareString2 = "";
155
                if (entity2.getAbbrevTitleCache() != null){
156
                    compareString2 = entity2.getAbbrevTitleCache();
157
                }
158
                if (entity2.getTitleCache() != null){
159
                    compareString2 += entity2.getTitleCache();
160
                }
161

  
162

  
163
                int result =collator.compare(compareString1, compareString2);
164
                if (result == 0){
165
                    result = entity1.getUuid().compareTo(entity2.getUuid());
166
                }
167
                return result;
168
            }
169
        };
170
    }
160 171
	@Override
161 172
	protected String getTitle(Reference cdmObject) {
162 173
        if(cdmObject == null){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)