ref #10078: code cleaning
authorKatja Luther <k.luther@bgbm.org>
Tue, 23 Aug 2022 10:39:13 +0000 (12:39 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 23 Aug 2022 10:39:13 +0000 (12:39 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/term/TermComboElement.java

index 48c31aae77adf63a798427d452fecad3932a042b..c55feadd1dc5f0cdc8b23f3a2dc57ba12bba0fcd 100755 (executable)
@@ -56,8 +56,6 @@ public class TermComboElement<T extends DefinedTermBase>
 
        public void setTermComparator(Comparator<T> termComparator) {
                this.termComparator = termComparator;
-//             List<T> termsWithoutNull = terms.subList(1, terms.size());
-
                populateTerms();
 
        }
@@ -113,7 +111,6 @@ public class TermComboElement<T extends DefinedTermBase>
                int style, boolean useAbbrevLabel, Comparator<T> comparator) {
         super(formFactory, parentElement);
 
-//        this.termType = termType;
         this.termVocabulary = termVocabulary;
         this.termClass = termClass;
         this.addEmptyElement = addEmptyElement;
@@ -126,8 +123,7 @@ public class TermComboElement<T extends DefinedTermBase>
 
         if(termType!=null){
             //TODO try to remove generic T and avoid classes to be used
-               addTerms((List<T>) getTermManager().getPreferredTerms(termType));
-            
+               addTerms((List<T>) getTermManager().getPreferredTerms(termType));            
         }
         else if(termVocabulary!=null){
             addTerms((List<T>) getTermManager().getPreferredTerms(termVocabulary));
@@ -169,9 +165,7 @@ public class TermComboElement<T extends DefinedTermBase>
                }
                for (T term: preferredTerms){
                        terms.add(term);
-               }
-
-               
+               }               
        }
 
        private TermComboElement(CdmFormFactory formFactory,
@@ -179,7 +173,6 @@ public class TermComboElement<T extends DefinedTermBase>
             int style, boolean useAbbrevLabel, Comparator<T> comparator) {
         super(formFactory, parentElement);
 
-//        this.termType = termType;
         this.termVocabulary = termVocabulary;
         this.termClass = termClass;
         this.addEmptyElement = addEmptyElement;
@@ -189,7 +182,6 @@ public class TermComboElement<T extends DefinedTermBase>
             label.setText(labelString);
         }
 
-
         if(termType!=null){
             //TODO try to remove generic T and avoid classes to be used
             addTerms((List<T>) getTermManager().getPreferredTerms(termType));
@@ -209,7 +201,6 @@ public class TermComboElement<T extends DefinedTermBase>
                this.termType = termType;
         }
 
-
         addContentProposalAdapter();
         combo.addSelectionListener(this);
         combo.addDisposeListener(this);
@@ -290,18 +281,13 @@ public class TermComboElement<T extends DefinedTermBase>
         * @param preferredTerms
         */
        protected void populateTerms() {
-
                combo.removeAll();
-
-//             terms = new ArrayList<T>();
-
                int i = 1;
                int index = 0;
 
                if(addEmptyElement){
                    // Add an empty element for when nothing was selected yet
                    combo.add(EMPTY_ELEMENT_LABEL);
-//                 terms.add(emptyElement);
                }
                List<T> withoutNull = new ArrayList<>(terms);
                
@@ -309,8 +295,6 @@ public class TermComboElement<T extends DefinedTermBase>
                        if (addEmptyElement){
                                withoutNull = terms.subList(1, terms.size());
                        }
-//                     Collections.sort(withoutNull, termComparator);          
-                       
                }
                for (T term : withoutNull) {
                        String label = getLabel(term);
@@ -328,11 +312,8 @@ public class TermComboElement<T extends DefinedTermBase>
                                }
 
                        }
-
                        combo.add(label);
                        combo.setData(label, term);
-//                     terms.add(term);
-
                        i++;
                        if (selection != null) {
                                if (selection.equals(term)) {
@@ -340,7 +321,6 @@ public class TermComboElement<T extends DefinedTermBase>
                                }
                        }
                }
-
         if (selection != null && index == 0) {
                        createTermNotInPreferredTerms(selection, terms);
                }
@@ -408,10 +388,7 @@ public class TermComboElement<T extends DefinedTermBase>
         * @param term
         */
        private void createTermNotInPreferredTerms(T term, List<T> preferredTerms) {
-               //List<T> preferredTerms = getPreferredTerms();
-
                terms.add(term);
-
                populateTerms();
        }
 
@@ -458,7 +435,6 @@ public class TermComboElement<T extends DefinedTermBase>
         * @param terms a {@link List} of T objects or <code>null</code> for default preferred terms
         */
        public void setTerms(List<T> terms) {
-//             setSelection(null);
                customPreferredTerms = terms;
                addTerms(customPreferredTerms);
                populateTerms();