2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
11 import org
.eclipse
.swt
.events
.SelectionListener
;
12 import org
.eclipse
.swt
.graphics
.Color
;
14 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
15 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
16 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
17 import eu
.etaxonomy
.taxeditor
.ui
.combo
.term
.TermComboElement
;
18 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
28 public class StatisticalMeasureCollectionElement
extends AbstractEntityCollectionElement
<StatisticalMeasure
> {
31 private TermComboElement
<StatisticalMeasure
> comboStatisticalMeasure
;
37 * @param removeListener
38 * @param isChoosableEntity
39 * @param backgroundColor
42 public StatisticalMeasureCollectionElement(CdmFormFactory formFactory
, AbstractFormSection section
, StatisticalMeasure entity
,
43 SelectionListener removeListener
, Color backgroundColor
, int style
) {
44 super(formFactory
, section
, entity
, removeListener
, backgroundColor
, style
);
49 public void createControls(ICdmFormElement element
, int style
) {
50 comboStatisticalMeasure
= formFactory
.createDefinedTermComboElementDto(TermType
.StatisticalMeasure
, element
, "Statistical measure", null, style
);
54 public void setEntity(StatisticalMeasure entity
) {
56 if(entity
.getId()!=0){
57 comboStatisticalMeasure
.setSelection(entity
);
58 comboStatisticalMeasure
.removeEmptyElement();
63 public void handleEvent(Object eventSource
) {
64 if(eventSource
==comboStatisticalMeasure
&& comboStatisticalMeasure
.getSelection()!=null){
65 if(getParentElement() instanceof StatisticalMeasureCollectionSection
){
66 StatisticalMeasureCollectionSection parentElement
= (StatisticalMeasureCollectionSection
) getParentElement();
67 Feature feature
= parentElement
.getEntity();
68 feature
.removeRecommendedStatisticalMeasure(entity
);
69 StatisticalMeasure statisticalMeasure
= comboStatisticalMeasure
.getSelection();
70 feature
.addRecommendedStatisticalMeasure(statisticalMeasure
);
71 entity
= statisticalMeasure
;
72 //update the parent section to re-set the listeners to the persisted measurement unit
73 parentElement
.removeElementAndUpdate(null);