3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.description
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.graphics
.Color
;
15 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
16 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
17 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
18 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
19 import eu
.etaxonomy
.taxeditor
.ui
.combo
.VocabularyComboElement
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
.StateModifierCollectionSection
;
31 public class StateModifierElement
extends AbstractEntityCollectionElement
<TermVocabulary
<DefinedTerm
>> {
34 private VocabularyComboElement
<DefinedTerm
, TermVocabulary
<DefinedTerm
>> comboStateVocabulary
;
40 * @param removeListener
41 * @param isChoosableEntity
42 * @param backgroundColor
45 public StateModifierElement(CdmFormFactory formFactory
, AbstractFormSection section
, TermVocabulary
<DefinedTerm
> entity
,
46 SelectionListener removeListener
, Color backgroundColor
, int style
) {
47 super(formFactory
, section
, entity
, removeListener
, false, backgroundColor
, style
);
52 public void createControls(ICdmFormElement element
, int style
) {
53 comboStateVocabulary
= formFactory
.createVocabularyComboElement(TermType
.Modifier
, "State modifiers", null, element
, style
);
57 public void setEntity(TermVocabulary
<DefinedTerm
> entity
) {
59 if(entity
.getId()!=0){
60 comboStateVocabulary
.setSelection(entity
);
65 public void handleEvent(Object eventSource
) {
66 if(eventSource
==comboStateVocabulary
&& comboStateVocabulary
.getSelection()!=null){
67 if(getParentElement() instanceof StateModifierCollectionSection
){
68 Feature feature
= ((StateModifierCollectionSection
) getParentElement()).getEntity();
69 feature
.removeRecommendedModifierEnumeration(entity
);
70 TermVocabulary
<DefinedTerm
> vocabulary
= comboStateVocabulary
.getSelection();
71 feature
.addRecommendedModifierEnumeration(vocabulary
);