ref #3836: show always freetext modifier field
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / detail / AbstractDetailedDescriptionDetailElement.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.section.description.detail;
11
12 import org.eclipse.swt.SWT;
13 import org.eclipse.ui.forms.widgets.ExpandableComposite;
14
15 import eu.etaxonomy.cdm.model.common.LanguageString;
16 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
17 import eu.etaxonomy.taxeditor.store.CdmStore;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
21 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
22 import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement;
23 import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
24 import eu.etaxonomy.taxeditor.ui.section.description.ModifierSection;
25
26 /**
27 * <p>Abstract AbstractDetailedDescriptionDetailElement class.</p>
28 *
29 * @author n.hoffmann
30 * @created Jun 10, 2010
31 * @version 1.0
32 */
33 public abstract class AbstractDetailedDescriptionDetailElement<T extends DescriptionElementBase> extends AbstractCdmDetailElement<T>{
34
35 TimePeriodElement timePeriod;
36 ModifierSection section_modifiers;
37 TextWithLabelElement text_modifyingText;
38
39 /**
40 * <p>Constructor for AbstractDetailedDescriptionDetailElement.</p>
41 *
42 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
43 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
44 * @param entity a T object.
45 * @param style a int.
46 * @param <T> a T object.
47 */
48 public AbstractDetailedDescriptionDetailElement(CdmFormFactory formFactory,
49 ICdmFormElement formElement, T entity, int style) {
50 super(formFactory, formElement);
51 setEntity(entity);
52 }
53
54
55 protected void createTimePeriod(ICdmFormElement formElement, DescriptionElementBase entity,
56 int style) {
57 timePeriod = formFactory.createTimePeriodElement(this, "Time scope", entity.getTimeperiod(), SWT.WRAP);
58
59 }
60
61 protected void createModifier(ICdmFormElement formElement, DescriptionElementBase entity,
62 int style) {
63
64 section_modifiers = formFactory.createModifierSection(getConversationHolder(), this, ExpandableComposite.TWISTIE|ExpandableComposite.EXPANDED);
65 section_modifiers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
66 section_modifiers.setEntity(entity);
67
68 text_modifyingText = formFactory.createTextWithLabelElement(this, "Modifying Text", null, style);
69 if(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
70 text_modifyingText.setText(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()).getText());
71 }
72 }
73
74 protected void createFreetextModifier(ICdmFormElement formElement, DescriptionElementBase entity,
75 int style) {
76
77 text_modifyingText = formFactory.createTextWithLabelElement(this, "Modifying Text", null, style);
78 if(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {
79 text_modifyingText.setText(getEntity().getModifyingText().get(CdmStore.getDefaultLanguage()).getText());
80 }
81 }
82
83 @Override
84 public void handleEvent(Object eventSource) {
85 if(eventSource == timePeriod){
86 getEntity().setTimeperiod(timePeriod.getTimePeriod());
87 }
88 if (eventSource == text_modifyingText){
89 getEntity().putModifyingText(LanguageString.NewInstance(text_modifyingText.getText(), CdmStore.getDefaultLanguage()));
90 }
91
92 }
93 }