ref #9838: change order of ui element creation and setting entity in collection elements
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / description / StatisticalMeasurementValueSection.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.description.QuantitativeData;
17 import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
18 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
19 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
20 import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
21 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
22 import eu.etaxonomy.taxeditor.ui.section.DefaultCdmBaseComparator;
23
24 /**
25 * <p>StatisticalMeasurementValueSection class.</p>
26 *
27 * @author n.hoffmann
28 * @created Sep 15, 2010
29 * @version 1.0
30 */
31 public class StatisticalMeasurementValueSection extends
32 AbstractEntityCollectionSection<QuantitativeData, StatisticalMeasurementValue> implements IEnableableFormElement{
33
34 /**
35 * <p>Constructor for StatisticalMeasurementValueSection.</p>
36 *
37 * @param formFactory 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 StatisticalMeasurementValueSection(CdmFormFactory formFactory,
43 ConversationHolder conversation, ICdmFormElement parentElement,
44 int style) {
45 super(formFactory, conversation, parentElement, "Statistical Measurement Value", style);
46 }
47
48 /** {@inheritDoc} */
49 @Override
50 public Collection<StatisticalMeasurementValue> getCollection(
51 QuantitativeData entity) {
52 return entity.getStatisticalValues();
53 }
54
55 @Override
56 public Comparator<StatisticalMeasurementValue> getComparator() {
57 return new DefaultCdmBaseComparator<>();
58 }
59
60 /** {@inheritDoc} */
61 @Override
62 public StatisticalMeasurementValue createNewElement() {
63 return StatisticalMeasurementValue.NewInstance();
64 }
65
66 /** {@inheritDoc} */
67 @Override
68 public void addElement(StatisticalMeasurementValue element) {
69 getEntity().addStatisticalValue(element);
70 }
71
72 /** {@inheritDoc} */
73 @Override
74 public void removeElement(StatisticalMeasurementValue element) {
75 getEntity().removeStatisticalValue(element);
76 }
77
78 /** {@inheritDoc} */
79 @Override
80 public String getEmptyString() {
81 return "No statistical values yet.";
82 }
83
84 /** {@inheritDoc} */
85 @Override
86 protected String getTooltipString() {
87 return "Create new statistical value";
88 }
89
90 /**
91 * {@inheritDoc}
92 */
93 @Override
94 public StatisticalMeasurementValue addExisting() {
95 return null;
96 }
97
98 /**
99 * {@inheritDoc}
100 */
101 @Override
102 public boolean allowAddExisting() {
103 return false;
104 }
105 }