added a readme file
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / section / description / DescriptionSourceSection.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 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
11 package eu.etaxonomy.taxeditor.section.description;
12
13 import java.util.Collection;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.model.description.DescriptionBase;
17 import eu.etaxonomy.cdm.model.reference.Reference;
18 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
19 import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.section.AbstractEntityCollectionSection;
22
23 /**
24 * <p>DescriptionSourceSection class.</p>
25 *
26 * @author n.hoffmann
27 * @created Mar 18, 2010
28 * @version 1.0
29 */
30 public class DescriptionSourceSection extends
31 AbstractEntityCollectionSection<DescriptionBase, Reference>{
32
33 /**
34 * <p>Constructor for DescriptionSourceSection.</p>
35 *
36 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.forms.CdmFormFactory} object.
37 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
38 * @param parentElement a {@link eu.etaxonomy.taxeditor.forms.ICdmFormElement} object.
39 * @param style a int.
40 */
41 public DescriptionSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
42 ICdmFormElement parentElement, int style) {
43 super(cdmFormFactory, conversation, parentElement, "Description Sources", style);
44 }
45
46
47
48 /** {@inheritDoc} */
49 @Override
50 public void addElement(Reference element) {
51 getEntity().addDescriptionSource(element);
52 }
53
54 /** {@inheritDoc} */
55 @Override
56 public Reference createNewElement() {
57 return new ReferenceFactory().newGeneric();
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 public Collection<Reference> getCollection(DescriptionBase entity) {
63 return entity.getDescriptionSources();
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public String getEmptyString() {
69 return "No description sources yet.";
70 }
71
72 /** {@inheritDoc} */
73 @Override
74 protected String getTooltipString() {
75 return "Add a reference as source for this description";
76 }
77
78 /** {@inheritDoc} */
79 @Override
80 public void removeElement(Reference element) {
81 getEntity().removeDescriptionSource(element);
82 }
83 }