3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
;
12 import org
.eclipse
.swt
.events
.SelectionListener
;
13 import org
.eclipse
.swt
.graphics
.Color
;
15 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
16 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
17 import eu
.etaxonomy
.cdm
.model
.description
.StatisticalMeasure
;
18 import eu
.etaxonomy
.taxeditor
.ui
.combo
.TermComboElement
;
19 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractFormSection
;
20 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.AbstractEntityCollectionElement
;
29 public class StatisticalMeasureCollectionElement
extends AbstractEntityCollectionElement
<StatisticalMeasure
> {
32 private TermComboElement
<StatisticalMeasure
> comboStatisticalMeasure
;
38 * @param removeListener
39 * @param isChoosableEntity
40 * @param backgroundColor
43 public StatisticalMeasureCollectionElement(CdmFormFactory formFactory
, AbstractFormSection section
, StatisticalMeasure entity
,
44 SelectionListener removeListener
, Color backgroundColor
, int style
) {
45 super(formFactory
, section
, entity
, removeListener
, false, backgroundColor
, style
);
50 public void createControls(ICdmFormElement element
, int style
) {
51 comboStatisticalMeasure
= formFactory
.createDefinedTermComboElement(TermType
.StatisticalMeasure
, element
, "Statistical measure", null, style
);
55 public void setEntity(StatisticalMeasure entity
) {
57 if(entity
.getId()!=0){
58 comboStatisticalMeasure
.setSelection(entity
);
63 public void handleEvent(Object eventSource
) {
64 if(eventSource
==comboStatisticalMeasure
&& comboStatisticalMeasure
.getSelection()!=null){
65 if(getParentElement() instanceof StatisticalMeasureCollectionSection
){
66 Feature feature
= ((StatisticalMeasureCollectionSection
) getParentElement()).getEntity();
67 feature
.removeRecommendedStatisticalMeasure(entity
);
68 StatisticalMeasure statisticalMeasure
= comboStatisticalMeasure
.getSelection();
69 feature
.addRecommendedStatisticalMeasure(statisticalMeasure
);
70 entity
= statisticalMeasure
;