3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.dialogs
.filteredSelection
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.jface
.viewers
.LabelProvider
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Control
;
18 import org
.eclipse
.swt
.widgets
.Shell
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
22 import eu
.etaxonomy
.cdm
.model
.agent
.INomenclaturalAuthor
;
23 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
24 import eu
.etaxonomy
.taxeditor
.editor
.newWizard
.AbstractNewEntityWizard
;
25 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 * <p>FilteredAgentSelectionDialog class.</p>
31 * @created Sep 10, 2009
34 public class FilteredAgentSelectionDialog
extends
35 AbstractFilteredCdmResourceSelectionDialog
<AgentBase
> {
40 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
41 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
42 * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
43 * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
45 public static AgentBase
select(Shell shell
, ConversationHolder conversation
, AgentBase entity
) {
46 FilteredAgentSelectionDialog dialog
= new FilteredAgentSelectionDialog(shell
, conversation
,
47 "Choose Agent", false, FilteredAgentSelectionDialog
.class.getCanonicalName(), entity
);
48 return getSelectionFromDialog(dialog
);
52 * <p>Constructor for FilteredAgentSelectionDialog.</p>
54 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
55 * @param title a {@link java.lang.String} object.
56 * @param agent a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
57 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
58 * @param multi a boolean.
59 * @param settings a {@link java.lang.String} object.
61 protected FilteredAgentSelectionDialog(Shell shell
, ConversationHolder conversation
, String title
, boolean multi
, String settings
, AgentBase agent
) {
62 super(shell
, conversation
, title
, multi
, settings
, agent
);
71 public class DetailsLabelProvider
extends LabelProvider
{
73 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
75 public String
getText(Object element
) {
76 AgentBase agent
= getCdmObjectByUuid(((UuidAndTitleCache
<AgentBase
>) element
).getUuid());
77 if (agent
instanceof INomenclaturalAuthor
) {
78 return "Nomenclatural title: '" + ((INomenclaturalAuthor
) agent
).getNomenclaturalTitle() + "'";
80 return "'" + agent
.getTitleCache() + "' is not a nomenclatural author.";
86 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObect(java.util.UUID)
90 protected AgentBase
getPersistentObject(UUID cdmUuid
) {
91 return CdmStore
.getAgentService().load(cdmUuid
);
96 protected AbstractNewEntityWizard
getNewEntityWizard() {
102 protected String
getNewWizardLinkText() {
103 return "Create a new <a>Team</a> or <a>Person</a>";
108 protected Control
createExtendedContentArea(Composite parent
) {
109 // nothing at the moment
115 protected void initModel() {
116 model
= CdmStore
.getAgentService().getUuidAndTitleCache();