Revision 69955d6c
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement; |
40 | 40 |
|
41 | 41 |
/** |
42 |
* <p>NameDetailElement class.</p> |
|
43 |
* |
|
44 | 42 |
* @author n.hoffmann |
45 | 43 |
* @created Feb 26, 2010 |
46 | 44 |
*/ |
... | ... | |
48 | 46 |
|
49 | 47 |
private final Logger logger = Logger.getLogger(NameDetailElement.class); |
50 | 48 |
|
51 |
private TermComboElement<Rank> combo_rank;
|
|
52 |
private TextWithLabelElement text_appendedPhrase;
|
|
53 |
private TextWithLabelElement text_uninomial;
|
|
54 |
private TextWithLabelElement text_infragenericEpithet;
|
|
55 |
private TextWithLabelElement text_specificEpithet;
|
|
56 |
private TextWithLabelElement text_infraspecificEpithet;
|
|
57 |
private SelectionArbitrator selectionArbitrator;
|
|
58 |
private CheckboxElement checkbox_anamorphic;
|
|
59 |
private TextWithLabelElement text_cultivarName;
|
|
60 |
private TextWithLabelElement text_subGenusAuthorship;
|
|
49 |
private TermComboElement<Rank> combo_rank;
|
|
50 |
private TextWithLabelElement text_appendedPhrase;
|
|
51 |
private TextWithLabelElement text_uninomial;
|
|
52 |
private TextWithLabelElement text_infragenericEpithet;
|
|
53 |
private TextWithLabelElement text_specificEpithet;
|
|
54 |
private TextWithLabelElement text_infraspecificEpithet;
|
|
55 |
private SelectionArbitrator selectionArbitrator;
|
|
56 |
private CheckboxElement checkbox_anamorphic;
|
|
57 |
private TextWithLabelElement text_cultivarName;
|
|
58 |
private TextWithLabelElement text_subGenusAuthorship;
|
|
61 | 59 |
|
62 |
private TextWithLabelElement text_breed;
|
|
63 |
//private NumberWithLabelElement text_publicationYear;
|
|
64 |
//private NumberWithLabelElement text_originalPublicationYear;
|
|
65 |
private int cursorPosition;
|
|
60 |
private TextWithLabelElement text_breed;
|
|
61 |
//private NumberWithLabelElement text_publicationYear;
|
|
62 |
//private NumberWithLabelElement text_originalPublicationYear;
|
|
63 |
private int cursorPosition;
|
|
66 | 64 |
|
67 |
NameDetailsConfigurator config;
|
|
65 |
NameDetailsConfigurator config;
|
|
68 | 66 |
|
69 | 67 |
private int style; |
70 | 68 |
|
71 |
/** |
|
72 |
* <p>Constructor for NameDetailElement.</p> |
|
73 |
* |
|
74 |
* @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object. |
|
75 |
* @param formElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object. |
|
76 |
* @param style a int. |
|
77 |
*/ |
|
78 |
public NameDetailElement(CdmFormFactory cdmFormFactory, ICdmFormElement formElement, |
|
79 |
int style) { |
|
80 |
super(cdmFormFactory, formElement); |
|
81 |
// make this element selectable |
|
82 |
|
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
/** {@inheritDoc} */ |
|
87 |
@Override |
|
88 |
protected void createControls(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
89 |
this.style = style; |
|
90 |
super.update(nonViralName); |
|
91 |
Comparator<Rank> comparator = null; |
|
92 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
93 |
if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
94 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
95 |
} |
|
96 |
if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
97 |
comparator = new Comparator<Rank>(){ |
|
98 |
|
|
99 |
@Override |
|
100 |
public int compare(Rank o1, Rank o2) { |
|
101 |
return o2.compareTo(o1); |
|
102 |
} |
|
103 |
|
|
104 |
}; |
|
105 |
} |
|
106 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", null, nonViralName.isProtectedNameCache(), style); |
|
107 |
|
|
108 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", null, style, comparator); |
|
109 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
110 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(this, "Infrageneric Epithet", null, style); |
|
111 |
text_specificEpithet = formFactory.createTextWithLabelElement(this, "Specific Epithet", null, SWT.NULL); |
|
112 |
text_infraspecificEpithet = formFactory.createTextWithLabelElement(this, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL); |
|
113 |
// createSpecificNameParts(this, nonViralName, style); |
|
114 |
|
|
115 |
text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", null, style); |
|
116 |
|
|
117 |
update(nonViralName); |
|
118 |
// if (isAdvancedView){ |
|
119 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
120 |
// |
|
121 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
122 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
123 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
124 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
125 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
126 |
// createSpecificNameParts(this, nonViralName, style); |
|
127 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
128 |
// }else{ |
|
129 |
// if (config.isNameCacheActivated()){ |
|
130 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
131 |
// } |
|
132 |
// if (config.isRankActivated()){ |
|
133 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
134 |
// } |
|
135 |
// if (config.isAtomisedEpithetsActivated()){ |
|
136 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
137 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
138 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
139 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
140 |
// createSpecificNameParts(this, nonViralName, style); |
|
141 |
// } |
|
142 |
// if (config.isAppendedPhraseActivated()){ |
|
143 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
144 |
// } |
|
145 |
// } |
|
146 |
if(this.getFormFactory().getSelectionProvider() != null){ |
|
147 |
selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
// @Override |
|
152 |
// protected void update(INonViralName nonViralName) { |
|
153 |
// super.update(nonViralName); |
|
154 |
// Comparator<Rank> comparator = null; |
|
155 |
// config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
156 |
// if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
157 |
// config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
158 |
// } |
|
159 |
// if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
160 |
// comparator = new Comparator<Rank>(){ |
|
161 |
// |
|
162 |
// @Override |
|
163 |
// public int compare(Rank o1, Rank o2) { |
|
164 |
// return o2.compareTo(o1); |
|
165 |
// } |
|
166 |
// |
|
167 |
// }; |
|
168 |
// } |
|
169 |
// if (isAdvancedView){ |
|
170 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
171 |
// |
|
172 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
173 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
174 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
175 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
176 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
177 |
// createSpecificNameParts(this, nonViralName, style); |
|
178 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
179 |
// }else{ |
|
180 |
// if (config.isNameCacheActivated()){ |
|
181 |
// toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
182 |
// } |
|
183 |
// if (config.isRankActivated()){ |
|
184 |
// combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
185 |
// } |
|
186 |
// if (config.isAtomisedEpithetsActivated()){ |
|
187 |
// createGenusOrUninomialControls(this, nonViralName, style); |
|
188 |
// createInfragenerericEpithetControls(this, nonViralName, style); |
|
189 |
// createSpecificEpithetControls(this, nonViralName, style); |
|
190 |
// createInfraSpecificEpithetControls(this, nonViralName, style); |
|
191 |
// createSpecificNameParts(this, nonViralName, style); |
|
192 |
// } |
|
193 |
// if (config.isAppendedPhraseActivated()){ |
|
194 |
// text_appendedPhrase = formFactory.createTextWithLabelElement(this, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
195 |
// } |
|
196 |
// } |
|
197 |
// if(this.getFormFactory().getSelectionProvider() != null){ |
|
198 |
// selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
199 |
// } |
|
200 |
// } |
|
201 |
@Override |
|
202 |
protected void update(INonViralName nonViralName) { |
|
203 |
super.update(nonViralName); |
|
204 |
if (isAdvancedView){ |
|
205 |
toggleable_cache.setText(nonViralName.getNameCache()); |
|
206 |
|
|
207 |
combo_rank.setSelection(nonViralName.getRank()); |
|
208 |
updateGenusOrUninomialControls(nonViralName); |
|
209 |
updateInfragenerericEpithetControls(nonViralName); |
|
210 |
updateSpecificEpithetControls(nonViralName); |
|
211 |
updateInfraSpecificEpithetControls(nonViralName); |
|
212 |
// updateSpecificNameParts(nonViralName); |
|
213 |
text_appendedPhrase.setText(nonViralName.getAppendedPhrase()); |
|
214 |
}else{ |
|
215 |
if (config.isNameCacheActivated()){ |
|
216 |
toggleable_cache.setText(nonViralName.getNameCache()); |
|
217 |
} |
|
218 |
if (config.isRankActivated()){ |
|
219 |
combo_rank.setSelection(nonViralName.getRank()); |
|
220 |
} |
|
221 |
if (config.isAtomisedEpithetsActivated()){ |
|
222 |
updateGenusOrUninomialControls(nonViralName); |
|
223 |
updateInfragenerericEpithetControls(nonViralName); |
|
224 |
updateSpecificEpithetControls(nonViralName); |
|
225 |
updateInfraSpecificEpithetControls(nonViralName); |
|
226 |
// updateSpecificNameParts(nonViralName); |
|
227 |
} |
|
228 |
if (config.isAppendedPhraseActivated()){ |
|
229 |
text_appendedPhrase.setText(nonViralName.getAppendedPhrase()); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* <p>clearCheckRankWarnings</p> |
|
236 |
*/ |
|
237 |
protected void clearCheckRankWarnings() { |
|
238 |
if(getEntity().hasProblem(ParserProblem.CheckRank)){ |
|
239 |
getEntity().removeParsingProblem(ParserProblem.CheckRank); |
|
240 |
|
|
241 |
// FIXME this has to be reafctored completely. See tickets #1959, #1663, #1957, #1958 |
|
242 |
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME); |
|
243 |
// nameEditor.getSelectedContainer().getNameViewer().clearErrors(); |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
/** {@inheritDoc} */ |
|
248 |
@Override |
|
249 |
public void updateContent() { |
|
250 |
if(getEntity() == null){ |
|
251 |
setEntity(TaxonNameFactory.NewNonViralInstance(null)); |
|
252 |
} |
|
253 |
|
|
254 |
super.updateContent(); |
|
255 |
if (toggleable_cache != null){ |
|
256 |
toggleable_cache.setEnabled(getEntity().isProtectedNameCache()); |
|
257 |
|
|
258 |
if (isAdvancedView){ |
|
259 |
if(isIrrelevant()){ |
|
260 |
setIrrelevant(isIrrelevant()); |
|
261 |
}else{ |
|
262 |
setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache})); |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
|
|
268 |
|
|
269 |
private void updateSpecificNameParts(INonViralName nonViralName) { |
|
270 |
NomenclaturalCode code = nonViralName.getNomenclaturalCode(); |
|
271 |
if (code != null){ |
|
272 |
switch(nonViralName.getNomenclaturalCode()){ |
|
273 |
case ICNAFP : |
|
274 |
//nothing do add |
|
275 |
updateBotanicalNameParts(nonViralName); |
|
276 |
break; |
|
277 |
case Fungi : |
|
278 |
if (isAdvancedView){ |
|
279 |
updateFungusNameParts(nonViralName); |
|
280 |
} |
|
281 |
break; |
|
282 |
case ICZN: |
|
283 |
updateZoologicalNameParts(nonViralName); |
|
284 |
break; |
|
285 |
case ICVCN: |
|
286 |
//TODO implement |
|
287 |
logger.warn("ICVCN not yet implemented"); |
|
288 |
break; |
|
289 |
case ICNB: |
|
290 |
updateBacterialNameParts(nonViralName); |
|
291 |
break; |
|
292 |
case ICNCP: |
|
293 |
updateCultivarNameParts(nonViralName); |
|
294 |
break; |
|
295 |
case NonViral: |
|
296 |
//TODO implement |
|
297 |
logger.warn("NonViral not yet implemented"); |
|
298 |
break; |
|
299 |
} |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
private void createSpecificNameParts(ICdmFormElement formElement, |
|
304 |
INonViralName nonViralName, int style) { |
|
305 |
NomenclaturalCode code = nonViralName.getNomenclaturalCode(); |
|
306 |
if (code != null){ |
|
307 |
switch(nonViralName.getNomenclaturalCode()){ |
|
308 |
case ICNAFP : |
|
309 |
//nothing do add |
|
310 |
createBotanicalNameParts(formElement, nonViralName, style); |
|
311 |
break; |
|
312 |
case Fungi : |
|
313 |
if (isAdvancedView){ |
|
314 |
createFungusNameParts(formElement, nonViralName, style); |
|
315 |
} |
|
316 |
break; |
|
317 |
case ICZN: |
|
318 |
createZoologicalNameParts(formElement, nonViralName, style); |
|
319 |
break; |
|
69 |
private ICdmFormElement formElement; |
|
70 |
|
|
71 |
public NameDetailElement(CdmFormFactory cdmFormFactory, ICdmFormElement formElement, |
|
72 |
int style) { |
|
73 |
super(cdmFormFactory, formElement); |
|
74 |
|
|
75 |
// make this element selectable |
|
76 |
|
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
protected void createControls(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
82 |
this.style = style; |
|
83 |
this.formElement = formElement; |
|
84 |
update(nonViralName); |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
protected void update(INonViralName nonViralName) { |
|
89 |
super.update(nonViralName); |
|
90 |
Comparator<Rank> comparator = null; |
|
91 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(false); |
|
92 |
if ( PreferencesUtil.getPreferenceStore().getBoolean(PreferencesUtil.ALLOW_OVERRIDE_NAME_DETAILS) || config == null){ |
|
93 |
config = PreferencesUtil.setPreferredNameDetailsConfiguration(true); |
|
94 |
} |
|
95 |
if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
96 |
comparator = new Comparator<Rank>(){ |
|
97 |
|
|
98 |
@Override |
|
99 |
public int compare(Rank o1, Rank o2) { |
|
100 |
return o2.compareTo(o1); |
|
101 |
} |
|
102 |
|
|
103 |
}; |
|
104 |
} |
|
105 |
if (isAdvancedView){ |
|
106 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
107 |
|
|
108 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
109 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
110 |
createInfragenerericEpithetControls(this, nonViralName, style); |
|
111 |
createSpecificEpithetControls(this, nonViralName, style); |
|
112 |
createInfraSpecificEpithetControls(this, nonViralName, style); |
|
113 |
createSpecificNameParts(this, nonViralName, style); |
|
114 |
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
115 |
}else{ |
|
116 |
if (config.isNameCacheActivated()){ |
|
117 |
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style); |
|
118 |
} |
|
119 |
|
|
120 |
if (config.isRankActivated()){ |
|
121 |
combo_rank = formFactory.createDefinedTermComboElement(TermType.Rank, this, "Rank", nonViralName.getRank(), style, comparator); |
|
122 |
} |
|
123 |
|
|
124 |
if (config.isAtomisedEpithetsActivated()){ |
|
125 |
createGenusOrUninomialControls(this, nonViralName, style); |
|
126 |
createInfragenerericEpithetControls(this, nonViralName, style); |
|
127 |
createSpecificEpithetControls(this, nonViralName, style); |
|
128 |
createInfraSpecificEpithetControls(this, nonViralName, style); |
|
129 |
createSpecificNameParts(this, nonViralName, style); |
|
130 |
} |
|
131 |
if (config.isAppendedPhraseActivated()){ |
|
132 |
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style); |
|
133 |
} |
|
134 |
} |
|
135 |
if(this.getFormFactory().getSelectionProvider() != null){ |
|
136 |
selectionArbitrator = this.getFormFactory().createSelectionArbitrator(this); |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* <p>clearCheckRankWarnings</p> |
|
142 |
*/ |
|
143 |
protected void clearCheckRankWarnings() { |
|
144 |
if(getEntity().hasProblem(ParserProblem.CheckRank)){ |
|
145 |
getEntity().removeParsingProblem(ParserProblem.CheckRank); |
|
146 |
|
|
147 |
// FIXME this has to be refactored completely. See tickets #1959, #1663, #1957, #1958 |
|
148 |
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME); |
|
149 |
// nameEditor.getSelectedContainer().getNameViewer().clearErrors(); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
/** {@inheritDoc} */ |
|
154 |
@Override |
|
155 |
public void updateContent() { |
|
156 |
if(getEntity() == null){ |
|
157 |
setEntity(TaxonNameFactory.NewNonViralInstance(null)); |
|
158 |
} |
|
159 |
|
|
160 |
super.updateContent(); |
|
161 |
if (toggleable_cache != null){ |
|
162 |
toggleable_cache.setEnabled(getEntity().isProtectedNameCache()); |
|
163 |
|
|
164 |
if (isAdvancedView){ |
|
165 |
if(isIrrelevant()){ |
|
166 |
setIrrelevant(isIrrelevant()); |
|
167 |
}else{ |
|
168 |
setIrrelevant(toggleable_cache.getState(), Arrays.asList(new Object[]{toggleable_cache})); |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
private void createSpecificNameParts(ICdmFormElement formElement, |
|
175 |
INonViralName nonViralName, int style) { |
|
176 |
NomenclaturalCode code = nonViralName.getNomenclaturalCode(); |
|
177 |
if (code != null){ |
|
178 |
switch(nonViralName.getNomenclaturalCode()){ |
|
179 |
case ICNAFP : |
|
180 |
//nothing do add |
|
181 |
createBotanicalNameParts(formElement, nonViralName, style); |
|
182 |
break; |
|
183 |
case Fungi : |
|
184 |
if (isAdvancedView){ |
|
185 |
createFungusNameParts(formElement, nonViralName, style); |
|
186 |
} |
|
187 |
break; |
|
188 |
case ICZN: |
|
189 |
createZoologicalNameParts(formElement, nonViralName, style); |
|
190 |
break; |
|
320 | 191 |
case ICVCN: |
321 | 192 |
//TODO implement |
322 | 193 |
logger.warn("ICVCN not yet implemented"); |
323 | 194 |
break; |
324 | 195 |
case ICNB: |
325 |
createBacterialNameParts(formElement, nonViralName, style);
|
|
196 |
createBacterialNameParts(formElement, nonViralName, style);
|
|
326 | 197 |
break; |
327 | 198 |
case ICNCP: |
328 |
createCultivarNameParts(formElement, nonViralName, style);
|
|
199 |
createCultivarNameParts(formElement, nonViralName, style);
|
|
329 | 200 |
break; |
330 | 201 |
case NonViral: |
331 | 202 |
//TODO implement |
332 | 203 |
logger.warn("NonViral not yet implemented"); |
333 | 204 |
break; |
334 | 205 |
} |
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
|
|
339 |
private void createBacterialNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
340 |
IBacterialName bacterialName = (IBacterialName) nonViralName; |
|
341 |
text_subGenusAuthorship = formFactory.createTextWithLabelElement(formElement, "Subgenus Authorship", bacterialName.getSubGenusAuthorship(), style); |
|
342 |
// text_nameApprobation = formFactory.createTextWithLabelElement(formElement, "Name Approbation", bacterialName.getNameApprobation(), style); |
|
343 |
|
|
344 |
} |
|
345 |
|
|
346 |
private void updateBacterialNameParts(INonViralName nonViralName) { |
|
347 |
IBacterialName bacterialName = (IBacterialName) nonViralName; |
|
348 |
text_subGenusAuthorship.setText(bacterialName.getSubGenusAuthorship()); |
|
349 |
} |
|
350 |
|
|
351 |
private void createCultivarNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
352 |
ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName; |
|
353 |
text_cultivarName = formFactory.createTextWithLabelElement(formElement, "Cultivar Name", cultivarName.getCultivarName(), style); |
|
354 |
} |
|
355 |
|
|
356 |
private void updateCultivarNameParts(INonViralName nonViralName) { |
|
357 |
ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName; |
|
358 |
text_cultivarName.setText(cultivarName.getCultivarName()); |
|
359 |
} |
|
360 |
|
|
361 |
private void createBotanicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
362 |
//nothing to do |
|
363 |
} |
|
364 |
|
|
365 |
private void updateBotanicalNameParts(INonViralName nonViralName){ |
|
366 |
//nothing to do |
|
367 |
} |
|
368 |
|
|
369 |
private void createFungusNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
370 |
IFungusName fungusName= (IFungusName)nonViralName; |
|
371 |
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", fungusName.isAnamorphic(), style); |
|
372 |
} |
|
373 |
|
|
374 |
private void updateFungusNameParts(INonViralName nonViralName){ |
|
375 |
IFungusName fungusName= (IFungusName)nonViralName; |
|
376 |
checkbox_anamorphic.setSelection(fungusName.isAnamorphic()); |
|
377 |
} |
|
378 |
|
|
379 |
private void createZoologicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
380 |
IZoologicalName zoologicalName = (IZoologicalName) nonViralName; |
|
381 |
|
|
382 |
if (isAdvancedView){ |
|
383 |
text_breed = formFactory.createTextWithLabelElement(formElement, "Breed", zoologicalName.getBreed(), style); |
|
384 |
} |
|
385 |
} |
|
386 |
|
|
387 |
private void updateZoologicalNameParts(INonViralName nonViralName){ |
|
388 |
IZoologicalName zoologicalName = (IZoologicalName) nonViralName; |
|
389 |
if (isAdvancedView){ |
|
390 |
text_breed.setText(zoologicalName.getBreed()); |
|
391 |
} |
|
392 |
} |
|
393 |
|
|
394 |
private void createGenusOrUninomialControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
395 |
String title = "Genus"; |
|
396 |
Rank rank = nonViralName.getRank(); |
|
397 |
if(rank != null && rank.isSupraGeneric()){ |
|
398 |
title = "Uninomial"; |
|
399 |
} |
|
400 |
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style); |
|
401 |
} |
|
402 |
|
|
403 |
private void updateGenusOrUninomialControls(INonViralName nonViralName){ |
|
404 |
text_uninomial.setVisible(true); |
|
405 |
text_uninomial.setText(nonViralName.getGenusOrUninomial()); |
|
406 |
} |
|
407 |
|
|
408 |
private void createInfragenerericEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
409 |
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){ |
|
410 |
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){ |
|
411 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
|
412 |
return; |
|
413 |
} |
|
414 |
} else{ |
|
415 |
if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){ |
|
416 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
|
417 |
return; |
|
418 |
} |
|
419 |
} |
|
420 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", null, style); |
|
421 |
text_infragenericEpithet.setVisible(false); |
|
422 |
} |
|
423 |
|
|
424 |
private void updateInfragenerericEpithetControls(INonViralName nonViralName){ |
|
425 |
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){ |
|
426 |
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){ |
|
427 |
text_infragenericEpithet.setVisible(true); |
|
428 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
429 |
return; |
|
430 |
} |
|
431 |
} |
|
432 |
else if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){ |
|
433 |
text_infragenericEpithet.setVisible(true); |
|
434 |
text_infragenericEpithet.setText(nonViralName.getInfraGenericEpithet()); |
|
435 |
return; |
|
436 |
} |
|
437 |
if(text_infragenericEpithet!=null){ |
|
438 |
text_infragenericEpithet.setVisible(false); |
|
439 |
} |
|
440 |
} |
|
441 |
|
|
442 |
private void createSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
443 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
|
444 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL); |
|
445 |
return; |
|
446 |
} |
|
447 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", null, SWT.NULL); |
|
448 |
text_specificEpithet.setVisible(false); |
|
449 |
} |
|
450 |
|
|
451 |
private void updateSpecificEpithetControls(INonViralName nonViralName){ |
|
452 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
|
453 |
text_specificEpithet.setText(nonViralName.getSpecificEpithet()); |
|
454 |
text_specificEpithet.setVisible(true); |
|
455 |
return; |
|
456 |
} |
|
457 |
if(text_specificEpithet!=null){ |
|
458 |
text_specificEpithet.setVisible(false); |
|
459 |
} |
|
460 |
} |
|
461 |
|
|
462 |
private void createInfraSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
463 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){ |
|
464 |
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL); |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
private void updateInfraSpecificEpithetControls(INonViralName nonViralName){ |
|
469 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){ |
|
470 |
text_infraspecificEpithet.setVisible(true); |
|
471 |
text_infraspecificEpithet.setText(nonViralName.getInfraSpecificEpithet()); |
|
472 |
return; |
|
473 |
} |
|
474 |
if(text_infraspecificEpithet!=null){ |
|
475 |
text_infraspecificEpithet.setVisible(false); |
|
476 |
} |
|
477 |
} |
|
478 |
|
|
479 |
/** {@inheritDoc} */ |
|
480 |
@Override |
|
481 |
public void handleEvent(Object eventSource){ |
|
482 |
if (eventSource == toggleable_cache) { |
|
483 |
getEntity().setNameCache(toggleable_cache.getText(), |
|
484 |
toggleable_cache.getState()); |
|
485 |
//if (!isIrrelevant()) { |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
private void createBacterialNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
210 |
IBacterialName bacterialName = (IBacterialName) nonViralName; |
|
211 |
text_subGenusAuthorship = formFactory.createTextWithLabelElement(formElement, "Subgenus Authorship", bacterialName.getSubGenusAuthorship(), style); |
|
212 |
// text_nameApprobation = formFactory.createTextWithLabelElement(formElement, "Name Approbation", bacterialName.getNameApprobation(), style); |
|
213 |
} |
|
214 |
|
|
215 |
private void createCultivarNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style) { |
|
216 |
ICultivarPlantName cultivarName = (ICultivarPlantName)nonViralName; |
|
217 |
text_cultivarName = formFactory.createTextWithLabelElement(formElement, "Cultivar Name", cultivarName.getCultivarName(), style); |
|
218 |
} |
|
219 |
|
|
220 |
private void createBotanicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
221 |
//nothing to do |
|
222 |
} |
|
223 |
|
|
224 |
private void createFungusNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
225 |
IFungusName fungusName= (IFungusName)nonViralName; |
|
226 |
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", fungusName.isAnamorphic(), style); |
|
227 |
} |
|
228 |
|
|
229 |
private void createZoologicalNameParts(ICdmFormElement formElement, INonViralName nonViralName, int style){ |
|
230 |
IZoologicalName zoologicalName = (IZoologicalName) nonViralName; |
|
231 |
|
|
232 |
if (isAdvancedView){ |
|
233 |
text_breed = formFactory.createTextWithLabelElement(formElement, "Breed", zoologicalName.getBreed(), style); |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
private void createGenusOrUninomialControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
238 |
String title = "Genus"; |
|
239 |
Rank rank = nonViralName.getRank(); |
|
240 |
if(rank != null && rank.isSupraGeneric()){ |
|
241 |
title = "Uninomial"; |
|
242 |
} |
|
243 |
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style); |
|
244 |
} |
|
245 |
|
|
246 |
private void createInfragenerericEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
247 |
if (nonViralName.getNomenclaturalCode() == null || nonViralName.getNomenclaturalCode().equals(NomenclaturalCode.ICZN)){ |
|
248 |
if(nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS()) ){ |
|
249 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
|
250 |
} |
|
251 |
} else{ |
|
252 |
if((nonViralName.getRank() != null && nonViralName.getRank().isLower(Rank.GENUS())) && !nonViralName.getRank().isLower(Rank.SPECIES()) && !nonViralName.getRank().isSpeciesAggregate()){ |
|
253 |
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style); |
|
254 |
} |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
private void createSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
259 |
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){ |
|
260 |
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL); |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
private void createInfraSpecificEpithetControls(ICdmFormElement element, INonViralName nonViralName, int style){ |
|
265 |
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){ |
|
266 |
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL); |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 |
/** {@inheritDoc} */ |
|
271 |
@Override |
|
272 |
public void handleEvent(Object eventSource){ |
|
273 |
if (eventSource == toggleable_cache) { |
|
274 |
getEntity().setNameCache(toggleable_cache.getText(), |
|
275 |
toggleable_cache.getState()); |
|
276 |
//if (!isIrrelevant()) { |
|
486 | 277 |
setIrrelevant(toggleable_cache.getState(), |
487 |
Arrays.asList(new Object[] { toggleable_cache }));
|
|
278 |
Arrays.asList(new Object[] { toggleable_cache }));
|
|
488 | 279 |
//} |
489 |
}
|
|
490 |
else if(eventSource == combo_rank){
|
|
491 |
getEntity().setRank(combo_rank.getSelection());
|
|
492 |
clearCheckRankWarnings();
|
|
493 |
updateContent();
|
|
494 |
}
|
|
495 |
else if(eventSource == text_appendedPhrase){
|
|
496 |
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
|
|
497 |
}
|
|
498 |
else if(eventSource == text_infragenericEpithet){
|
|
499 |
getEntity().setInfraGenericEpithet(text_infragenericEpithet.getText());
|
|
500 |
}
|
|
501 |
else if(eventSource == text_infraspecificEpithet){
|
|
502 |
getEntity().setInfraSpecificEpithet(text_infraspecificEpithet.getText());
|
|
503 |
}
|
|
504 |
else if(eventSource == text_specificEpithet){
|
|
505 |
getEntity().setSpecificEpithet(text_specificEpithet.getText());
|
|
506 |
}
|
|
507 |
else if(eventSource == text_uninomial){
|
|
508 |
getEntity().setGenusOrUninomial(text_uninomial.getText());
|
|
509 |
}
|
|
510 |
else if(eventSource == checkbox_anamorphic){
|
|
511 |
((IFungusName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
|
|
512 |
}else if(eventSource == text_breed){
|
|
280 |
}
|
|
281 |
else if(eventSource == combo_rank){
|
|
282 |
getEntity().setRank(combo_rank.getSelection());
|
|
283 |
clearCheckRankWarnings();
|
|
284 |
updateContent();
|
|
285 |
}
|
|
286 |
else if(eventSource == text_appendedPhrase){
|
|
287 |
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
|
|
288 |
}
|
|
289 |
else if(eventSource == text_infragenericEpithet){
|
|
290 |
getEntity().setInfraGenericEpithet(text_infragenericEpithet.getText());
|
|
291 |
}
|
|
292 |
else if(eventSource == text_infraspecificEpithet){
|
|
293 |
getEntity().setInfraSpecificEpithet(text_infraspecificEpithet.getText());
|
|
294 |
}
|
|
295 |
else if(eventSource == text_specificEpithet){
|
|
296 |
getEntity().setSpecificEpithet(text_specificEpithet.getText());
|
|
297 |
}
|
|
298 |
else if(eventSource == text_uninomial){
|
|
299 |
getEntity().setGenusOrUninomial(text_uninomial.getText());
|
|
300 |
}
|
|
301 |
else if(eventSource == checkbox_anamorphic){
|
|
302 |
((IFungusName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
|
|
303 |
}else if(eventSource == text_breed){
|
|
513 | 304 |
((IZoologicalName)getEntity()).setBreed(text_breed.getText()); |
514 | 305 |
}else if(eventSource == this.text_cultivarName){ |
515 | 306 |
((ICultivarPlantName)getEntity()).setCultivarName(text_cultivarName.getText()); |
... | ... | |
517 | 308 |
((IBacterialName)getEntity()).setSubGenusAuthorship(text_subGenusAuthorship.getText()); |
518 | 309 |
} |
519 | 310 |
|
520 |
} |
|
521 |
|
|
522 |
/* |
|
523 |
* (non-Javadoc) |
|
524 |
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator() |
|
525 |
*/ |
|
526 |
/** |
|
527 |
* <p>Getter for the field <code>selectionArbitrator</code>.</p> |
|
528 |
* |
|
529 |
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object. |
|
530 |
*/ |
|
531 |
@Override |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
532 | 314 |
public SelectionArbitrator getSelectionArbitrator() { |
533 |
return selectionArbitrator;
|
|
534 |
}
|
|
535 |
|
|
536 |
@Override
|
|
537 |
public void updateToggleableCacheField() {
|
|
538 |
if (toggleable_cache != null){
|
|
539 |
if(! getEntity().isProtectedNameCache()){
|
|
540 |
toggleable_cache.setText(getEntity().getNameCache());
|
|
541 |
}
|
|
542 |
}
|
|
543 |
}
|
|
544 |
|
|
545 |
@Override
|
|
546 |
protected void handleToggleableCacheField() {
|
|
315 |
return selectionArbitrator;
|
|
316 |
}
|
|
317 |
|
|
318 |
@Override
|
|
319 |
public void updateToggleableCacheField() {
|
|
320 |
if (toggleable_cache != null){
|
|
321 |
if(! getEntity().isProtectedNameCache()){
|
|
322 |
toggleable_cache.setText(getEntity().getNameCache());
|
|
323 |
}
|
|
324 |
}
|
|
325 |
}
|
|
326 |
|
|
327 |
@Override
|
|
328 |
protected void handleToggleableCacheField() {
|
|
547 | 329 |
boolean pushedState = toggleable_cache.getState(); |
548 | 330 |
|
549 | 331 |
getEntity().setTitleCache(toggleable_cache.getText(), pushedState); |
... | ... | |
551 | 333 |
updateToggleableCacheField(); |
552 | 334 |
} |
553 | 335 |
|
554 |
@Override |
|
555 |
public void setIrrelevant(boolean irrelevant, Collection<Object> except){ |
|
556 |
if (toggleable_cache != null){ |
|
557 |
if (toggleable_cache.getState() == irrelevant){ |
|
558 |
super.setIrrelevant(irrelevant, except); |
|
559 |
} |
|
560 |
if (except == null || except.isEmpty()){ |
|
561 |
toggleable_cache.setIrrelevant(irrelevant); |
|
562 |
} |
|
563 |
} |
|
564 |
|
|
565 |
} |
|
566 |
|
|
567 |
|
|
568 |
|
|
336 |
@Override |
|
337 |
public void setIrrelevant(boolean irrelevant, Collection<Object> except){ |
|
338 |
if (toggleable_cache != null){ |
|
339 |
if (toggleable_cache.getState() == irrelevant){ |
|
340 |
super.setIrrelevant(irrelevant, except); |
|
341 |
} |
|
342 |
if (except == null || except.isEmpty()){ |
|
343 |
toggleable_cache.setIrrelevant(irrelevant); |
|
344 |
} |
|
345 |
} |
|
346 |
} |
|
569 | 347 |
|
570 | 348 |
} |
Also available in: Unified diff
ref #6554 Revert caching of NameDetailElement