bbd8752f3fd87a7b6288bfe538667b98213d6f7a
[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.model.MessagingUtils;
13 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
14 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
15 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
16
17 /**
18 * <p>DescriptionElementSourceSection class.</p>
19 *
20 * @author n.hoffmann
21 * @created Nov 17, 2009
22 * @version 1.0
23 */
24 public class DescriptionElementSourceSection extends AbstractEntityCollectionSection<DescriptionElementBase, DescriptionElementSource>{
25
26 /**
27 * <p>Constructor for DescriptionElementSourceSection.</p>
28 *
29 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
30 * @param style a int.
31 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
32 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
33 */
34 public DescriptionElementSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style){
35 super(cdmFormFactory, conversation, parentElement, "References", style);
36 }
37
38 /** {@inheritDoc} */
39 @Override
40 public DescriptionElementSource createNewElement() {
41 /* if(getEntity().getId() == 0) {
42 MessagingUtils.warningDialog("Description not saved", this, "Please save the newly created description before adding source");
43 return null;
44 }*/
45 return DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public Collection<DescriptionElementSource> getCollection(
51 DescriptionElementBase entity) {
52 return entity.getSources();
53 }
54
55 /** {@inheritDoc} */
56 @Override
57 public String getEmptyString() {
58 return "No references yet.";
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 protected String getTooltipString() {
64 return "Create a new reference";
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 public void addElement(DescriptionElementSource element) {
70 getEntity().addSource(element);
71 }
72
73 /** {@inheritDoc} */
74 @Override
75 public void removeElement(DescriptionElementSource element) {
76 getEntity().removeSource(element);
77 }
78 }