- fixed background of checkbox
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / deleteConfigurator / DeleteSpecimenConfiguratorComposite.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10 package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
11
12 import org.eclipse.core.databinding.DataBindingContext;
13 import org.eclipse.core.databinding.beans.PojoProperties;
14 import org.eclipse.core.databinding.observable.value.IObservableValue;
15 import org.eclipse.jface.databinding.swt.WidgetProperties;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.events.DisposeEvent;
18 import org.eclipse.swt.events.DisposeListener;
19 import org.eclipse.swt.layout.RowLayout;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Display;
23 import org.eclipse.ui.forms.widgets.FormToolkit;
24
25 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
26
27 /**
28 * @author pplitzner
29 * @date Feb 18, 2015
30 *
31 */
32 public class DeleteSpecimenConfiguratorComposite extends Composite {
33 private final DataBindingContext m_bindingContext;
34
35 private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36
37 private final SpecimenDeleteConfigurator configurator;
38 private final Button btnDeleteChildren;
39 private final Button btnDeleteFromTypeDesignation;
40 private final Button btnDeleteMolecularData;
41 private final Button btnDeleteIndividualsassociationsfactual;
42 private final Button btnDeleteSpecimenDescription;
43
44 /**
45 * Create the composite.
46 * @param parent
47 * @param style
48 */
49 public DeleteSpecimenConfiguratorComposite(SpecimenDeleteConfigurator configurator, Composite parent, int style) {
50 super(parent, style);
51 this.configurator = configurator;
52 addDisposeListener(new DisposeListener() {
53 @Override
54 public void widgetDisposed(DisposeEvent e) {
55 toolkit.dispose();
56 }
57 });
58 toolkit.paintBordersFor(this);
59 setLayout(new RowLayout(SWT.VERTICAL));
60
61 btnDeleteChildren = new Button(this, SWT.CHECK);
62 btnDeleteChildren.setText("Delete Children");
63
64 btnDeleteFromTypeDesignation = new Button(this, SWT.CHECK);
65 btnDeleteFromTypeDesignation.setText("Delete from type designation");
66
67 btnDeleteMolecularData = new Button(this, SWT.CHECK);
68 btnDeleteMolecularData.setText("Delete molecular data");
69
70 btnDeleteIndividualsassociationsfactual = new Button(this, SWT.CHECK);
71 btnDeleteIndividualsassociationsfactual.setText("Delete from factual data");
72
73 btnDeleteSpecimenDescription = new Button(this, SWT.CHECK);
74 btnDeleteSpecimenDescription.setText("Delete specimen description");
75 m_bindingContext = initDataBindings();
76
77 }
78 protected DataBindingContext initDataBindings() {
79 DataBindingContext bindingContext = new DataBindingContext();
80 //
81 IObservableValue observeSelectionBtnDeleteChildrenObserveWidget = WidgetProperties.selection().observe(btnDeleteChildren);
82 IObservableValue deleteChildrenConfiguratorObserveValue = PojoProperties.value("deleteChildren").observe(configurator);
83 bindingContext.bindValue(observeSelectionBtnDeleteChildrenObserveWidget, deleteChildrenConfiguratorObserveValue, null, null);
84 //
85 IObservableValue observeSelectionBtnDeleteFromTypeDesignationObserveWidget = WidgetProperties.selection().observe(btnDeleteFromTypeDesignation);
86 IObservableValue deleteFromTypeDesignationConfiguratorObserveValue = PojoProperties.value("deleteFromTypeDesignation").observe(configurator);
87 bindingContext.bindValue(observeSelectionBtnDeleteFromTypeDesignationObserveWidget, deleteFromTypeDesignationConfiguratorObserveValue, null, null);
88 //
89 IObservableValue observeSelectionBtnDeleteMolecularDataObserveWidget = WidgetProperties.selection().observe(btnDeleteMolecularData);
90 IObservableValue deleteMolecularDataConfiguratorObserveValue = PojoProperties.value("deleteMolecularData").observe(configurator);
91 bindingContext.bindValue(observeSelectionBtnDeleteMolecularDataObserveWidget, deleteMolecularDataConfiguratorObserveValue, null, null);
92 //
93 IObservableValue observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget = WidgetProperties.selection().observe(btnDeleteIndividualsassociationsfactual);
94 IObservableValue deleteFromIndividualsAssociationConfiguratorObserveValue = PojoProperties.value("deleteFromIndividualsAssociation").observe(configurator);
95 bindingContext.bindValue(observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget, deleteFromIndividualsAssociationConfiguratorObserveValue, null, null);
96 //
97 IObservableValue observeSelectionBtnDeleteSpecimenDescriptionObserveWidget = WidgetProperties.selection().observe(btnDeleteSpecimenDescription);
98 IObservableValue deleteFromDescriptionConfiguratorObserveValue = PojoProperties.value("deleteFromDescription").observe(configurator);
99 bindingContext.bindValue(observeSelectionBtnDeleteSpecimenDescriptionObserveWidget, deleteFromDescriptionConfiguratorObserveValue, null, null);
100 //
101 return bindingContext;
102 }
103 }