Project

General

Profile

Download (3.36 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.Collections;
13
import java.util.Comparator;
14

    
15
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16
import eu.etaxonomy.cdm.model.media.Media;
17
import eu.etaxonomy.cdm.model.molecular.AmplificationResult;
18
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
21
import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
22

    
23
/**
24
 * @author pplitzner
25
 * @date 26.02.2014
26
 *
27
 */
28
public class AmplificationGelPhotoCollectionDetailSection extends AbstractEntityCollectionSection<AmplificationResult, Media> {
29

    
30
    /**
31
     * @param formFactory
32
     * @param conversation
33
     * @param parentElement
34
     * @param title
35
     * @param style
36
     */
37
    public AmplificationGelPhotoCollectionDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
38
            ICdmFormElement parentElement, int style) {
39
        super(formFactory, conversation, parentElement, "Gel Photo", style);
40
    }
41

    
42

    
43

    
44
    /* (non-Javadoc)
45
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
46
     */
47
    @Override
48
    public Collection<Media> getCollection(AmplificationResult entity) {
49
        if(entity.getGelPhoto()!=null){
50
            return Collections.singleton(entity.getGelPhoto());
51
        }
52
        return Collections.EMPTY_LIST;
53
    }
54

    
55
    @Override
56
    public Comparator<Media> getComparator() {
57
        return new DefaultCdmBaseComparator<>();
58
    }
59

    
60
    /* (non-Javadoc)
61
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
62
     */
63
    @Override
64
    public Media createNewElement() {
65
        if(getEntity().getGelPhoto()==null){
66
            return Media.NewInstance();
67
        }
68
        return null;
69
    }
70

    
71
    /* (non-Javadoc)
72
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement(java.lang.Object)
73
     */
74
    @Override
75
    public void addElement(Media element) {
76
        if(getEntity().getGelPhoto()==null){
77
            getEntity().setGelPhoto(element);
78
        }
79

    
80
    }
81

    
82
    /* (non-Javadoc)
83
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#removeElement(java.lang.Object)
84
     */
85
    @Override
86
    public void removeElement(Media element) {
87
        getEntity().setGelPhoto(null);
88
    }
89

    
90
    /* (non-Javadoc)
91
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getEmptyString()
92
     */
93
    @Override
94
    public String getEmptyString() {
95
        return "No gel photo yet";
96
    }
97

    
98
    /* (non-Javadoc)
99
     * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getTooltipString()
100
     */
101
    @Override
102
    protected String getTooltipString() {
103
        return "Add a gel photo";
104
    }
105

    
106

    
107

    
108
    /**
109
     * {@inheritDoc}
110
     */
111
    @Override
112
    public Media addExisting() {
113
        return null;
114
    }
115

    
116

    
117

    
118
    /**
119
     * {@inheritDoc}
120
     */
121
    @Override
122
    public boolean allowAddExisting() {
123
        return false;
124
    }
125

    
126
}
(5-5/32)