Merge branch 'develop' into feature/cdm-4.7
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / InstitutionSelectionDialog.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.dialog.selection;
11
12 import java.util.UUID;
13
14 import org.eclipse.swt.widgets.Shell;
15
16 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
17 import eu.etaxonomy.cdm.api.service.IAgentService;
18 import eu.etaxonomy.cdm.model.agent.AgentBase;
19 import eu.etaxonomy.cdm.model.agent.Institution;
20 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
21 import eu.etaxonomy.taxeditor.newWizard.NewInstitutionWizard;
22 import eu.etaxonomy.taxeditor.store.CdmStore;
23
24 /**
25 * @author n.hoffmann
26 * @created Dec 15, 2010
27 * @version 1.0
28 */
29 public class InstitutionSelectionDialog extends
30 AbstractFilteredCdmResourceSelectionDialog<Institution> {
31
32 public static Institution select(Shell shell, ConversationHolder conversation, Institution institution){
33 InstitutionSelectionDialog dialog = new InstitutionSelectionDialog(shell, conversation,
34 "Choose Institution", false, TeamSelectionDialog.class.getCanonicalName(), institution);
35 return getSelectionFromDialog(dialog);
36 }
37
38 /**
39 * @param shell
40 * @param conversation
41 * @param title
42 * @param multi
43 * @param settings
44 * @param cdmObject
45 */
46 protected InstitutionSelectionDialog(Shell shell,
47 ConversationHolder conversation, String title, boolean multi,
48 String settings, Institution cdmObject) {
49 super(shell, conversation, title, multi, settings, cdmObject);
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
54 */
55 @Override
56 protected Institution getPersistentObject(UUID uuid) {
57 AgentBase agentBase = CdmStore.getService(IAgentService.class).load(uuid);
58
59 if(agentBase instanceof Institution){
60 return (Institution) agentBase;
61 }
62 return null;
63 }
64
65 /* (non-Javadoc)
66 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
67 */
68 @Override
69 protected void initModel() {
70 model = CdmStore.getService(IAgentService.class).getInstitutionUuidAndTitleCache();
71 }
72
73 /* (non-Javadoc)
74 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
75 */
76 @Override
77 protected String getNewWizardLinkText() {
78 return String.format("Create a new <a>%1s</a>", "Institution ");
79 }
80
81 /* (non-Javadoc)
82 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard(java.lang.String)
83 */
84 @Override
85 protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
86 return new NewInstitutionWizard();
87 }
88
89 }