public class TermComboElement<T extends DefinedTermBase>
extends AbstractComboElement<T> {
- protected T emptyElement;
- protected static String EMPTY_ELEMENT_LABEL = "";
+ private T emptyElement;
+ private static String EMPTY_ELEMENT_LABEL = "";
private ArrayList<T> terms;
- protected Comparator<T> termComparator;
+ private Comparator<T> termComparator;
public Comparator<T> getTermComparator() {
return termComparator;
public void setTermComparator(Comparator<T> termComparator) {
this.termComparator = termComparator;
- List<T> termsWithoutNull = getTerms().subList(1, getTerms().size());
+ List<T> termsWithoutNull = terms.subList(1, terms.size());
populateTerms(termsWithoutNull);
private List<T> customPreferredTerms;
- protected boolean useAbbrevLabel = false;
+ private boolean useAbbrevLabel = false;
private boolean addEmptyElement;
public TermComboElement(CdmFormFactory formFactory,
this.termType = termType;
this.termVocabulary = termVocabulary;
this.termClass = termClass;
- this.setAddEmptyElement(addEmptyElement);
+ this.addEmptyElement = addEmptyElement;
this.useAbbrevLabel = useAbbrevLabel;
this.termComparator = comparator;
if (labelString != null) {
// set selection to the emptyElement
selectedIndex = 0;
}else{
- selectedIndex = getTerms().indexOf(selection);
+ selectedIndex = terms.indexOf(selection);
if (selectedIndex == -1) {
createTermNotInPreferredTerms(selection);
- selectedIndex = getTerms().indexOf(selection);
+ selectedIndex = terms.indexOf(selection);
}
}
combo.select(selectedIndex);
combo.removeAll();
- setTerms(new ArrayList<T>());
+ terms = new ArrayList<T>();
int i = 1;
int index = 0;
- if(isAddEmptyElement()){
+ if(addEmptyElement){
// Add an empty element for when nothing was selected yet
combo.add(EMPTY_ELEMENT_LABEL);
- getTerms().add(emptyElement);
+ terms.add(emptyElement);
}
if (termComparator != null) {
}
combo.add(label);
- getTerms().add(term);
+ terms.add(term);
i++;
if (selection != null) {
*
* @param term
*/
- protected void createTermNotInPreferredTerms(T term) {
+ private void createTermNotInPreferredTerms(T term) {
List<T> preferredTerms = getPreferredTerms();
preferredTerms.add(term);
/** {@inheritDoc} */
@Override
public void widgetSelected(SelectionEvent e) {
- selection = getTerms().get(combo.getSelectionIndex());
+ selection = terms.get(combo.getSelectionIndex());
firePropertyChangeEvent(new CdmPropertyChangeEvent(this, e));
}
}
public void removeEmptyElement(){
- if(isAddEmptyElement()){
- if(getTerms().contains(emptyElement)){
- getTerms().remove(emptyElement);
+ if(addEmptyElement){
+ if(terms.contains(emptyElement)){
+ terms.remove(emptyElement);
}
if(Arrays.asList(combo.getItems()).contains(EMPTY_ELEMENT_LABEL)){
combo.remove(EMPTY_ELEMENT_LABEL);
}
}
- public ArrayList<T> getTerms() {
- return terms;
- }
-
- public void setTerms(ArrayList<T> terms) {
- this.terms = terms;
- }
-
- public boolean isAddEmptyElement() {
- return addEmptyElement;
- }
-
- public void setAddEmptyElement(boolean addEmptyElement) {
- this.addEmptyElement = addEmptyElement;
- }
}