e78980638e970fb9f457619b2a3e737ea4eb3030
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / dna / SingleReadPherogramCollectionDetailSection.java
1 // $Id$
2 /**
3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.ui.section.occurrence.dna;
11
12 import java.util.Collection;
13 import java.util.Collections;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.model.media.Media;
17 import eu.etaxonomy.cdm.model.molecular.SingleRead;
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
22 /**
23 * @author pplitzner
24 * @date 03.03.2014
25 *
26 */
27 public class SingleReadPherogramCollectionDetailSection extends AbstractEntityCollectionSection<SingleRead, Media> {
28
29 /**
30 * @param formFactory
31 * @param conversation
32 * @param parentElement
33 * @param title
34 * @param style
35 */
36 public SingleReadPherogramCollectionDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
37 ICdmFormElement parentElement, int style) {
38 super(formFactory, conversation, parentElement, "Read Chromatogram", style);
39 }
40
41
42
43 /* (non-Javadoc)
44 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#getCollection(java.lang.Object)
45 */
46 @Override
47 public Collection<Media> getCollection(SingleRead entity) {
48 if(entity.getPherogram()!=null){
49 return Collections.singleton(entity.getPherogram());
50 }
51 return Collections.EMPTY_LIST;
52 }
53
54 /* (non-Javadoc)
55 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
56 */
57 @Override
58 public Media createNewElement() {
59 if(getEntity().getPherogram()==null){
60 return Media.NewInstance();
61 }
62 return null;
63 }
64
65 /* (non-Javadoc)
66 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#addElement(java.lang.Object)
67 */
68 @Override
69 public void addElement(Media element) {
70 if(getEntity().getPherogram()==null){
71 getEntity().setPherogram(element);
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().setPherogram(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 read chromatogram 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 read chromatogram";
97 }
98 }