1 |
cfcb0ce6
|
n.hoffmann
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
5b087075
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
cfcb0ce6
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
5b087075
|
Patric Plitzner
|
*
|
6 |
cfcb0ce6
|
n.hoffmann
|
* 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.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
f211dd28
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
11 |
cfcb0ce6
|
n.hoffmann
|
|
12 |
cab4c925
|
Patric Plitzner
|
import java.util.ArrayList;
|
13 |
|
|
import java.util.List;
|
14 |
|
|
import java.util.Set;
|
15 |
|
|
|
16 |
cfcb0ce6
|
n.hoffmann
|
import org.eclipse.swt.events.SelectionListener;
|
17 |
|
|
|
18 |
|
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
19 |
|
|
import eu.etaxonomy.cdm.model.description.State;
|
20 |
|
|
import eu.etaxonomy.cdm.model.description.StateData;
|
21 |
98db3bf7
|
Patrick Plitzner
|
import eu.etaxonomy.cdm.model.term.TermType;
|
22 |
|
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
23 |
cfcb0ce6
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24 |
98db3bf7
|
Patrick Plitzner
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
25 |
b9a0d300
|
l.morris
|
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
|
26 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
|
27 |
|
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
28 |
dacb59c9
|
Patric Plitzner
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
29 |
23783f7a
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
30 |
78222507
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
|
31 |
f211dd28
|
n.hoffmann
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
32 |
cfcb0ce6
|
n.hoffmann
|
|
33 |
|
|
/**
|
34 |
3be6ef3e
|
n.hoffmann
|
* <p>StateDataElement class.</p>
|
35 |
|
|
*
|
36 |
cfcb0ce6
|
n.hoffmann
|
* @author n.hoffmann
|
37 |
|
|
* @created Sep 15, 2010
|
38 |
|
|
* @version 1.0
|
39 |
|
|
*/
|
40 |
|
|
public class StateDataElement extends AbstractEntityCollectionElement<StateData> {
|
41 |
5b087075
|
Patric Plitzner
|
|
42 |
b9a0d300
|
l.morris
|
private TermComboElement<State> combo_state;
|
43 |
cfcb0ce6
|
n.hoffmann
|
private ModifierSection section_modifiers;
|
44 |
|
|
private TextWithLabelElement text_modifyingText;
|
45 |
|
|
|
46 |
3be6ef3e
|
n.hoffmann
|
/**
|
47 |
|
|
* <p>Constructor for StateDataElement.</p>
|
48 |
|
|
*
|
49 |
78222507
|
n.hoffmann
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
|
50 |
|
|
* @param section a {@link eu.etaxonomy.taxeditor.ui.element.AbstractFormSection} object.
|
51 |
3be6ef3e
|
n.hoffmann
|
* @param entity a {@link eu.etaxonomy.cdm.model.description.StateData} object.
|
52 |
|
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
53 |
|
|
* @param style a int.
|
54 |
|
|
*/
|
55 |
cfcb0ce6
|
n.hoffmann
|
public StateDataElement(CdmFormFactory formFactory,
|
56 |
|
|
AbstractFormSection section, StateData entity,
|
57 |
|
|
SelectionListener removeListener, int style) {
|
58 |
|
|
super(formFactory, section, entity, removeListener, null, style);
|
59 |
|
|
}
|
60 |
5b087075
|
Patric Plitzner
|
|
61 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
62 |
cfcb0ce6
|
n.hoffmann
|
@Override
|
63 |
|
|
public void setEntity(StateData entity) {
|
64 |
|
|
this.entity = entity;
|
65 |
cab4c925
|
Patric Plitzner
|
List<State> stateTerms = new ArrayList<State>();
|
66 |
|
|
Set<TermVocabulary<State>> stateVocabularies = getEntity().getCategoricalData().getFeature().getSupportedCategoricalEnumerations();
|
67 |
|
|
for (TermVocabulary<State> termVocabulary : stateVocabularies) {
|
68 |
|
|
stateTerms.addAll(termVocabulary.getTerms());
|
69 |
|
|
}
|
70 |
|
|
combo_state.setTerms(stateTerms);
|
71 |
cfcb0ce6
|
n.hoffmann
|
combo_state.setSelection(entity.getState());
|
72 |
|
|
section_modifiers.setEntity(entity);
|
73 |
7765e60d
|
Patric Plitzner
|
section_modifiers.setExpanded(!entity.getModifiers().isEmpty());
|
74 |
5b087075
|
Patric Plitzner
|
if(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
|
75 |
|
|
text_modifyingText.setText(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()).getText());
|
76 |
|
|
}
|
77 |
5a52b8a4
|
Patric Plitzner
|
if(getEntity().getId()>0){
|
78 |
|
|
combo_state.removeEmptyElement();
|
79 |
|
|
}
|
80 |
cfcb0ce6
|
n.hoffmann
|
}
|
81 |
|
|
|
82 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
83 |
cfcb0ce6
|
n.hoffmann
|
@Override
|
84 |
|
|
public void createControls(ICdmFormElement element, int style) {
|
85 |
5a52b8a4
|
Patric Plitzner
|
combo_state = formFactory.createDefinedTermComboElement(TermType.State, element, "State", null, style);
|
86 |
98db3bf7
|
Patrick Plitzner
|
section_modifiers = formFactory.createModifierSection(getConversationHolder(), element, StoreUtil.getSectionStyle(ModifierSection.class, StateData.class.getCanonicalName(), true));
|
87 |
23783f7a
|
n.hoffmann
|
section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
88 |
cfcb0ce6
|
n.hoffmann
|
text_modifyingText = formFactory.createTextWithLabelElement(element, "Modifying Text", null, style);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
92 |
cfcb0ce6
|
n.hoffmann
|
@Override
|
93 |
|
|
public void handleEvent(Object eventSource) {
|
94 |
|
|
if(eventSource == combo_state){
|
95 |
|
|
getEntity().setState(combo_state.getSelection());
|
96 |
5a52b8a4
|
Patric Plitzner
|
combo_state.removeEmptyElement();
|
97 |
cfcb0ce6
|
n.hoffmann
|
}
|
98 |
|
|
if(eventSource == text_modifyingText){
|
99 |
23783f7a
|
n.hoffmann
|
getEntity().putModifyingText(LanguageString.NewInstance(text_modifyingText.getText(), CdmStore.getDefaultLanguage()));
|
100 |
cfcb0ce6
|
n.hoffmann
|
}
|
101 |
|
|
}
|
102 |
|
|
}
|