Project

General

Profile

« Previous | Next » 

Revision e765dbb3

Added by Katja Luther almost 8 years ago

selectiondialog for nomenclatural authors should work on nomenclatural
title

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java
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(null, null);
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
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
44 44
import eu.etaxonomy.taxeditor.model.MessagingUtils;
45 45
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
46 46
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
47
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
47 48

  
48 49
/**
49 50
 * @author n.hoffmann
......
82 83
		if(clazz.equals(Team.class)){
83 84
			return (T) TeamSelectionDialog.select(shell, conversation, (Team) currentSelection);
84 85
		}
85
		if(clazz.equals(TeamOrPersonBase.class)){
86
		if(clazz.equals(TeamOrPersonBase.class) && parentElement instanceof AuthorshipDetailElement){
87
            return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
88
        }else if(clazz.equals(TeamOrPersonBase.class)){
86 89
		    //TODO: add TeamOrPersonBaseSelectionDialog (see ticket #4545)
87 90
		    return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
88 91
		}
92

  
89 93
		if(clazz.equals(AgentBase.class)){
90 94
			return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
91 95
		}

Also available in: Unified diff