Project

General

Profile

« Previous | Next » 

Revision 2890a5e8

Added by Katja Luther over 1 year ago

ref #10078: code cleaning

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/term/TermComboElement.java
56 56

  
57 57
	public void setTermComparator(Comparator<T> termComparator) {
58 58
		this.termComparator = termComparator;
59
//		List<T> termsWithoutNull = terms.subList(1, terms.size());
60

  
61 59
		populateTerms();
62 60

  
63 61
	}
......
113 111
	        int style, boolean useAbbrevLabel, Comparator<T> comparator) {
114 112
        super(formFactory, parentElement);
115 113

  
116
//        this.termType = termType;
117 114
        this.termVocabulary = termVocabulary;
118 115
        this.termClass = termClass;
119 116
        this.addEmptyElement = addEmptyElement;
......
126 123

  
127 124
        if(termType!=null){
128 125
            //TODO try to remove generic T and avoid classes to be used
129
        	addTerms((List<T>) getTermManager().getPreferredTerms(termType));
130
            
126
        	addTerms((List<T>) getTermManager().getPreferredTerms(termType));            
131 127
        }
132 128
        else if(termVocabulary!=null){
133 129
            addTerms((List<T>) getTermManager().getPreferredTerms(termVocabulary));
......
169 165
		}
170 166
		for (T term: preferredTerms){
171 167
			terms.add(term);
172
		}
173

  
174
		
168
		}		
175 169
	}
176 170

  
177 171
	private TermComboElement(CdmFormFactory formFactory,
......
179 173
            int style, boolean useAbbrevLabel, Comparator<T> comparator) {
180 174
        super(formFactory, parentElement);
181 175

  
182
//        this.termType = termType;
183 176
        this.termVocabulary = termVocabulary;
184 177
        this.termClass = termClass;
185 178
        this.addEmptyElement = addEmptyElement;
......
189 182
            label.setText(labelString);
190 183
        }
191 184

  
192

  
193 185
        if(termType!=null){
194 186
            //TODO try to remove generic T and avoid classes to be used
195 187
            addTerms((List<T>) getTermManager().getPreferredTerms(termType));
......
209 201
        	this.termType = termType;
210 202
        }
211 203

  
212

  
213 204
        addContentProposalAdapter();
214 205
        combo.addSelectionListener(this);
215 206
        combo.addDisposeListener(this);
......
290 281
	 * @param preferredTerms
291 282
	 */
292 283
	protected void populateTerms() {
293

  
294 284
		combo.removeAll();
295

  
296
//		terms = new ArrayList<T>();
297

  
298 285
		int i = 1;
299 286
		int index = 0;
300 287

  
301 288
		if(addEmptyElement){
302 289
		    // Add an empty element for when nothing was selected yet
303 290
		    combo.add(EMPTY_ELEMENT_LABEL);
304
//		    terms.add(emptyElement);
305 291
		}
306 292
		List<T> withoutNull = new ArrayList<>(terms);
307 293
		
......
309 295
			if (addEmptyElement){
310 296
				withoutNull = terms.subList(1, terms.size());
311 297
			}
312
//			Collections.sort(withoutNull, termComparator);		
313
			
314 298
		}
315 299
		for (T term : withoutNull) {
316 300
			String label = getLabel(term);
......
328 312
				}
329 313

  
330 314
			}
331

  
332 315
			combo.add(label);
333 316
			combo.setData(label, term);
334
//			terms.add(term);
335

  
336 317
			i++;
337 318
			if (selection != null) {
338 319
				if (selection.equals(term)) {
......
340 321
				}
341 322
			}
342 323
		}
343

  
344 324
        if (selection != null && index == 0) {
345 325
			createTermNotInPreferredTerms(selection, terms);
346 326
		}
......
408 388
	 * @param term
409 389
	 */
410 390
	private void createTermNotInPreferredTerms(T term, List<T> preferredTerms) {
411
		//List<T> preferredTerms = getPreferredTerms();
412

  
413 391
		terms.add(term);
414

  
415 392
		populateTerms();
416 393
	}
417 394

  
......
458 435
	 * @param terms a {@link List} of T objects or <code>null</code> for default preferred terms
459 436
	 */
460 437
	public void setTerms(List<T> terms) {
461
//		setSelection(null);
462 438
		customPreferredTerms = terms;
463 439
		addTerms(customPreferredTerms);
464 440
		populateTerms();

Also available in: Unified diff