add default comparator to all term combos without own comparator
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / DescriptionSourceSection.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.ui.section.description;
11
12 import java.util.Collection;
13 import java.util.Comparator;
14
15 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
16 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
17 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
18 import eu.etaxonomy.cdm.model.description.DescriptionBase;
19 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
20 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
22 import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
23
24 /**
25 * <p>DescriptionSourceSection class.</p>
26 *
27 * @author n.hoffmann
28 * @created Mar 18, 2010
29 * @version 1.0
30 */
31 public class DescriptionSourceSection extends
32 AbstractEntityCollectionSection<DescriptionBase, IdentifiableSource>{
33
34 /**
35 * <p>Constructor for DescriptionSourceSection.</p>
36 *
37 * @param cdmFormFactory a {@link eu.etaxonomy.taxeditor.ui.element.CdmFormFactory} object.
38 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
39 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
40 * @param style a int.
41 */
42 public DescriptionSourceSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
43 ICdmFormElement parentElement, int style) {
44 super(cdmFormFactory, conversation, parentElement, "Sources", style);
45 }
46
47
48
49 /** {@inheritDoc} */
50 @Override
51 public void addElement(IdentifiableSource element) {
52 getEntity().addSource(element);
53 }
54
55 /** {@inheritDoc} */
56 @Override
57 public IdentifiableSource createNewElement() {
58 OriginalSourceType ost = OriginalSourceType.PrimaryTaxonomicSource;
59 return IdentifiableSource.NewInstance(ost);
60
61 }
62
63 /** {@inheritDoc} */
64 @Override
65 public Collection<IdentifiableSource> getCollection(DescriptionBase entity) {
66 return entity.getSources();
67 }
68
69 @Override
70 public Comparator<IdentifiableSource> getComparator() {
71 return new DefaultCdmBaseComparator<>();
72 }
73
74 /** {@inheritDoc} */
75 @Override
76 public String getEmptyString() {
77 return "No description sources yet.";
78 }
79
80 /** {@inheritDoc} */
81 @Override
82 protected String getTooltipString() {
83 return "Add a reference as source for this description";
84 }
85
86 /** {@inheritDoc} */
87 @Override
88 public void removeElement(IdentifiableSource element) {
89 getEntity().removeSource(element);
90 }
91
92
93
94 /**
95 * {@inheritDoc}
96 */
97 @Override
98 public IdentifiableSource addExisting() {
99 return null;
100 }
101
102
103
104 /**
105 * {@inheritDoc}
106 */
107 @Override
108 public boolean allowAddExisting() {
109 return false;
110 }
111 }