Revision 5a35a97d
Added by Patrick Plitzner over 10 years ago
- added not covered switch cases in NameDetailElement
- commented null pointer access in UseObjectManager (FIXME 3.3M)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
12 | 12 |
|
13 | 13 |
import java.util.Arrays; |
14 | 14 |
|
15 |
import org.apache.log4j.Logger; |
|
15 | 16 |
import org.eclipse.swt.SWT; |
16 | 17 |
|
17 | 18 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
... | ... | |
40 | 41 |
*/ |
41 | 42 |
public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<NonViralName> implements ISelectableElement, IEnableableFormElement{ |
42 | 43 |
|
44 |
private final Logger logger = Logger.getLogger(NameDetailElement.class); |
|
45 |
|
|
43 | 46 |
private TermComboElement<Rank> combo_rank; |
44 | 47 |
private TextWithLabelElement text_appendedPhrase; |
45 | 48 |
private TextWithLabelElement text_uninomial; |
... | ... | |
52 | 55 |
private NumberWithLabelElement text_publicationYear; |
53 | 56 |
private NumberWithLabelElement text_originalPublicationYear; |
54 | 57 |
private int cursorPosition; |
55 |
|
|
58 |
|
|
56 | 59 |
/** |
57 | 60 |
* <p>Constructor for NameDetailElement.</p> |
58 | 61 |
* |
... | ... | |
72 | 75 |
/** {@inheritDoc} */ |
73 | 76 |
@Override |
74 | 77 |
protected void createControls(ICdmFormElement formElement, NonViralName nonViralName, int style) { |
75 |
|
|
78 |
|
|
76 | 79 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
77 |
|
|
80 |
|
|
78 | 81 |
combo_rank = formFactory.createTermComboElement(Rank.class, this, "Rank", nonViralName.getRank(), style); |
79 |
|
|
82 |
|
|
80 | 83 |
createGenusOrUninomialControls(this, nonViralName, style); |
81 | 84 |
createInfragenerericEpithetControls(this, nonViralName, style); |
82 | 85 |
createSpecificEpithetControls(this, nonViralName, style); |
83 | 86 |
createInfraSpecificEpithetControls(this, nonViralName, style); |
84 |
|
|
87 |
|
|
85 | 88 |
createSpecificNameParts(this, nonViralName, style); |
86 |
|
|
89 |
|
|
87 | 90 |
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
88 |
|
|
91 |
|
|
89 | 92 |
} |
90 | 93 |
|
91 | 94 |
/** |
... | ... | |
94 | 97 |
protected void clearCheckRankWarnings() { |
95 | 98 |
if(getEntity().hasProblem(ParserProblem.CheckRank)){ |
96 | 99 |
getEntity().removeParsingProblem(ParserProblem.CheckRank); |
97 |
|
|
100 |
|
|
98 | 101 |
// FIXME this has to be reafctored completely. See tickets #1959, #1663, #1957, #1958 |
99 | 102 |
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME); |
100 | 103 |
// nameEditor.getSelectedContainer().getNameViewer().clearErrors(); |
101 | 104 |
} |
102 | 105 |
} |
103 |
|
|
106 |
|
|
104 | 107 |
/** {@inheritDoc} */ |
105 | 108 |
@Override |
106 | 109 |
protected void updateContent() { |
107 | 110 |
if(getEntity() == null){ |
108 | 111 |
setEntity(NonViralName.NewInstance(null)); |
109 | 112 |
} |
110 |
|
|
113 |
|
|
111 | 114 |
super.updateContent(); |
112 |
|
|
115 |
|
|
113 | 116 |
if(isIrrelevant()){ |
114 | 117 |
setIrrelevant(isIrrelevant()); |
115 | 118 |
}else{ |
... | ... | |
129 | 132 |
case ICZN: |
130 | 133 |
createZoologicalNameParts(formElement, nonViralName, style); |
131 | 134 |
break; |
132 |
} |
|
135 |
case ICVCN: |
|
136 |
//TODO implement |
|
137 |
logger.warn("ICVCN not yet implemented"); |
|
138 |
break; |
|
139 |
case ICNB: |
|
140 |
//TODO implement |
|
141 |
logger.warn("ICNB not yet implemented"); |
|
142 |
break; |
|
143 |
case ICNCP: |
|
144 |
//TODO implement |
|
145 |
logger.warn("ICNCP not yet implemented"); |
|
146 |
break; |
|
147 |
} |
|
133 | 148 |
} |
134 | 149 |
} |
135 |
|
|
150 |
|
|
136 | 151 |
private void createBotanicalNameParts(ICdmFormElement formElement, NonViralName nonViralName, int style){ |
137 | 152 |
BotanicalName botanicalName = (BotanicalName) nonViralName; |
138 | 153 |
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", botanicalName.isAnamorphic(), style); |
... | ... | |
144 | 159 |
text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", zoologicalName.getPublicationYear(), style); |
145 | 160 |
text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", zoologicalName.getOriginalPublicationYear(), style); |
146 | 161 |
} |
147 |
|
|
148 |
private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){
|
|
162 |
|
|
163 |
private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){ |
|
149 | 164 |
String title = "Genus"; |
150 | 165 |
Rank rank = nonViralName.getRank(); |
151 | 166 |
if(rank != null && rank.isSupraGeneric()){ |
152 |
title = "Uninomial";
|
|
167 |
title = "Uninomial"; |
|
153 | 168 |
} |
154 | 169 |
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style); |
155 | 170 |
} |
156 |
|
|
171 |
|
|
157 | 172 |
private void createInfragenerericEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){ |
158 | 173 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraGeneric() && !nonViralName.getRank().isSpeciesAggregate()){ |
159 | 174 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
160 | 175 |
} |
161 | 176 |
} |
162 |
|
|
177 |
|
|
163 | 178 |
private void createSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){ |
164 | 179 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
165 | 180 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL); |
166 | 181 |
} |
167 | 182 |
} |
168 |
|
|
183 |
|
|
169 | 184 |
private void createInfraSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){ |
170 | 185 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){ |
171 | 186 |
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL); |
172 | 187 |
} |
173 | 188 |
} |
174 |
|
|
189 |
|
|
175 | 190 |
/** {@inheritDoc} */ |
176 | 191 |
@Override |
177 | 192 |
public void handleEvent(Object eventSource){ |
178 | 193 |
if (eventSource == toggleable_cache) { |
179 | 194 |
getEntity().setNameCache(toggleable_cache.getText(), |
180 | 195 |
toggleable_cache.getState()); |
181 |
if (!isIrrelevant()) |
|
182 |
setIrrelevant(toggleable_cache.getState(),
|
|
196 |
if (!isIrrelevant()) {
|
|
197 |
setIrrelevant(toggleable_cache.getState(),
|
|
183 | 198 |
Arrays.asList(new Object[] { toggleable_cache })); |
199 |
} |
|
184 | 200 |
} |
185 | 201 |
else if(eventSource == combo_rank){ |
186 | 202 |
getEntity().setRank(combo_rank.getSelection()); |
187 | 203 |
clearCheckRankWarnings(); |
188 | 204 |
updateContent(); |
189 |
}
|
|
205 |
} |
|
190 | 206 |
else if(eventSource == text_appendedPhrase){ |
191 | 207 |
getEntity().setAppendedPhrase(text_appendedPhrase.getText()); |
192 | 208 |
} |
... | ... | |
201 | 217 |
} |
202 | 218 |
else if(eventSource == text_uninomial){ |
203 | 219 |
getEntity().setGenusOrUninomial(text_uninomial.getText()); |
204 |
}
|
|
220 |
} |
|
205 | 221 |
else if(eventSource == checkbox_anamorphic){ |
206 | 222 |
((BotanicalName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection()); |
207 | 223 |
} |
208 | 224 |
} |
209 |
|
|
225 |
|
|
210 | 226 |
/* |
211 | 227 |
* (non-Javadoc) |
212 | 228 |
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator() |
... | ... | |
216 | 232 |
* |
217 | 233 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object. |
218 | 234 |
*/ |
219 |
public SelectionArbitrator getSelectionArbitrator() { |
|
235 |
@Override |
|
236 |
public SelectionArbitrator getSelectionArbitrator() { |
|
220 | 237 |
return selectionArbitrator; |
221 | 238 |
} |
222 |
|
|
239 |
|
|
223 | 240 |
@Override |
224 | 241 |
public void updateToggleableCacheField() { |
225 | 242 |
if(! getEntity().isProtectedNameCache()){ |
Also available in: Unified diff