Project

General

Profile

Download (2.88 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 *
3
 */
4
package eu.etaxonomy.taxeditor.ui.section.description;
5

    
6
import java.util.Collection;
7
import java.util.Comparator;
8

    
9
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
10
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
11
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
12
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
15
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
16

    
17
/**
18
 * <p>
19
 * DescriptionElementSourceSection class.
20
 * </p>
21
 *
22
 * @author n.hoffmann
23
 * @created Nov 17, 2009
24
 * @version 1.0
25
 */
26
public class DescriptionElementSourceSection extends
27
        AbstractEntityCollectionSection<DescriptionElementBase, DescriptionElementSource> {
28

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

    
51
    /** {@inheritDoc} */
52
    @Override
53
    public DescriptionElementSource createNewElement() {
54
        return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
55
    }
56

    
57
    /** {@inheritDoc} */
58
    @Override
59
    public Collection<DescriptionElementSource> getCollection(DescriptionElementBase entity) {
60
        return entity.getSources();
61
    }
62

    
63
    @Override
64
    public Comparator<DescriptionElementSource> getComparator() {
65
        return new SourceComparator();
66
    }
67

    
68
    /** {@inheritDoc} */
69
    @Override
70
    public String getEmptyString() {
71
        return "No references yet.";
72
    }
73

    
74
    /** {@inheritDoc} */
75
    @Override
76
    protected String getTooltipString() {
77
        return "Create a new reference";
78
    }
79

    
80
    /** {@inheritDoc} */
81
    @Override
82
    public void addElement(DescriptionElementSource element) {
83
        getEntity().addSource(element);
84
    }
85

    
86
    /** {@inheritDoc} */
87
    @Override
88
    public void removeElement(DescriptionElementSource element) {
89
        getEntity().removeSource(element);
90
    }
91

    
92
    /**
93
     * {@inheritDoc}
94
     */
95
    @Override
96
    public DescriptionElementSource addExisting() {
97
        return null;
98
    }
99

    
100
    /**
101
     * {@inheritDoc}
102
     */
103
    @Override
104
    public boolean allowAddExisting() {
105
        return false;
106
    }
107
}
(10-10/26)