3 * Copyright (C) 2016 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.selection
;
14 import org
.eclipse
.swt
.widgets
.Control
;
15 import org
.eclipse
.swt
.widgets
.Shell
;
16 import org
.eclipse
.swt
.widgets
.Text
;
18 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IAgentService
;
20 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
22 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
23 import eu
.etaxonomy
.taxeditor
.newWizard
.NewPersonWizard
;
24 import eu
.etaxonomy
.taxeditor
.newWizard
.NewTeamWizard
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
32 public class NomenclaturalAuthorSelectionDialog
extends AgentSelectionDialog
{
43 protected NomenclaturalAuthorSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
,
44 boolean multi
, String settings
, AgentBase agent
) {
45 super(shell
, conversation
, title
, multi
, settings
, agent
);
46 // TODO Auto-generated constructor stub
50 protected void initModel() {
51 Control control
= getPatternControl();
52 String pattern
= null;
54 pattern
= ((Text
)control
).getText();
57 model
= CdmStore
.getService(IAgentService
.class).getUuidAndAbbrevTitleCache(limitOfInitialElements
, pattern
, null);
62 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {
63 if(TEAM
.equals(parameter
)){
64 return new NewTeamWizard(true);
66 else if(PERSON
.equals(parameter
)){
67 return new NewPersonWizard();
70 throw new IllegalArgumentException("Could not determine the desired wizard.");
78 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
79 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
80 * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
81 * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
83 public static AgentBase
select(Shell shell
, ConversationHolder conversation
, AgentBase entity
) {
84 NomenclaturalAuthorSelectionDialog dialog
= new NomenclaturalAuthorSelectionDialog(shell
, conversation
,
85 "Choose Agent", false, NomenclaturalAuthorSelectionDialog
.class.getCanonicalName(), entity
);
86 return getSelectionFromDialog(dialog
);
92 * @param cdmObject a T object.
93 * @return a {@link java.lang.String} object.
96 protected String
getTitle(AgentBase cdmObject
) {
97 if(cdmObject
== null){
101 if (cdmObject
instanceof TeamOrPersonBase
) {
102 return ((TeamOrPersonBase
) cdmObject
).getNomenclaturalTitle();
103 } else if (cdmObject
instanceof AgentBase
){
104 return ((TeamOrPersonBase
) cdmObject
).getTitleCache();
107 throw new IllegalArgumentException("Generic method only" +
108 " supports cdmObject of type IIdentifiableEntity." +
109 " Please implement specific method in subclass.");