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.name;
|
12
|
|
13
|
import java.util.Arrays;
|
14
|
|
15
|
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
18
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
19
|
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
20
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
21
|
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
|
22
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
23
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
24
|
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
|
27
|
|
28
|
/**
|
29
|
* <p>
|
30
|
* NonViralNameDetailElement class.
|
31
|
* </p>
|
32
|
*
|
33
|
* @author n.hoffmann
|
34
|
* @created May 20, 2010
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class NonViralNameDetailElement extends
|
38
|
AbstractIdentifiableEntityDetailElement<NonViralName> {
|
39
|
|
40
|
private NameDetailSection section_name;
|
41
|
private AuthorshipDetailSection section_author;
|
42
|
private EnumComboElement<NomenclaturalCode> combo_nomenclaturalCode;
|
43
|
private HybridDetailSection section_hybrid;
|
44
|
|
45
|
/**
|
46
|
* <p>
|
47
|
* Constructor for NonViralNameDetailElement.
|
48
|
* </p>
|
49
|
*
|
50
|
* @param formFactory
|
51
|
* a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
|
52
|
* object.
|
53
|
* @param formElement
|
54
|
* a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement}
|
55
|
* object.
|
56
|
*/
|
57
|
public NonViralNameDetailElement(CdmFormFactory formFactory,
|
58
|
ICdmFormElement formElement) {
|
59
|
super(formFactory, formElement);
|
60
|
}
|
61
|
|
62
|
/*
|
63
|
* (non-Javadoc)
|
64
|
*
|
65
|
* @see
|
66
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#createControls
|
67
|
* (eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement,
|
68
|
* eu.etaxonomy.cdm.model.common.AnnotatableEntity, int)
|
69
|
*/
|
70
|
/** {@inheritDoc} */
|
71
|
@Override
|
72
|
protected void createControls(ICdmFormElement formElement, final NonViralName entity, int style) {
|
73
|
|
74
|
toggleable_cache = formFactory.createToggleableTextField(formElement, "Cache", entity.getTitleCache(), entity.isProtectedTitleCache() || entity.isProtectedFullTitleCache(), style);
|
75
|
|
76
|
combo_nomenclaturalCode = formFactory.createEnumComboElement(NomenclaturalCode.class, formElement, style);
|
77
|
combo_nomenclaturalCode.setSelection(entity.getNomenclaturalCode());
|
78
|
|
79
|
//TODO RL
|
80
|
if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
|
81
|
toggleable_cache.setVisible(false);
|
82
|
combo_nomenclaturalCode.setVisible(false);
|
83
|
}
|
84
|
|
85
|
section_name = formFactory.createNameDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
|
86
|
section_name.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
87
|
addControl(section_name);
|
88
|
addElement(section_name);
|
89
|
section_author = formFactory.createAuthorshipDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
|
90
|
section_author.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
91
|
addControl(section_author);
|
92
|
addElement(section_author);
|
93
|
|
94
|
//TODO RL
|
95
|
if(!PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
|
96
|
section_hybrid = formFactory.createHybridDetailSection(getConversationHolder(), formElement, null, ExpandableComposite.TWISTIE);
|
97
|
section_hybrid.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
|
98
|
addControl(section_hybrid);
|
99
|
addElement(section_hybrid);
|
100
|
}
|
101
|
}
|
102
|
|
103
|
/** {@inheritDoc} */
|
104
|
@Override
|
105
|
protected void updateContent() {
|
106
|
super.updateContent();
|
107
|
|
108
|
// disable nomenclatural code, because changing of nom.code is not
|
109
|
// implemented on library side
|
110
|
combo_nomenclaturalCode.setEnabled(false);
|
111
|
|
112
|
setIrrelevant(toggleable_cache.getState(),
|
113
|
Arrays.asList(new Object[] { toggleable_cache }));
|
114
|
}
|
115
|
|
116
|
/** {@inheritDoc} */
|
117
|
@Override
|
118
|
public void setEntity(NonViralName entity) {
|
119
|
super.setEntity(entity);
|
120
|
if (section_name!=null) section_name.setEntity(entity);
|
121
|
if (section_author!=null) section_author.setEntity(entity);
|
122
|
if (section_hybrid!=null) section_hybrid.setEntity(entity);
|
123
|
}
|
124
|
|
125
|
/** {@inheritDoc} */
|
126
|
@Override
|
127
|
public void removeElements() {
|
128
|
super.removeElements();
|
129
|
if (section_name != null) {
|
130
|
section_name.removeElements();
|
131
|
removeControl(section_name);
|
132
|
section_name.dispose();
|
133
|
section_name = null;
|
134
|
}
|
135
|
if (section_author != null) {
|
136
|
section_author.removeElements();
|
137
|
removeControl(section_author);
|
138
|
section_author.dispose();
|
139
|
section_author = null;
|
140
|
}
|
141
|
}
|
142
|
|
143
|
/*
|
144
|
* (non-Javadoc)
|
145
|
*
|
146
|
* @see
|
147
|
* eu.etaxonomy.taxeditor.section.AbstractCdmDetailElement#handleEvent(java
|
148
|
* .lang.Object)
|
149
|
*/
|
150
|
/** {@inheritDoc} */
|
151
|
@Override
|
152
|
public void handleEvent(Object eventSource) {
|
153
|
if (eventSource == toggleable_cache) {
|
154
|
handleToggleableCacheField();
|
155
|
// we never want the fullTitleCache to be protected since we only
|
156
|
// use it for
|
157
|
// initiating the free text name editor
|
158
|
getEntity().setProtectedFullTitleCache(false);
|
159
|
} else if (eventSource == section_name || eventSource == section_author) {
|
160
|
if (getParentElement() instanceof AbstractCdmDetailSection) {
|
161
|
((AbstractCdmDetailSection) getParentElement()).updateTitle();
|
162
|
}
|
163
|
if (!toggleable_cache.getState()) {
|
164
|
toggleable_cache.setText(getEntity().getTitleCache());
|
165
|
}
|
166
|
}
|
167
|
if (eventSource == section_name) {
|
168
|
section_name.setEntity(getEntity());
|
169
|
getLayoutComposite().layout();
|
170
|
}
|
171
|
}
|
172
|
}
|