2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
11 import org
.eclipse
.swt
.events
.SelectionListener
;
12 import org
.eclipse
.swt
.graphics
.Color
;
14 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
15 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
16 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
17 import eu
.etaxonomy
.cdm
.model
.description
.State
;
18 import eu
.etaxonomy
.taxeditor
.ui
.combo
.VocabularyComboElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
29 public class StateVocabularyCollectionElement
extends AbstractEntityCollectionElement
<TermVocabulary
<State
>> {
32 private VocabularyComboElement
<State
, TermVocabulary
<State
>> comboStateVocabulary
;
38 * @param removeListener
39 * @param isChoosableEntity
40 * @param backgroundColor
43 public StateVocabularyCollectionElement(CdmFormFactory formFactory
, AbstractFormSection section
, TermVocabulary
<State
> entity
,
44 SelectionListener removeListener
, Color backgroundColor
, int style
) {
45 super(formFactory
, section
, entity
, removeListener
, false, backgroundColor
, style
);
50 public void createControls(ICdmFormElement element
, int style
) {
51 comboStateVocabulary
= formFactory
.createVocabularyComboElement(TermType
.State
, "State vocabulary", null, element
, style
);
55 public void setEntity(TermVocabulary
<State
> entity
) {
57 if(entity
.getId()!=0){
58 comboStateVocabulary
.setSelection(entity
);
59 comboStateVocabulary
.removeEmptyElement();
64 public void handleEvent(Object eventSource
) {
65 if(eventSource
==comboStateVocabulary
&& comboStateVocabulary
.getSelection()!=null){
66 if(getParentElement() instanceof StateVocabularyCollectionSection
){
67 StateVocabularyCollectionSection parentElement
= (StateVocabularyCollectionSection
) getParentElement();
68 Feature feature
= parentElement
.getEntity();
69 feature
.removeSupportedCategoricalEnumeration(entity
);
70 TermVocabulary
<State
> vocabulary
= comboStateVocabulary
.getSelection();
71 feature
.addSupportedCategoricalEnumeration(vocabulary
);
73 //update the parent section to re-set the listeners to the persisted measurement unit
74 parentElement
.removeElementAndUpdate(null);