Merge branch 'release/3.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / name / AuthorshipDetailElement.java
index e1693f05f513bd5f3c8a1c1a72a140fdaf6717a9..9e672a485ac361830c7c647b95f06918d24bdd08 100644 (file)
@@ -1,9 +1,9 @@
 // $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.
  */
@@ -12,40 +12,37 @@ package eu.etaxonomy.taxeditor.ui.section.name;
 
 import java.util.Arrays;
 
-import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.name.NonViralName;
-import eu.etaxonomy.taxeditor.model.AuthorHelper;
-import eu.etaxonomy.taxeditor.ui.campanula.compatibility.ICdmFormElement;
+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.IEnableableFormElement;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
-import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
 
 /**
  * <p>
  * AuthorshipDetailElement class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Mar 4, 2010
  * @version 1.0
  */
 public class AuthorshipDetailElement extends
-       AbstractIdentifiableEntityDetailElement<NonViralName> implements
-               IEnableableFormElement {
-
-       private NomenclaturalAuthorTeamSelectionElement selection_exBasionymAuthorTeam;
-       private NomenclaturalAuthorTeamSelectionElement selection_basionymAuthorTeam;
-       private NomenclaturalAuthorTeamSelectionElement selection_exCombinationAuthorTeam;
-       private NomenclaturalAuthorTeamSelectionElement selection_combinationAuthorTeam;
+       AbstractIdentifiableEntityDetailElement<NonViralName> {
 
+    private EntitySelectionElement<TeamOrPersonBase> selectionExBasionymAuthor;
+    private EntitySelectionElement<TeamOrPersonBase> selectionBasionymAuthor;
+    private EntitySelectionElement<TeamOrPersonBase> selectionExCombinationAuthor;
+    private EntitySelectionElement<TeamOrPersonBase> selectionCombinationAuthor;
        /**
         * <p>
         * Constructor for AuthorshipDetailElement.
         * </p>
-        * 
+        *
         * @param cdmFormFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -67,30 +64,32 @@ public class AuthorshipDetailElement extends
                toggleable_cache = formFactory.createToggleableTextField(this,
                                "Authorship Cache", entity.getAuthorshipCache(),
                                entity.isProtectedAuthorshipCache(), style);
-               selection_combinationAuthorTeam = formFactory.createNomenclaturalAuthorTeamSelectionElement(
+
+               //TODO RL
+               if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
+                       toggleable_cache.setVisible(false);
+               }
+               selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Author",
-                               AuthorHelper.getAuthor(entity.getCombinationAuthorTeam()),
+                               entity.getCombinationAuthorship(),
                                EntitySelectionElement.ALL, style);
-               addElement(selection_combinationAuthorTeam);
-               selection_exCombinationAuthorTeam = formFactory.createNomenclaturalAuthorTeamSelectionElement(
+               addElement(selectionCombinationAuthor);
+               selectionExCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Ex Author",
-                               AuthorHelper.getAuthor(entity.getExCombinationAuthorTeam()),
-                               EntitySelectionElement.ALL, style);
-               addElement(selection_exCombinationAuthorTeam);
-               selection_basionymAuthorTeam = formFactory.createNomenclaturalAuthorTeamSelectionElement(
-                               getConversationHolder(),
-                               formElement, "Basionym Author",
-                               AuthorHelper.getAuthor(entity.getBasionymAuthorTeam()),
+                               entity.getExCombinationAuthorship(),
                                EntitySelectionElement.ALL, style);
-               addElement(selection_basionymAuthorTeam);
-               selection_exBasionymAuthorTeam = formFactory.createNomenclaturalAuthorTeamSelectionElement(
-                               getConversationHolder(),
-                               formElement, "Ex Basionym Author",
-                               AuthorHelper.getAuthor(entity.getExBasionymAuthorTeam()),
-                               EntitySelectionElement.ALL, style);
-               addElement(selection_exBasionymAuthorTeam);
+               addElement(selectionExCombinationAuthor);
+               selectionBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
+                formElement, "Basionym Author", entity.getBasionymAuthorship(),
+                EntitySelectionElement.ALL, style);
+               addElement(selectionBasionymAuthor);
+               selectionExBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
+                       formElement, "Ex Basionym Author", entity.getExBasionymAuthorship(),
+                       EntitySelectionElement.ALL, style);
+
+               addElement(selectionExBasionymAuthor);
        }
 
        /** {@inheritDoc} */
@@ -99,7 +98,7 @@ public class AuthorshipDetailElement extends
                if (getEntity() == null) {
                        setEntity(NonViralName.NewInstance(null));
                }
-               
+
                super.updateContent();
                toggleable_cache.setEnabled(getEntity().isProtectedAuthorshipCache());
 
@@ -117,25 +116,22 @@ public class AuthorshipDetailElement extends
                if (eventSource == toggleable_cache) {
                        getEntity().setAuthorshipCache(toggleable_cache.getText(),
                                        toggleable_cache.getState());
-                       if (!isIrrelevant())
+                       if (!isIrrelevant()){
                                setIrrelevant(toggleable_cache.getState(),
                                                Arrays.asList(new Object[] { toggleable_cache }));
-               } else if (eventSource == selection_combinationAuthorTeam) {
-                       getEntity().setCombinationAuthorTeam(
-                                       (INomenclaturalAuthor) selection_combinationAuthorTeam
-                                                       .getSelection());
-               } else if (eventSource == selection_exCombinationAuthorTeam) {
-                       getEntity().setExCombinationAuthorTeam(
-                                       (INomenclaturalAuthor) selection_exCombinationAuthorTeam
-                                                       .getSelection());
-               } else if (eventSource == selection_basionymAuthorTeam) {
-                       getEntity().setBasionymAuthorTeam(
-                                       (INomenclaturalAuthor) selection_basionymAuthorTeam
-                                                       .getSelection());
-               } else if (eventSource == selection_exBasionymAuthorTeam) {
-                       getEntity().setExBasionymAuthorTeam(
-                                       (INomenclaturalAuthor) selection_exBasionymAuthorTeam
-                                                       .getSelection());
+                       }
+               } else if (eventSource == selectionCombinationAuthor) {
+                       getEntity().setCombinationAuthorship(
+                                       selectionCombinationAuthor.getSelection());
+               } else if (eventSource == selectionExCombinationAuthor) {
+                       getEntity().setExCombinationAuthorship(
+                                       selectionExCombinationAuthor.getSelection());
+               } else if (eventSource == selectionBasionymAuthor) {
+                       getEntity().setBasionymAuthorship(
+                                       selectionBasionymAuthor.getSelection());
+               } else if (eventSource == selectionExBasionymAuthor) {
+                       getEntity().setExBasionymAuthorship(
+                                       selectionExBasionymAuthor.getSelection());
                }
 
 //             if (eventSource != toggleable_cache) {
@@ -149,7 +145,7 @@ public class AuthorshipDetailElement extends
                        firePropertyChangeEvent(new CdmPropertyChangeEvent(
                                        getParentElement(), null));
        }
-       
+
        @Override
        public void updateToggleableCacheField() {
                if(! getEntity().isProtectedAuthorshipCache()){