Project

General

Profile

Download (3.28 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2014 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
package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
10

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

    
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.model.molecular.Sequence;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
21

    
22
/**
23
 * This section visualizes {@link Reference}s belonging to a {@link Sequence} and alllows adding/removing them.
24
 * @author pplitzner
25
 * @date 07.01.2014
26
 *
27
 */
28
public class SequenceReferenceCollectionDetailSection extends AbstractUnboundEntityCollectionSection<Sequence, Reference> {
29

    
30
    public SequenceReferenceCollectionDetailSection(CdmFormFactory formFactory,
31
            ConversationHolder conversation, ICdmFormElement parentElement, int style) {
32
        super(formFactory, conversation, parentElement, "References", style);
33
    }
34

    
35
    /* (non-Javadoc)
36
     * @see eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractNullEntityCollectionSection#getEntityCollection(java.lang.Object)
37
     */
38
    /** {@inheritDoc} */
39
    @Override
40
    protected Collection<Reference> getEntityCollection(Sequence entity) {
41
        return entity.getCitations();
42
    }
43

    
44
    @Override
45
    public Comparator<Reference> getComparator() {
46
        return new DefaultCdmBaseComparator<>();
47
    }
48

    
49
    /* (non-Javadoc)
50
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
51
     */
52
    /** {@inheritDoc} */
53
    @Override
54
    public Reference createNewElement() {
55
        return ReferenceFactory.newGeneric();
56
    }
57

    
58
    /* (non-Javadoc)
59
     * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
60
     */
61
    /** {@inheritDoc} */
62
    @Override
63
    public void addElement(Reference element) {
64
        //never gets called
65
    }
66

    
67
    /* (non-Javadoc)
68
     * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
69
     */
70
    /** {@inheritDoc} */
71
    @Override
72
    public void removeElement(Reference element) {
73
        getEntity().removeCitation(element);
74
    }
75

    
76
    /* (non-Javadoc)
77
     * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
78
     */
79
    /** {@inheritDoc} */
80
    @Override
81
    public String getEmptyString() {
82
        return "No references yet.";
83
    }
84

    
85
    /* (non-Javadoc)
86
     * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
87
     */
88
    /** {@inheritDoc} */
89
    @Override
90
    protected String getTooltipString() {
91
        return "Add a reference";
92
    }
93

    
94
    /**
95
     * {@inheritDoc}
96
     */
97
    @Override
98
    public Reference addExisting() {
99
        return null;
100
    }
101

    
102
    /**
103
     * {@inheritDoc}
104
     */
105
    @Override
106
    public boolean allowAddExisting() {
107
        return false;
108
    }
109

    
110

    
111
}
(27-27/32)