1546ffa8e288d8c6695e7c15b242ab2f6f629191
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescriptionElementSourceSection.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.ui.section.description;
5
6 import java.util.Collection;
7
8 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
9 import eu.etaxonomy.cdm.model.common.OriginalSourceType;
10 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
11 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
12 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
13 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
14 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
15
16 /**
17 * <p>DescriptionElementSourceSection class.</p>
18 *
19 * @author n.hoffmann
20 * @created Nov 17, 2009
21 * @version 1.0
22 */
23 public class DescriptionElementSourceSection extends AbstractEntityCollectionSection<DescriptionElementBase, DescriptionElementSource>{
24
25 /**
26 * <p>Constructor for DescriptionElementSourceSection.</p>
27 *
28 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
29 * @param style a int.
30 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
31 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
32 */
33 public DescriptionElementSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style){
34 super(cdmFormFactory, conversation, parentElement, "References", style);
35 }
36
37 /** {@inheritDoc} */
38 @Override
39 public DescriptionElementSource createNewElement() {
40 return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
41 }
42
43 /** {@inheritDoc} */
44 @Override
45 public Collection<DescriptionElementSource> getCollection(
46 DescriptionElementBase entity) {
47 return entity.getSources();
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public String getEmptyString() {
53 return "No references yet.";
54 }
55
56 /** {@inheritDoc} */
57 @Override
58 protected String getTooltipString() {
59 return "Create a new reference";
60 }
61
62 /** {@inheritDoc} */
63 @Override
64 public void addElement(DescriptionElementSource element) {
65 getEntity().addSource(element);
66 }
67
68 /** {@inheritDoc} */
69 @Override
70 public void removeElement(DescriptionElementSource element) {
71 getEntity().removeSource(element);
72 }
73 }