fix NPE for first search
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / NomenclaturalAuthorTeamSelectionDialog.java
index f43399142cfd9d64b25c9d11dad73b657aae3182..1725708606317ac38f886157fc5331b23f79aa87 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
 /**
 * Copyright (C) 2007 EDIT
 * European Distributed Institute of Taxonomy
@@ -14,9 +13,10 @@ import java.util.UUID;
 
 import org.eclipse.swt.widgets.Shell;
 
 
 import org.eclipse.swt.widgets.Shell;
 
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.IAgentService;
+import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.cdm.model.agent.Team;
 import eu.etaxonomy.cdm.model.agent.Team;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.newWizard.NewTeamWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.newWizard.NewTeamWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -29,7 +29,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @version 1.0
  */
 public class NomenclaturalAuthorTeamSelectionDialog extends
  * @version 1.0
  */
 public class NomenclaturalAuthorTeamSelectionDialog extends
-       AbstractFilteredCdmResourceSelectionDialog<Team> {
+       AbstractFilteredCdmResourceSelectionDialog<AgentBase> {
 
        /**
         * <p>select</p>
 
        /**
         * <p>select</p>
@@ -39,10 +39,11 @@ public class NomenclaturalAuthorTeamSelectionDialog extends
         * @param team a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         * @return a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         */
         * @param team a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         * @return a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         */
-       public static Team select(Shell shell, ConversationHolder conversation, Team team){
-               NomenclaturalAuthorTeamSelectionDialog dialog = new NomenclaturalAuthorTeamSelectionDialog(shell, conversation,
+       public static Team select(Shell shell, //ConversationHolder conversation,
+               Team team){
+               NomenclaturalAuthorTeamSelectionDialog dialog = new NomenclaturalAuthorTeamSelectionDialog(shell, //conversation,
                                "Choose Author Team", false, NomenclaturalAuthorTeamSelectionDialog.class.getCanonicalName(), team);
                                "Choose Author Team", false, NomenclaturalAuthorTeamSelectionDialog.class.getCanonicalName(), team);
-               return getSelectionFromDialog(dialog);
+               return (Team)getSelectionFromDialog(dialog);
        }
 
        /**
        }
 
        /**
@@ -55,32 +56,48 @@ public class NomenclaturalAuthorTeamSelectionDialog extends
         * @param settings a {@link java.lang.String} object.
         * @param agent a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         */
         * @param settings a {@link java.lang.String} object.
         * @param agent a {@link eu.etaxonomy.cdm.model.agent.Team} object.
         */
-       protected NomenclaturalAuthorTeamSelectionDialog(Shell shell, ConversationHolder conversation, String title,
+       protected NomenclaturalAuthorTeamSelectionDialog(Shell shell, //ConversationHolder conversation,
+               String title,
                        boolean multi, String settings, Team agent) {
                        boolean multi, String settings, Team agent) {
-               super(shell, conversation, title, multi, settings, agent);
+               super(shell, //conversation,
+                       title, multi, settings, agent);
        }
 
        /** {@inheritDoc} */
        @Override
        protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
        }
 
        /** {@inheritDoc} */
        @Override
        protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
-               return new NewTeamWizard();
+               return new NewTeamWizard(true);
        }
 
        /** {@inheritDoc} */
        @Override
        }
 
        /** {@inheritDoc} */
        @Override
-       protected String getNewWizardLinkText() {
-               return String.format("Create a new <a>%1s</a>", "Team ");
+       protected String[] getNewWizardText() {
+               return new String[]{"new Team"};
        }
 
        }
 
-       /** {@inheritDoc} */
-       @Override
-       protected void initModel() {
-               model = CdmStore.getService(IAgentService.class).getTeamUuidAndNomenclaturalTitle();
-       }
+//     /** {@inheritDoc} */
+//     @Override
+//     protected void search() {
+//         Control control =getSearchField();
+//        String pattern = null;
+//        if (control != null){
+//            pattern = ((Text)control).getText();
+//        }
+//
+//             model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
+//     }
 
        /** {@inheritDoc} */
        @Override
        protected Team getPersistentObject(UUID uuid) {
 
        /** {@inheritDoc} */
        @Override
        protected Team getPersistentObject(UUID uuid) {
-               return (Team) CdmStore.getService(IAgentService.class).load(uuid);
+               return CdmBase.deproxy(CdmStore.getService(IAgentService.class).load(uuid), Team.class) ;
        }
        }
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog#callService(java.lang.String)
+     */
+    @Override
+    void callService(String pattern) {
+        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
+    }
 }
 }