- moved ICdmFormElement to ui.element
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / occurrence / dna / SequenceReferenceCollectionDetailSection.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
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
21 /**
22 * This section visualizes {@link Reference}s belonging to a {@link Sequence} and alllows adding/removing them.
23 * @author pplitzner
24 * @date 07.01.2014
25 *
26 */
27 public class SequenceReferenceCollectionDetailSection extends AbstractUnboundEntityCollectionSection<Sequence, Reference> {
28
29 public SequenceReferenceCollectionDetailSection(CdmFormFactory formFactory,
30 ConversationHolder conversation, ICdmFormElement parentElement, int style) {
31 super(formFactory, conversation, parentElement, "References", style);
32 }
33
34 /* (non-Javadoc)
35 * @see eu.etaxonomy.taxeditor.ui.section.occurrence.dna.AbstractNullEntityCollectionSection#getEntityCollection(java.lang.Object)
36 */
37 /** {@inheritDoc} */
38 @Override
39 protected Collection<Reference> getEntityCollection(Sequence entity) {
40 return entity.getCitations();
41 }
42
43 /* (non-Javadoc)
44 * @see eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection#createNewElement()
45 */
46 /** {@inheritDoc} */
47 @Override
48 public Reference createNewElement() {
49 return ReferenceFactory.newGeneric();
50 }
51
52 /* (non-Javadoc)
53 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#addElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
54 */
55 /** {@inheritDoc} */
56 @Override
57 public void addElement(Reference element) {
58 if(element!=null){
59 getEntity().addCitation(element);
60 }
61 }
62
63 /* (non-Javadoc)
64 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#removeElement(eu.etaxonomy.cdm.model.common.IVersionableEntity)
65 */
66 /** {@inheritDoc} */
67 @Override
68 public void removeElement(Reference element) {
69 getEntity().removeCitation(element);
70 }
71
72 /* (non-Javadoc)
73 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getEmptyString()
74 */
75 /** {@inheritDoc} */
76 @Override
77 public String getEmptyString() {
78 return "No references yet.";
79 }
80
81 /* (non-Javadoc)
82 * @see eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection#getTooltipString()
83 */
84 /** {@inheritDoc} */
85 @Override
86 protected String getTooltipString() {
87 return "Add a reference";
88 }
89
90
91 }