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