add original publication year to simple details view
authorKatja Luther <k.luther@bgbm.org>
Tue, 7 Jun 2016 08:12:03 +0000 (10:12 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 7 Jun 2016 08:12:03 +0000 (10:12 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AuthorshipDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameDetailElement.java

index c52cacf451d98f51195bf35f165f409282da938b..ae3f52b4d6ecf2e596aabc50c8e7e776ce7a79fe 100644 (file)
@@ -13,12 +13,15 @@ package eu.etaxonomy.taxeditor.ui.section.name;
 import java.util.Arrays;
 
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
 import eu.etaxonomy.cdm.model.name.NonViralName;
+import eu.etaxonomy.cdm.model.name.ZoologicalName;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
 
@@ -38,6 +41,9 @@ public class AuthorshipDetailElement extends
     private EntitySelectionElement<TeamOrPersonBase> selectionBasionymAuthor;
     private EntitySelectionElement<TeamOrPersonBase> selectionExCombinationAuthor;
     private EntitySelectionElement<TeamOrPersonBase> selectionCombinationAuthor;
+
+    private NumberWithLabelElement text_publicationYear;
+    private NumberWithLabelElement text_originalPublicationYear;
        /**
         * <p>
         * Constructor for AuthorshipDetailElement.
@@ -70,8 +76,9 @@ public class AuthorshipDetailElement extends
                 toggleable_cache.setVisible(false);
             }
            }
+           NomenclaturalCode code = entity.getNomenclaturalCode();
 
-               selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
+        selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Author",
                                entity.getCombinationAuthorship(),
@@ -83,6 +90,12 @@ public class AuthorshipDetailElement extends
                                entity.getExCombinationAuthorship(),
                                EntitySelectionElement.ALL, style);
                addElement(selectionExCombinationAuthor);
+               if (code != null){
+            if (code.equals(NomenclaturalCode.ICZN)){
+                text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", ((ZoologicalName)entity).getPublicationYear(), style);
+
+            }
+         }
                selectionBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
                 formElement, "Basionym Author", entity.getBasionymAuthorship(),
                 EntitySelectionElement.ALL, style);
@@ -92,6 +105,16 @@ public class AuthorshipDetailElement extends
                        EntitySelectionElement.ALL, style);
 
                addElement(selectionExBasionymAuthor);
+                if (code != null){
+                   if (code.equals(NomenclaturalCode.ICZN)){
+
+                       text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", ((ZoologicalName)entity).getOriginalPublicationYear(), style);
+
+                   }
+                }
+
+
+
        }
 
        /** {@inheritDoc} */
@@ -137,7 +160,11 @@ public class AuthorshipDetailElement extends
                } else if (eventSource == selectionExBasionymAuthor) {
                        getEntity().setExBasionymAuthorship(
                                        selectionExBasionymAuthor.getSelection());
-               }
+               } else if (eventSource == text_originalPublicationYear) {
+            ((ZoologicalName)getEntity()).setOriginalPublicationYear(text_originalPublicationYear.getInteger());
+        } else if (eventSource == text_publicationYear) {
+            ((ZoologicalName)getEntity()).setPublicationYear(text_publicationYear.getInteger());
+        }
 
 //             if (eventSource != toggleable_cache) {
 //                     toggleable_cache.setText(getEntity().getAuthorshipCache());
index f663b2876bfd9d28f47090cf9f0d532dcb712121..eb878529310ad32ad74693e3f52b650d69eb6f69 100644 (file)
@@ -30,7 +30,6 @@ import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
 import eu.etaxonomy.taxeditor.ui.element.ISelectableElement;
-import eu.etaxonomy.taxeditor.ui.element.NumberWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
@@ -55,8 +54,8 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
        private SelectionArbitrator selectionArbitrator;
        private CheckboxElement checkbox_anamorphic;
        private TextWithLabelElement text_breed;
-       private NumberWithLabelElement text_publicationYear;
-       private NumberWithLabelElement text_originalPublicationYear;
+       //private NumberWithLabelElement text_publicationYear;
+       //private NumberWithLabelElement text_originalPublicationYear;
        private int cursorPosition;
 
        /**
@@ -164,10 +163,9 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
 
        private void createZoologicalNameParts(ICdmFormElement formElement, NonViralName nonViralName, int style){
                ZoologicalName zoologicalName = (ZoologicalName) nonViralName;
-               text_publicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Publication Year", zoologicalName.getPublicationYear(), style);
+
                if (isAdvancedView){
                    text_breed = formFactory.createTextWithLabelElement(formElement, "Breed", zoologicalName.getBreed(), style);
-                       text_originalPublicationYear = formFactory.createNumberTextWithLabelElement(formElement, "Orig. Publication Year", zoologicalName.getOriginalPublicationYear(), style);
                }
        }
 
@@ -231,7 +229,10 @@ public class NameDetailElement extends AbstractIdentifiableEntityDetailElement<N
                }
                else if(eventSource == checkbox_anamorphic){
                        ((BotanicalName)getEntity()).setAnamorphic(checkbox_anamorphic.getSelection());
-               }
+               }else if(eventSource == text_breed){
+            ((ZoologicalName)getEntity()).setBreed(text_breed.getText());
+        }
+
        }
 
        /*