Show abbreviated title cache for authors and refernce in taxon details
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 29 Jun 2015 12:26:07 +0000 (14:26 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 29 Jun 2015 12:26:50 +0000 (14:26 +0200)
view

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
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/reference/NomenclaturalReferenceDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementWithAbbreviatedTitle.java [new file with mode: 0644]

index e06114f57c2d9099356fbe61c1d85a496fadd13e..f44a4373b407d2b2a28714ee2ea585313e60e27a 100644 (file)
@@ -323,6 +323,7 @@ import eu.etaxonomy.taxeditor.ui.section.vocabulary.StatisticalMeasureCollection
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailElement;
 import eu.etaxonomy.taxeditor.ui.section.vocabulary.TermVocabularyDetailSection;
 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
+import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElementWithAbbreviatedTitle;
 import eu.etaxonomy.taxeditor.ui.selection.NomenclaturalAuthorTeamSelectionElement;
 import eu.etaxonomy.taxeditor.ui.selection.TaxonNodeSelectionElement;
 
@@ -2616,6 +2617,48 @@ public class CdmFormFactory extends FormToolkit {
         return element;
     }
 
+    /**
+     * <p>
+     * Creates a selection element for the given type T which shows only the <b>abbreviated</b> title as the label.
+     * </p>
+     * <p>
+     * <strong>Selection elements not handled by this method:</strong>
+     * <ul>
+     * <li>{@link TaxonNodeSelectionElement} see
+     * {@link #createTaxonNodeSelectionElement(ConversationHolder, ICdmFormElement, String, TaxonNode, int, int)}
+     * </li>
+     * <li>{@link NomenclaturalAuthorTeamSelectionElement} see
+     * {@link #createNomenclaturalAuthorTeamSelectionElement(ConversationHolder, ICdmFormElement, String, Team, int, int)}
+     * </li>
+     * </ul>
+     * </p>
+     *
+     * @param clazz
+     *            a {@link Class} object of the type that you want the selection
+     *            element to handle
+     * @param parentElement
+     *            a {@link ICdmFormElement} object.
+     * @param labelString
+     *            a {@link String} object.
+     * @param selectionType
+     * @param selection
+     *            a {@link ICdmBase} object.
+     * @param style
+     *            a int.
+     * @param conversation
+     *            a {@link ConversationHolder} object.
+     * @return a {@link EntitySelectionElement} object.
+     */
+    public <T extends ICdmBase> EntitySelectionElementWithAbbreviatedTitle<T> createSelectionElementWithAbbreviatedTitle(
+            Class<T> clazz, ConversationHolder conversation, ICdmFormElement parentElement, String labelString,
+            T selection, int mode, int style) {
+        EntitySelectionElementWithAbbreviatedTitle<T> element = new EntitySelectionElementWithAbbreviatedTitle<T>(this, conversation, parentElement, clazz,
+                labelString, selection, mode, style);
+        adapt(element);
+        parentElement.addElement(element);
+        return element;
+    }
+
     public TaxonNodeSelectionElement createTaxonNodeSelectionElement(ConversationHolder conversation,
             ICdmFormElement parentElement, String labelString, TaxonNode selection, int mode, int style) {
         TaxonNodeSelectionElement element = new TaxonNodeSelectionElement(this, conversation, parentElement,
index 23b0ca82f1cd505dacf8e93aa1664498b522856b..9e672a485ac361830c7c647b95f06918d24bdd08 100644 (file)
@@ -69,23 +69,23 @@ public class AuthorshipDetailElement extends
                if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.IS_RL)){
                        toggleable_cache.setVisible(false);
                }
-               selectionCombinationAuthor = formFactory.createSelectionElement(TeamOrPersonBase.class,
+               selectionCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Author",
                                entity.getCombinationAuthorship(),
                                EntitySelectionElement.ALL, style);
                addElement(selectionCombinationAuthor);
-               selectionExCombinationAuthor = formFactory.createSelectionElement(TeamOrPersonBase.class,
+               selectionExCombinationAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class,
                                getConversationHolder(),
                                formElement, "Ex Author",
                                entity.getExCombinationAuthorship(),
                                EntitySelectionElement.ALL, style);
                addElement(selectionExCombinationAuthor);
-               selectionBasionymAuthor = formFactory.createSelectionElement(TeamOrPersonBase.class, getConversationHolder(),
+               selectionBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
                 formElement, "Basionym Author", entity.getBasionymAuthorship(),
                 EntitySelectionElement.ALL, style);
                addElement(selectionBasionymAuthor);
-               selectionExBasionymAuthor = formFactory.createSelectionElement(TeamOrPersonBase.class, getConversationHolder(),
+               selectionExBasionymAuthor = formFactory.createSelectionElementWithAbbreviatedTitle(TeamOrPersonBase.class, getConversationHolder(),
                        formElement, "Ex Basionym Author", entity.getExBasionymAuthorship(),
                        EntitySelectionElement.ALL, style);
 
index 977e56d64c9a29b1f5972074356fa2243d183275..c9c4fbb12ee41daf3599dc76b317edc691b357de 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.
  */
@@ -22,7 +22,7 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  * <p>
  * NomenclaturalReferenceDetailElement class.
  * </p>
- * 
+ *
  * @author n.hoffmann
  * @created Mar 12, 2010
  * @version 1.0
@@ -37,7 +37,7 @@ public class NomenclaturalReferenceDetailElement extends
         * <p>
         * Constructor for NomenclaturalReferenceDetailElement.
         * </p>
-        * 
+        *
         * @param cdmFormFactory
         *            a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory}
         *            object.
@@ -57,7 +57,7 @@ public class NomenclaturalReferenceDetailElement extends
        protected void createControls(ICdmFormElement formElement,
                        TaxonNameBase entity, int style) {
                selection_nomenclaturalReference = formFactory
-                               .createSelectionElement(Reference.class,
+                               .createSelectionElementWithAbbreviatedTitle(Reference.class,
                                                getConversationHolder(), formElement, "Reference",
                                                (Reference) entity.getNomenclaturalReference(),
                                                EntitySelectionElement.ALL, style);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementWithAbbreviatedTitle.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EntitySelectionElementWithAbbreviatedTitle.java
new file mode 100644 (file)
index 0000000..5c2a267
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.ui.selection;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+
+public class EntitySelectionElementWithAbbreviatedTitle<T extends ICdmBase> extends EntitySelectionElement<T> {
+
+       /**
+     * @param formFactory
+     * @param conversation
+     * @param parentElement
+     * @param clazz
+     * @param labelString
+     * @param entity
+     * @param mode
+     * @param style
+     */
+    public EntitySelectionElementWithAbbreviatedTitle(CdmFormFactory formFactory, ConversationHolder conversation,
+            ICdmFormElement parentElement, Class<T> clazz, String labelString, T entity, int mode, int style) {
+        super(formFactory, conversation, parentElement, clazz, labelString, entity, mode, style);
+    }
+
+    @Override
+    protected String getTitle() {
+               if (entity != null){
+                   if(entity instanceof TeamOrPersonBase) {
+                       return ((TeamOrPersonBase) entity).getNomenclaturalTitle();
+                   } else if(entity instanceof Reference){
+                       return ((Reference) entity).getAbbrevTitleCache();
+                   } else{
+                       return super.getTitle();
+                   }
+               }
+               return "";
+       }
+}