Revision 7bea8087
Added by Katja Luther about 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java | ||
---|---|---|
31 | 31 |
* @created Sep 10, 2009 |
32 | 32 |
* @version 1.0 |
33 | 33 |
*/ |
34 |
public class AgentSelectionDialog extends |
|
35 |
AbstractFilteredCdmResourceSelectionDialog<AgentBase> {
|
|
34 |
public class AgentSelectionDialog<T extends AgentBase> extends
|
|
35 |
AbstractFilteredCdmResourceSelectionDialog { |
|
36 | 36 |
|
37 | 37 |
/** |
38 | 38 |
* |
... | ... | |
57 | 57 |
AgentBase entity, boolean selectTeamMember) { |
58 | 58 |
AgentSelectionDialog dialog = new AgentSelectionDialog(shell, //conversation, |
59 | 59 |
"Choose Agent", false, AgentSelectionDialog.class.getCanonicalName(), entity, selectTeamMember); |
60 |
return getSelectionFromDialog(dialog); |
|
60 |
return (AgentBase) getSelectionFromDialog(dialog);
|
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
/** |
... | ... | |
89 | 89 |
*/ |
90 | 90 |
@Override |
91 | 91 |
public String getText(Object element) { |
92 |
AgentBase agent = getCdmObjectByUuid(((UuidAndTitleCache<AgentBase>) element).getUuid());
|
|
92 |
AgentBase agent = (AgentBase) getCdmObjectByUuid(((UuidAndTitleCache<AgentBase>) element).getUuid());
|
|
93 | 93 |
if (agent instanceof INomenclaturalAuthor) { |
94 | 94 |
return "Nomenclatural title: '" + ((INomenclaturalAuthor) agent).getNomenclaturalTitle() + "'"; |
95 | 95 |
} else { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java | ||
---|---|---|
18 | 18 |
import org.eclipse.swt.widgets.Shell; |
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
21 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
21 |
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor; |
|
22 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
23 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
22 | 24 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
23 | 25 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
24 | 26 |
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard; |
... | ... | |
33 | 35 |
* @date 25.05.2016 |
34 | 36 |
* |
35 | 37 |
*/ |
36 |
public class NomenclaturalAuthorSelectionDialog extends AgentSelectionDialog {
|
|
38 |
public class NomenclaturalAuthorSelectionDialog extends TeamOrPersonBaseSelectionDialog {
|
|
37 | 39 |
|
38 | 40 |
|
39 | 41 |
/** |
... | ... | |
46 | 48 |
*/ |
47 | 49 |
protected NomenclaturalAuthorSelectionDialog(Shell shell, //ConversationHolder conversation, |
48 | 50 |
String title, |
49 |
boolean multi, String settings, AgentBase agent, boolean teamMemberSelection) { |
|
50 |
super(shell, //conversation, |
|
51 |
title, multi, settings, agent, teamMemberSelection); |
|
52 |
// TODO Auto-generated constructor stub |
|
51 |
boolean multi, String settings, TeamOrPersonBase agent, boolean teamMemberSelection) { |
|
52 |
super(shell, title, multi, settings, agent, teamMemberSelection); |
|
53 |
|
|
53 | 54 |
} |
54 | 55 |
|
55 | 56 |
@Override |
56 | 57 |
protected void callService(String pattern) { |
57 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null); |
|
58 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(Team.class, limitOfInitialElements, pattern); |
|
59 |
model.addAll(CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(Person.class, limitOfInitialElements, pattern)); |
|
58 | 60 |
} |
59 | 61 |
|
60 | 62 |
/** {@inheritDoc} */ |
... | ... | |
87 | 89 |
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
88 | 90 |
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
89 | 91 |
*/ |
90 |
public static AgentBase select(Shell shell, //ConversationHolder conversation,
|
|
91 |
AgentBase entity, boolean teamMemberSelection) {
|
|
92 |
public static TeamOrPersonBase select(Shell shell, //ConversationHolder conversation,
|
|
93 |
TeamOrPersonBase entity, boolean teamMemberSelection) {
|
|
92 | 94 |
NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, //conversation, |
93 | 95 |
"Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity, teamMemberSelection); |
94 |
return getSelectionFromDialog(dialog); |
|
96 |
return (TeamOrPersonBase)getSelectionFromDialog(dialog);
|
|
95 | 97 |
} |
96 | 98 |
|
97 | 99 |
/** |
... | ... | |
101 | 103 |
* @return a {@link java.lang.String} object. |
102 | 104 |
*/ |
103 | 105 |
@Override |
104 |
protected String getTitle(AgentBase cdmObject) {
|
|
106 |
protected String getTitle(TeamOrPersonBase cdmObject) {
|
|
105 | 107 |
if(cdmObject == null){ |
106 | 108 |
return ""; |
107 | 109 |
} |
108 | 110 |
|
109 |
if (cdmObject instanceof TeamOrPersonBase) { |
|
110 |
return ((TeamOrPersonBase) cdmObject).getNomenclaturalTitle(); |
|
111 |
} else if (cdmObject instanceof AgentBase){ |
|
112 |
return ((TeamOrPersonBase) cdmObject).getTitleCache(); |
|
111 |
if (cdmObject instanceof INomenclaturalAuthor) { |
|
112 |
return ((INomenclaturalAuthor)cdmObject).getNomenclaturalTitle(); |
|
113 | 113 |
} |
114 |
|
|
115 | 114 |
throw new IllegalArgumentException("Generic method only" + |
116 | 115 |
" supports cdmObject of type IIdentifiableEntity." + |
117 | 116 |
" Please implement specific method in subclass."); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorTeamSelectionDialog.java | ||
---|---|---|
98 | 98 |
*/ |
99 | 99 |
@Override |
100 | 100 |
void callService(String pattern) { |
101 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
|
|
101 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(Team.class, limitOfInitialElements, pattern);
|
|
102 | 102 |
} |
103 | 103 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalPersonAuthorSelectionDialog.java | ||
---|---|---|
11 | 11 |
import org.eclipse.swt.widgets.Shell; |
12 | 12 |
|
13 | 13 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
14 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
15 | 14 |
import eu.etaxonomy.cdm.model.agent.Person; |
15 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
16 | 16 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
17 | 17 |
|
18 | 18 |
/** |
... | ... | |
32 | 32 |
*/ |
33 | 33 |
protected NomenclaturalPersonAuthorSelectionDialog(Shell shell, //ConversationHolder conversation, |
34 | 34 |
String title, |
35 |
boolean multi, String settings, AgentBase agent, boolean teamMemberSelection) {
|
|
35 |
boolean multi, String settings, TeamOrPersonBase agent, boolean teamMemberSelection) {
|
|
36 | 36 |
super(shell, //conversation, |
37 | 37 |
title, multi, settings, agent, teamMemberSelection); |
38 | 38 |
// TODO Auto-generated constructor stub |
... | ... | |
47 | 47 |
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
48 | 48 |
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
49 | 49 |
*/ |
50 |
public static AgentBase select(Shell shell, //ConversationHolder conversation,
|
|
51 |
AgentBase entity, boolean teamMemberSelection) {
|
|
50 |
public static TeamOrPersonBase select(Shell shell, //ConversationHolder conversation,
|
|
51 |
TeamOrPersonBase entity, boolean teamMemberSelection) {
|
|
52 | 52 |
NomenclaturalPersonAuthorSelectionDialog dialog = new NomenclaturalPersonAuthorSelectionDialog(shell, //conversation, |
53 | 53 |
"Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity,teamMemberSelection); |
54 |
return getSelectionFromDialog(dialog); |
|
54 |
return (TeamOrPersonBase)getSelectionFromDialog(dialog);
|
|
55 | 55 |
} |
56 | 56 |
|
57 | 57 |
@Override |
58 | 58 |
protected void callService(String pattern) { |
59 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Person.class);
|
|
59 |
model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(Person.class, limitOfInitialElements, pattern);
|
|
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java | ||
---|---|---|
113 | 113 |
} |
114 | 114 |
if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){ |
115 | 115 |
return (T) NomenclaturalAuthorSelectionDialog.select(shell, //conversation, |
116 |
(AgentBase) currentSelection, false);
|
|
116 |
(TeamOrPersonBase) currentSelection, false);
|
|
117 | 117 |
}else if(clazz.equals(TeamOrPersonBase.class)){ |
118 | 118 |
//TODO: add TeamOrPersonBaseSelectionDialog (see ticket #4545) |
119 |
return (T) AgentSelectionDialog.select(shell, //conversation,
|
|
120 |
(AgentBase) currentSelection, false);
|
|
119 |
return (T) TeamOrPersonBaseSelectionDialog.select(shell, //conversation,
|
|
120 |
(TeamOrPersonBase) currentSelection, false);
|
|
121 | 121 |
} |
122 | 122 |
if(clazz.equals(Person.class) && parentElement instanceof TeamMemberElement){ |
123 | 123 |
return (T) NomenclaturalPersonAuthorSelectionDialog.select(shell, //conversation, |
124 |
(AgentBase) currentSelection, true);
|
|
124 |
(TeamOrPersonBase) currentSelection, true);
|
|
125 | 125 |
} |
126 | 126 |
if(clazz.equals(AgentBase.class)){ |
127 | 127 |
return (T) AgentSelectionDialog.select(shell, //conversation, |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TeamOrPersonBaseSelectionDialog.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2019 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 |
package eu.etaxonomy.taxeditor.ui.dialog.selection; |
|
10 |
|
|
11 |
import org.eclipse.swt.widgets.Shell; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
|
14 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
15 |
import eu.etaxonomy.cdm.model.agent.Team; |
|
16 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
17 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author k.luther |
|
21 |
* @since 18.03.2019 |
|
22 |
* |
|
23 |
*/ |
|
24 |
public class TeamOrPersonBaseSelectionDialog extends AgentSelectionDialog<TeamOrPersonBase> { |
|
25 |
|
|
26 |
/** |
|
27 |
* @param shell |
|
28 |
* @param title |
|
29 |
* @param multi |
|
30 |
* @param settings |
|
31 |
* @param agent |
|
32 |
* @param selectTeamMember |
|
33 |
*/ |
|
34 |
protected TeamOrPersonBaseSelectionDialog(Shell shell, String title, boolean multi, String settings, |
|
35 |
TeamOrPersonBase agent, boolean selectTeamMember) { |
|
36 |
super(shell, title, multi, settings, agent, selectTeamMember); |
|
37 |
// TODO Auto-generated constructor stub |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* <p>select</p> |
|
44 |
* |
|
45 |
* @param shell a {@link org.eclipse.swt.widgets.Shell} object. |
|
46 |
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object. |
|
47 |
* @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
|
48 |
* @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object. |
|
49 |
*/ |
|
50 |
public static TeamOrPersonBase select(Shell shell, //ConversationHolder conversation, |
|
51 |
TeamOrPersonBase entity, boolean selectTeamMember) { |
|
52 |
TeamOrPersonBaseSelectionDialog dialog = new TeamOrPersonBaseSelectionDialog(shell, //conversation, |
|
53 |
"Choose Team or Person", false, TeamOrPersonBaseSelectionDialog.class.getCanonicalName(), entity, selectTeamMember); |
|
54 |
return (TeamOrPersonBase)getSelectionFromDialog(dialog); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
void callService(String pattern) { |
|
59 |
model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(Team.class,limitOfInitialElements, pattern); |
|
60 |
model.addAll( CdmStore.getService(IAgentService.class).getUuidAndTitleCache(Person.class,limitOfInitialElements, pattern)); |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* @param cdmObject |
|
67 |
* @return |
|
68 |
*/ |
|
69 |
protected String getTitle(TeamOrPersonBase cdmObject) { |
|
70 |
if(cdmObject == null){ |
|
71 |
return ""; |
|
72 |
} |
|
73 |
return cdmObject.getTitleCache(); |
|
74 |
} |
|
75 |
} |
Also available in: Unified diff
ref #4545: add TeamOrPersonSelectionDialog