selectiondialog for nomenclatural authors should work on nomenclatural
authorKatja Luther <k.luther@bgbm.org>
Wed, 25 May 2016 08:19:40 +0000 (10:19 +0200)
committerKatja Luther <k.luther@bgbm.org>
Wed, 25 May 2016 08:46:28 +0000 (10:46 +0200)
title

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java
new file mode 100644 (file)
index 0000000..6ccfbc3
--- /dev/null
@@ -0,0 +1,84 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2016 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.ui.dialog.selection;\r
+\r
+import org.eclipse.swt.widgets.Shell;\r
+\r
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;\r
+import eu.etaxonomy.cdm.api.service.IAgentService;\r
+import eu.etaxonomy.cdm.model.agent.AgentBase;\r
+import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;\r
+import eu.etaxonomy.taxeditor.store.CdmStore;\r
+\r
+/**\r
+ * @author k.luther\r
+ * @date 25.05.2016\r
+ *\r
+ */\r
+public class NomenclaturalAuthorSelectionDialog extends AgentSelectionDialog {\r
+\r
+\r
+    /**\r
+     * @param shell\r
+     * @param conversation\r
+     * @param title\r
+     * @param multi\r
+     * @param settings\r
+     * @param agent\r
+     */\r
+    protected NomenclaturalAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,\r
+            boolean multi, String settings, AgentBase agent) {\r
+        super(shell, conversation, title, multi, settings, agent);\r
+        // TODO Auto-generated constructor stub\r
+    }\r
+\r
+    @Override\r
+    protected void initModel() {\r
+        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null);\r
+    }\r
+\r
+    /**\r
+     * <p>select</p>\r
+     *\r
+     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.\r
+     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.\r
+     * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.\r
+     * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.\r
+     */\r
+    public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity) {\r
+        NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, conversation,\r
+                "Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity);\r
+        return getSelectionFromDialog(dialog);\r
+    }\r
+\r
+    /**\r
+     * <p>getTitle</p>\r
+     *\r
+     * @param cdmObject a T object.\r
+     * @return a {@link java.lang.String} object.\r
+     */\r
+    @Override\r
+    protected String getTitle(AgentBase cdmObject) {\r
+        if(cdmObject == null){\r
+            return "";\r
+        }\r
+\r
+        if (cdmObject instanceof TeamOrPersonBase) {\r
+            return ((TeamOrPersonBase) cdmObject).getNomenclaturalTitle();\r
+        } else if (cdmObject instanceof AgentBase){\r
+            return ((TeamOrPersonBase) cdmObject).getTitleCache();\r
+        }\r
+\r
+        throw new IllegalArgumentException("Generic method only" +\r
+                " supports cdmObject of type IIdentifiableEntity." +\r
+                " Please implement specific method in subclass.");\r
+    }\r
+\r
+}\r
index a90ce1c9bca1c861a41b1d44c3dcd2411259cd3b..70cdd0fb3e6533a2530fcb17043d661f52218f45 100644 (file)
@@ -44,6 +44,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
+import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
 
 /**
  * @author n.hoffmann
@@ -82,10 +83,13 @@ public class SelectionDialogFactory {
                if(clazz.equals(Team.class)){
                        return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
                }
-               if(clazz.equals(TeamOrPersonBase.class)){
+               if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){
+            return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
+        }else if(clazz.equals(TeamOrPersonBase.class)){
                    //TODO: add TeamOrPersonBaseSelectionDialog (see ticket #4545)
                    return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
                }
+
                if(clazz.equals(AgentBase.class)){
                        return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
                }