Project

General

Profile

Download (3.03 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.ui.section.description;
11

    
12
import java.util.Collection;
13
import java.util.Comparator;
14

    
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
17
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
18
import eu.etaxonomy.cdm.model.description.DescriptionBase;
19
import eu.etaxonomy.taxeditor.ui.dialog.selection.OriginalSourceTypeSelectionDialog;
20
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
21
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
22
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
23
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
24

    
25
/**
26
 * <p>DescriptionSourceSection class.</p>
27
 *
28
 * @author n.hoffmann
29
 * @created Mar 18, 2010
30
 * @version 1.0
31
 */
32
public class DescriptionSourceSection extends
33
		AbstractEntityCollectionSection<DescriptionBase, IdentifiableSource>{
34

    
35
	/**
36
	 * <p>Constructor for DescriptionSourceSection.</p>
37
	 *
38
	 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
39
	 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
40
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
41
	 * @param style a int.
42
	 */
43
	public DescriptionSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
44
			ICdmFormElement parentElement, int style) {
45
		super(cdmFormFactory, conversation, parentElement, "Description Sources", style);
46
	}
47

    
48

    
49

    
50
	/** {@inheritDoc} */
51
	@Override
52
	public void addElement(IdentifiableSource element) {
53
		getEntity().addSource(element);
54
	}
55

    
56
	/** {@inheritDoc} */
57
	@Override
58
	public IdentifiableSource createNewElement() {
59
		OriginalSourceType ost = OriginalSourceTypeSelectionDialog.select(getShell(), getConversationHolder());
60
		if(ost != null) {
61
			return IdentifiableSource.NewInstance(ost);
62
		} else {
63
			return null;
64
		}
65
	}
66

    
67
	/** {@inheritDoc} */
68
	@Override
69
	public Collection<IdentifiableSource> getCollection(DescriptionBase entity) {
70
		return entity.getSources();
71
	}
72

    
73
	@Override
74
	public Comparator<IdentifiableSource> getComparator() {
75
        return new DefaultCdmBaseComparator<>();
76
	}
77

    
78
	/** {@inheritDoc} */
79
	@Override
80
	public String getEmptyString() {
81
		return "No description sources yet.";
82
	}
83

    
84
	/** {@inheritDoc} */
85
	@Override
86
	protected String getTooltipString() {
87
		return "Add a reference as source for this description";
88
	}
89

    
90
	/** {@inheritDoc} */
91
	@Override
92
	public void removeElement(IdentifiableSource element) {
93
		getEntity().removeSource(element);
94
	}
95

    
96

    
97

    
98
    /**
99
     * {@inheritDoc}
100
     */
101
    @Override
102
    public IdentifiableSource addExisting() {
103
        return null;
104
    }
105

    
106

    
107

    
108
    /**
109
     * {@inheritDoc}
110
     */
111
    @Override
112
    public boolean allowAddExisting() {
113
        return false;
114
    }
115
}
(11-11/25)