cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / feature / AbstractApplicableElement.java
1 /**
2 * Copyright (C) 2019 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 package eu.etaxonomy.taxeditor.ui.section.feature;
10
11 import java.util.Collections;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.events.SelectionListener;
15 import org.eclipse.swt.graphics.Color;
16
17 import eu.etaxonomy.cdm.model.description.Feature;
18 import eu.etaxonomy.cdm.model.description.FeatureState;
19 import eu.etaxonomy.cdm.model.description.State;
20 import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;
21 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
22 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
23 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
24 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
25 import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
26
27 /**
28 * @author pplitzner
29 * @since Aug 16, 2019
30 */
31 public abstract class AbstractApplicableElement extends AbstractEntityCollectionElement<FeatureState> {
32
33 private TermComboElement<State> comboState;
34 private EntitySelectionElement<Feature> selectFeature;
35
36 public AbstractApplicableElement(CdmFormFactory formFactory, AbstractFormSection<?> section, FeatureState entity,
37 SelectionListener removeListener, Color backgroundColor, int style) {
38 super(formFactory, section, entity, removeListener, backgroundColor, style);
39
40 }
41
42 @Override
43 public void createControls(ICdmFormElement element, int style) {
44 selectFeature = formFactory.createSelectionElement(Feature.class, element, "Feature", null, EntitySelectionElement.SELECTABLE, SWT.NONE);
45 comboState = formFactory.createDefinedTermComboElement(Collections.EMPTY_LIST, element, getComboLabel(), null, style);
46 comboState.setEnabled(false);
47 selectFeature.setEnabled(false);
48
49 selectFeature.setEntity(entity.getFeature());
50 comboState.setSelection(entity.getState());
51 }
52
53 protected abstract String getComboLabel();
54
55 @Override
56 public void setEntity(FeatureState entity) {
57 this.entity = entity;
58 if (selectFeature != null){
59 selectFeature.setEntity(entity.getFeature());
60 comboState.setSelection(entity.getState());
61 }
62 }
63
64 @Override
65 public void handleEvent(Object eventSource) {
66 }
67 }