performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / dialogs / filteredSelection / FilteredAgentSelectionDialog.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.dialogs.filteredSelection;
12
13 import java.util.UUID;
14
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;
19
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;
26
27 /**
28 * <p>FilteredAgentSelectionDialog class.</p>
29 *
30 * @author n.hoffmann
31 * @created Sep 10, 2009
32 * @version 1.0
33 */
34 public class FilteredAgentSelectionDialog extends
35 AbstractFilteredCdmResourceSelectionDialog<AgentBase> {
36
37 /**
38 * <p>select</p>
39 *
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.
44 */
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);
49 }
50
51 /**
52 * <p>Constructor for FilteredAgentSelectionDialog.</p>
53 *
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.
60 */
61 protected FilteredAgentSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, String settings, AgentBase agent) {
62 super(shell, conversation, title, multi, settings, agent);
63 }
64
65
66 /**
67 * @author p.ciardelli
68 * @created 18.09.2009
69 * @version 1.0
70 */
71 public class DetailsLabelProvider extends LabelProvider {
72 /* (non-Javadoc)
73 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
74 */
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() + "'";
79 } else {
80 return "'" + agent.getTitleCache() + "' is not a nomenclatural author.";
81 }
82 }
83 }
84
85 /* (non-Javadoc)
86 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObect(java.util.UUID)
87 */
88 /** {@inheritDoc} */
89 @Override
90 protected AgentBase getPersistentObject(UUID cdmUuid) {
91 return CdmStore.getAgentService().load(cdmUuid);
92 }
93
94 /** {@inheritDoc} */
95 @Override
96 protected AbstractNewEntityWizard getNewEntityWizard() {
97 return null;
98 }
99
100 /** {@inheritDoc} */
101 @Override
102 protected String getNewWizardLinkText() {
103 return "Create a new <a>Team</a> or <a>Person</a>";
104 }
105
106 /** {@inheritDoc} */
107 @Override
108 protected Control createExtendedContentArea(Composite parent) {
109 // nothing at the moment
110 return null;
111 }
112
113 /** {@inheritDoc} */
114 @Override
115 protected void initModel() {
116 model = CdmStore.getAgentService().getUuidAndTitleCache();
117 }
118
119
120 }