1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.ui.section.description;
|
12
|
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.eclipse.swt.events.SelectionListener;
|
15
|
import org.eclipse.ui.forms.widgets.Section;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
18
|
import eu.etaxonomy.cdm.model.description.State;
|
19
|
import eu.etaxonomy.cdm.model.description.StateData;
|
20
|
import eu.etaxonomy.taxeditor.singlesource.ui.forms.TextWithLabelElementFacade;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
|
23
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
|
24
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
|
25
|
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.TermComboType;
|
26
|
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
|
27
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
|
28
|
import eu.etaxonomy.taxeditor.ui.term.AbstractTermComboElement;
|
29
|
|
30
|
/**
|
31
|
* <p>StateDataElement class.</p>
|
32
|
*
|
33
|
* @author n.hoffmann
|
34
|
* @created Sep 15, 2010
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class StateDataElement extends AbstractEntityCollectionElement<StateData> {
|
38
|
|
39
|
private static final Logger logger = Logger
|
40
|
.getLogger(StateDataElement.class);
|
41
|
private AbstractTermComboElement<State> combo_state;
|
42
|
private ModifierSection section_modifiers;
|
43
|
private TextWithLabelElementFacade text_modifyingText;
|
44
|
|
45
|
/**
|
46
|
* <p>Constructor for StateDataElement.</p>
|
47
|
*
|
48
|
* @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
|
49
|
* @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
|
50
|
* @param entity a {@link eu.etaxonomy.cdm.model.description.StateData} object.
|
51
|
* @param removeListener a {@link org.eclipse.swt.events.SelectionListener} object.
|
52
|
* @param style a int.
|
53
|
*/
|
54
|
public StateDataElement(CdmFormFactory formFactory,
|
55
|
AbstractFormSection section, StateData entity,
|
56
|
SelectionListener removeListener, int style) {
|
57
|
super(formFactory, section, entity, removeListener, null, style);
|
58
|
}
|
59
|
|
60
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
public void setEntity(StateData entity) {
|
63
|
this.entity = entity;
|
64
|
combo_state.setSelection(entity.getState());
|
65
|
section_modifiers.setEntity(entity);
|
66
|
if(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()) != null)
|
67
|
text_modifyingText.setText(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()).getText());
|
68
|
}
|
69
|
|
70
|
/** {@inheritDoc} */
|
71
|
@Override
|
72
|
public void createControls(ICdmFormElement element, int style) {
|
73
|
combo_state = formFactory.createTermComboElement(TermComboType.STATE, element, "State", null, style);
|
74
|
section_modifiers = (ModifierSection) formFactory.createEntityDetailSection(EntityDetailType.MODIFIER, getConversationHolder(), element, Section.TWISTIE);
|
75
|
section_modifiers.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
|
76
|
text_modifyingText = formFactory.createTextWithLabelElement(element, "Modifying Text", null, style);
|
77
|
}
|
78
|
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
public void handleEvent(Object eventSource) {
|
82
|
if(eventSource == combo_state){
|
83
|
getEntity().setState(combo_state.getSelection());
|
84
|
}
|
85
|
if(eventSource == text_modifyingText){
|
86
|
getEntity().addModifyingText(LanguageString.NewInstance(text_modifyingText.getText(), CdmStore.getDefaultLanguage()));
|
87
|
}
|
88
|
}
|
89
|
}
|