Project

General

Profile

Download (2.74 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2016 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
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

    
12
import org.eclipse.swt.widgets.Shell;
13

    
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.api.service.IAgentService;
16
import eu.etaxonomy.cdm.model.agent.AgentBase;
17
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19

    
20
/**
21
 * @author k.luther
22
 * @date 25.05.2016
23
 *
24
 */
25
public class NomenclaturalAuthorSelectionDialog extends AgentSelectionDialog {
26

    
27

    
28
    /**
29
     * @param shell
30
     * @param conversation
31
     * @param title
32
     * @param multi
33
     * @param settings
34
     * @param agent
35
     */
36
    protected NomenclaturalAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,
37
            boolean multi, String settings, AgentBase agent) {
38
        super(shell, conversation, title, multi, settings, agent);
39
        // TODO Auto-generated constructor stub
40
    }
41

    
42
    @Override
43
    protected void initModel() {
44
        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache();
45
    }
46

    
47
    /**
48
     * <p>select</p>
49
     *
50
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
51
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
52
     * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
53
     * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
54
     */
55
    public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity) {
56
        NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, conversation,
57
                "Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity);
58
        return getSelectionFromDialog(dialog);
59
    }
60

    
61
    /**
62
     * <p>getTitle</p>
63
     *
64
     * @param cdmObject a T object.
65
     * @return a {@link java.lang.String} object.
66
     */
67
    @Override
68
    protected String getTitle(AgentBase cdmObject) {
69
        if(cdmObject == null){
70
            return "";
71
        }
72

    
73
        if (cdmObject instanceof TeamOrPersonBase) {
74
            return ((TeamOrPersonBase) cdmObject).getNomenclaturalTitle();
75
        } else if (cdmObject instanceof AgentBase){
76
            return ((TeamOrPersonBase) cdmObject).getTitleCache();
77
        }
78

    
79
        throw new IllegalArgumentException("Generic method only" +
80
                " supports cdmObject of type IIdentifiableEntity." +
81
                " Please implement specific method in subclass.");
82
    }
83

    
84
}
(17-17/31)