Project

General

Profile

« Previous | Next » 

Revision aeb80bf1

Added by Andreas Müller about 3 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java
29 29
 * @author n.hoffmann
30 30
 * @created Sep 10, 2009
31 31
 */
32
public class AgentSelectionDialog<T extends AgentBase> extends
33
		AbstractFilteredCdmResourceSelectionDialog {
32
public class AgentSelectionDialog<T extends AgentBase>
33
        extends AbstractFilteredCdmResourceSelectionDialog<T> {
34 34

  
35 35
	protected static final String PERSON = "New Person";
36 36
	protected static final String TEAM = "New Team";
......
45 45
	 * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
46 46
	 * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
47 47
	 */
48
	public static AgentBase select(Shell shell, //ConversationHolder conversation,
49
	        AgentBase entity, boolean selectTeamMember) {
50
		AgentSelectionDialog dialog = new AgentSelectionDialog(shell, //conversation,
48
	public static <S extends AgentBase> S select(Shell shell,
49
	        S entity, boolean selectTeamMember) {
50
		AgentSelectionDialog<S> dialog = new AgentSelectionDialog<>(shell,
51 51
				"Choose Agent", false, AgentSelectionDialog.class.getCanonicalName(), entity, selectTeamMember);
52
		return (AgentBase) getSelectionFromDialog(dialog);
52
		return getSelectionFromDialog(dialog);
53 53
	}
54 54

  
55 55
	/**
......
63 63
	 * @param settings a {@link java.lang.String} object.
64 64
	 */
65 65
	protected AgentSelectionDialog(Shell shell,
66
	        String title, boolean multi, String settings, AgentBase agent, boolean selectTeamMember) {
67
		super(shell,
68
		        title, multi, settings, agent);
66
	        String title, boolean multi, String settings, T agent, boolean selectTeamMember) {
67
		super(shell, title, multi, settings, agent);
69 68
		this.selectTeamMember = selectTeamMember;
70 69
	}
71 70

  
72 71
	public class DetailsLabelProvider extends LabelProvider {
73 72
		@Override
74 73
        public String getText(Object element) {
75
		    AgentBase agent = (AgentBase) getCdmObjectByUuid(((UuidAndTitleCache<AgentBase>) element).getUuid());
74
		    T agent = getCdmObjectByUuid(((UuidAndTitleCache<AgentBase>) element).getUuid());
76 75
			if (agent instanceof INomenclaturalAuthor) {
77 76
				return "Nomenclatural title: '" + ((INomenclaturalAuthor) agent).getNomenclaturalTitle() + "'";
78 77
			} else {
......
82 81
	}
83 82

  
84 83
	@Override
85
	protected AgentBase getPersistentObject(UUID cdmUuid) {
86
		return CdmStore.getService(IAgentService.class).load(cdmUuid);
84
	protected T getPersistentObject(UUID cdmUuid) {
85
		return (T)CdmStore.getService(IAgentService.class).load(cdmUuid);
87 86
	}
88 87

  
89 88
	@Override
......
105 104
		if (this.selectTeamMember){
106 105
		    result = new String[1];
107 106
		    result[0] = PERSON;
108

  
109 107
		}else{
110 108
		    result = new String[2];
111 109
            result[0] = PERSON;
......
130 128

  
131 129
    @Override
132 130
    protected void callService(String pattern) {
133
        model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
131
        Class<T> clazz = (Class)AgentBase.class;
132
        model = CdmStore.getService(IAgentService.class).getUuidAndTitleCache(clazz, limitOfInitialElements, pattern);
134 133
    }
135 134
}

Also available in: Unified diff