// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
import java.util.Arrays;
+import org.apache.log4j.Logger;
import org.eclipse.swt.SWT;
import eu.etaxonomy.cdm.model.name.BotanicalName;
*/
public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<NonViralName> implements ISelectableElement, IEnableableFormElement{
+ private final Logger logger = Logger.getLogger(NameDetailElement.class);
+
private TermComboElement<Rank> combo_rank;
private TextWithLabelElement text_appendedPhrase;
private TextWithLabelElement text_uninomial;
private NumberWithLabelElement text_publicationYear;
private NumberWithLabelElement text_originalPublicationYear;
private int cursorPosition;
-
+
/**
* <p>Constructor for NameDetailElement.</p>
*
/** {@inheritDoc} */
@Override
protected void createControls(ICdmFormElement formElement, NonViralName nonViralName, int style) {
-
+
toggleable_cache = formFactory.createToggleableTextField(this, "Name Cache", nonViralName.getNameCache(), nonViralName.isProtectedNameCache(), style);
-
+
combo_rank = formFactory.createTermComboElement(Rank.class, this, "Rank", nonViralName.getRank(), style);
-
+
createGenusOrUninomialControls(this, nonViralName, style);
createInfragenerericEpithetControls(this, nonViralName, style);
createSpecificEpithetControls(this, nonViralName, style);
createInfraSpecificEpithetControls(this, nonViralName, style);
-
+
createSpecificNameParts(this, nonViralName, style);
-
+
text_appendedPhrase = formFactory.createTextWithLabelElement(formElement, "Appended Phrase", nonViralName.getAppendedPhrase(), style);
-
+
}
/**
protected void clearCheckRankWarnings() {
if(getEntity().hasProblem(ParserProblem.CheckRank)){
getEntity().removeParsingProblem(ParserProblem.CheckRank);
-
+
// FIXME this has to be reafctored completely. See tickets #1959, #1663, #1957, #1958
// TaxonNameEditor nameEditor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
// nameEditor.getSelectedContainer().getNameViewer().clearErrors();
}
}
-
+
/** {@inheritDoc} */
@Override
protected void updateContent() {
if(getEntity() == null){
setEntity(NonViralName.NewInstance(null));
}
-
+
super.updateContent();
-
+
if(isIrrelevant()){
setIrrelevant(isIrrelevant());
}else{
case ICZN:
createZoologicalNameParts(formElement, nonViralName, style);
break;
+ case ICVCN:
+ //TODO implement
+ logger.warn("ICVCN not yet implemented");
+ break;
+ case ICNB:
+ //TODO implement
+ logger.warn("ICNB not yet implemented");
+ break;
+ case ICNCP:
+ //TODO implement
+ logger.warn("ICNCP not yet implemented");
+ break;
}
}
}
-
+
private void createBotanicalNameParts(ICdmFormElement formElement, NonViralName nonViralName, int style){
BotanicalName botanicalName = (BotanicalName) nonViralName;
checkbox_anamorphic = formFactory.createCheckbox(formElement, "Anamorphic", botanicalName.isAnamorphic(), style);
text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", zoologicalName.getPublicationYear(), style);
text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", zoologicalName.getOriginalPublicationYear(), style);
}
-
- private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){
+
+ private void createGenusOrUninomialControls(ICdmFormElement element, NonViralName nonViralName, int style){
String title = "Genus";
Rank rank = nonViralName.getRank();
if(rank != null && rank.isSupraGeneric()){
- title = "Uninomial";
+ title = "Uninomial";
}
text_uninomial = formFactory.createTextWithLabelElement(element, title, nonViralName.getGenusOrUninomial(), style);
}
-
+
private void createInfragenerericEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraGeneric() && !nonViralName.getRank().isSpeciesAggregate()){
text_infragenericEpithet = formFactory.createTextWithLabelElement(element, "Infrageneric Epithet", nonViralName.getInfraGenericEpithet(), style);
}
}
-
+
private void createSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && (nonViralName.getRank().isSpecies() || nonViralName.getRank().isInfraSpecific() || nonViralName.getRank().isSpeciesAggregate())){
text_specificEpithet = formFactory.createTextWithLabelElement(element, "Specific Epithet", nonViralName.getSpecificEpithet(), SWT.NULL);
}
}
-
+
private void createInfraSpecificEpithetControls(ICdmFormElement element, NonViralName nonViralName, int style){
if(nonViralName.getRank() != null && nonViralName.getRank().isInfraSpecific()){
text_infraspecificEpithet = formFactory.createTextWithLabelElement(element, "Infraspecific Epithet", nonViralName.getInfraSpecificEpithet(), SWT.NULL);
}
}
-
+
/** {@inheritDoc} */
@Override
public void handleEvent(Object eventSource){
if (eventSource == toggleable_cache) {
getEntity().setNameCache(toggleable_cache.getText(),
toggleable_cache.getState());
- if (!isIrrelevant())
- setIrrelevant(toggleable_cache.getState(),
+ if (!isIrrelevant()) {
+ setIrrelevant(toggleable_cache.getState(),
Arrays.asList(new Object[] { toggleable_cache }));
+ }
}
else if(eventSource == combo_rank){
getEntity().setRank(combo_rank.getSelection());
clearCheckRankWarnings();
updateContent();
- }
+ }
else if(eventSource == text_appendedPhrase){
getEntity().setAppendedPhrase(text_appendedPhrase.getText());
}
}
else if(eventSource == text_uninomial){
getEntity().setGenusOrUninomial(text_uninomial.getText());
- }
+ }
else if(eventSource == checkbox_anamorphic){
((BotanicalName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
}
}
-
+
/*
* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.forms.section.cdmdetail.ISelectableElement#getSelectionArbitrator()
*
* @return a {@link eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator} object.
*/
- public SelectionArbitrator getSelectionArbitrator() {
+ @Override
+ public SelectionArbitrator getSelectionArbitrator() {
return selectionArbitrator;
}
-
+
@Override
public void updateToggleableCacheField() {
if(! getEntity().isProtectedNameCache()){