720b4e865d48b0bf95ca38e57c076feb3a3eb999
[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 toolkit.adapt(btnDeleteSpecimenDescription, true, true);
75 btnDeleteSpecimenDescription.setText("Delete specimen description");
76 m_bindingContext = initDataBindings();
77
78 }
79 protected DataBindingContext initDataBindings() {
80 DataBindingContext bindingContext = new DataBindingContext();
81 //
82 IObservableValue observeSelectionBtnDeleteChildrenObserveWidget = WidgetProperties.selection().observe(btnDeleteChildren);
83 IObservableValue deleteChildrenConfiguratorObserveValue = PojoProperties.value("deleteChildren").observe(configurator);
84 bindingContext.bindValue(observeSelectionBtnDeleteChildrenObserveWidget, deleteChildrenConfiguratorObserveValue, null, null);
85 //
86 IObservableValue observeSelectionBtnDeleteFromTypeDesignationObserveWidget = WidgetProperties.selection().observe(btnDeleteFromTypeDesignation);
87 IObservableValue deleteFromTypeDesignationConfiguratorObserveValue = PojoProperties.value("deleteFromTypeDesignation").observe(configurator);
88 bindingContext.bindValue(observeSelectionBtnDeleteFromTypeDesignationObserveWidget, deleteFromTypeDesignationConfiguratorObserveValue, null, null);
89 //
90 IObservableValue observeSelectionBtnDeleteMolecularDataObserveWidget = WidgetProperties.selection().observe(btnDeleteMolecularData);
91 IObservableValue deleteMolecularDataConfiguratorObserveValue = PojoProperties.value("deleteMolecularData").observe(configurator);
92 bindingContext.bindValue(observeSelectionBtnDeleteMolecularDataObserveWidget, deleteMolecularDataConfiguratorObserveValue, null, null);
93 //
94 IObservableValue observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget = WidgetProperties.selection().observe(btnDeleteIndividualsassociationsfactual);
95 IObservableValue deleteFromIndividualsAssociationConfiguratorObserveValue = PojoProperties.value("deleteFromIndividualsAssociation").observe(configurator);
96 bindingContext.bindValue(observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget, deleteFromIndividualsAssociationConfiguratorObserveValue, null, null);
97 //
98 IObservableValue observeSelectionBtnDeleteSpecimenDescriptionObserveWidget = WidgetProperties.selection().observe(btnDeleteSpecimenDescription);
99 IObservableValue deleteFromDescriptionConfiguratorObserveValue = PojoProperties.value("deleteFromDescription").observe(configurator);
100 bindingContext.bindValue(observeSelectionBtnDeleteSpecimenDescriptionObserveWidget, deleteFromDescriptionConfiguratorObserveValue, null, null);
101 //
102 return bindingContext;
103 }
104 }