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
|
|
14
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
15
|
import eu.etaxonomy.cdm.model.media.Media;
|
16
|
import eu.etaxonomy.cdm.model.molecular.AmplificationResult;
|
17
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
19
|
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
|
20
|
|
21
|
/**
|
22
|
* @author pplitzner
|
23
|
* @date 26.02.2014
|
24
|
*
|
25
|
*/
|
26
|
public class AmplificationGelPhotoCollectionDetailSection extends AbstractEntityCollectionSection<AmplificationResult, Media> {
|
27
|
|
28
|
/**
|
29
|
* @param formFactory
|
30
|
* @param conversation
|
31
|
* @param parentElement
|
32
|
* @param title
|
33
|
* @param style
|
34
|
*/
|
35
|
public AmplificationGelPhotoCollectionDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
|
36
|
ICdmFormElement parentElement, int style) {
|
37
|
super(formFactory, conversation, parentElement, "Gel Photo", style);
|
38
|
}
|
39
|
|
40
|
|
41
|
|
42
|
/* (non-Javadoc)
|
43
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
|
44
|
*/
|
45
|
@Override
|
46
|
public Collection<Media> getCollection(AmplificationResult entity) {
|
47
|
if(entity.getGelPhoto()!=null){
|
48
|
return Collections.singleton(entity.getGelPhoto());
|
49
|
}
|
50
|
return Collections.EMPTY_LIST;
|
51
|
}
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
|
55
|
*/
|
56
|
@Override
|
57
|
public Media createNewElement() {
|
58
|
if(getEntity().getGelPhoto()==null){
|
59
|
return Media.NewInstance();
|
60
|
}
|
61
|
return null;
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement(java.lang.Object)
|
66
|
*/
|
67
|
@Override
|
68
|
public void addElement(Media element) {
|
69
|
if(getEntity().getGelPhoto()==null){
|
70
|
getEntity().setGelPhoto(element);
|
71
|
}
|
72
|
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#removeElement(java.lang.Object)
|
77
|
*/
|
78
|
@Override
|
79
|
public void removeElement(Media element) {
|
80
|
getEntity().setGelPhoto(null);
|
81
|
}
|
82
|
|
83
|
/* (non-Javadoc)
|
84
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getEmptyString()
|
85
|
*/
|
86
|
@Override
|
87
|
public String getEmptyString() {
|
88
|
return "No gel photo yet";
|
89
|
}
|
90
|
|
91
|
/* (non-Javadoc)
|
92
|
* @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getTooltipString()
|
93
|
*/
|
94
|
@Override
|
95
|
protected String getTooltipString() {
|
96
|
return "Add a gel photo";
|
97
|
}
|
98
|
|
99
|
|
100
|
|
101
|
/**
|
102
|
* {@inheritDoc}
|
103
|
*/
|
104
|
@Override
|
105
|
public Media addExisting() {
|
106
|
return null;
|
107
|
}
|
108
|
|
109
|
|
110
|
|
111
|
/**
|
112
|
* {@inheritDoc}
|
113
|
*/
|
114
|
@Override
|
115
|
public boolean allowAddExisting() {
|
116
|
return false;
|
117
|
}
|
118
|
|
119
|
}
|