Project

General

Profile

« Previous | Next » 

Revision 90b5ff20

Added by Katja Luther over 3 years ago

ref #8774: fix term combo for dto selection

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/VocabularyComboElement.java
44 44

  
45 45
    private final TermType termType;
46 46

  
47
    private TermVocabularyDto selected_vocDto;
48

  
49
	public VocabularyComboElement(CdmFormFactory formFactory,
47
    public VocabularyComboElement(CdmFormFactory formFactory,
50 48
	        ICdmFormElement parentElement, TermType termType, String labelString, VOC selection,
51 49
	        int style) {
52 50
        super(formFactory, parentElement);
......
126 124

  
127 125

  
128 126
    public void setSelectionDto(TermVocabularyDto selection) {
129
        this.selected_vocDto = selection;
130

  
131 127
        Listener[] listeners = combo.getListeners(SWT.Selection);
132 128

  
133 129
//      for (Listener listener : listeners) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/term/TermComboElement.java
235 235
		}
236 236
	}
237 237

  
238
	public void setSelectionDto(TermDto selection) {
239
        int selectedIndex = 0;
240
        if(selection == null){
241
            // set selection to the emptyElement
242
            selectedIndex = 0;
243
        }else{
244
            for (T term: terms){
245
                if (term != null && term.getUuid().equals(selection.getUuid())){
246
                    selectedIndex = terms.indexOf(term);
247
                }
248
            }
249
        }
250
        if (selectedIndex > -1) {
251
            combo.select(selectedIndex);
252
        }
253
    }
254

  
238 255
	/**
239 256
	 * Fills the combo with elements and sets up the convenience functions
240 257
	 * for selection index
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/MeasurementUnitDtoCollectionElement.java
55 55
    public void setEntity(TermDto entity) {
56 56
        this.entity = entity;
57 57
//        if(entity.getId()!=0){
58
//            comboMeasurementUnit.setSelection(entity);
59
//            comboMeasurementUnit.removeEmptyElement();
58
            comboMeasurementUnit.setSelectionDto(entity);
59
            comboMeasurementUnit.removeEmptyElement();
60 60
//        }
61 61
    }
62 62

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/RecommendedModifierDtoVocabulariesElement.java
56 56
    public void setEntity(TermVocabularyDto entity) {
57 57
        this.entity = entity;
58 58
//        if(entity.getId()!=0){
59
//            comboStateVocabulary.setSelection(entity);
60
//            comboStateVocabulary.removeEmptyElement();
59
            comboStateVocabulary.setSelectionDto(entity);
60
            comboStateVocabulary.removeEmptyElement();
61 61
//        }
62 62
    }
63 63

  
64

  
64 65
    @Override
65 66
    public void handleEvent(Object eventSource) {
66 67
        if(eventSource==comboStateVocabulary && comboStateVocabulary.getSelection()!=null){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/RecommendedModifierVocabulariesDtoCollectionSection.java
137 137
    }
138 138

  
139 139

  
140

  
140 141
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/StatisticalMeasureDtoCollectionElement.java
55 55
    public void setEntity(TermDto entity) {
56 56
        this.entity = entity;
57 57
//        if(entity.getId()!=0){
58
//            comboStatisticalMeasure.setSelection(entity);
59
//            comboStatisticalMeasure.removeEmptyElement();
58
            comboStatisticalMeasure.setSelectionDto(entity);
59
            comboStatisticalMeasure.removeEmptyElement();
60 60
//        }
61 61
    }
62 62

  

Also available in: Unified diff