6d4e0b24d8fcc8246f147b0d3b3b4a3f04ee2cc8
[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
42 /**
43 * Create the composite.
44 * @param parent
45 * @param style
46 */
47 public DeleteSpecimenConfiguratorComposite(SpecimenDeleteConfigurator configurator, Composite parent, int style) {
48 super(parent, style);
49 this.configurator = configurator;
50 addDisposeListener(new DisposeListener() {
51 @Override
52 public void widgetDisposed(DisposeEvent e) {
53 toolkit.dispose();
54 }
55 });
56 toolkit.paintBordersFor(this);
57 setLayout(new RowLayout(SWT.VERTICAL));
58
59 btnDeleteChildren = new Button(this, SWT.CHECK);
60 btnDeleteChildren.setText("Delete Children");
61
62 btnDeleteFromTypeDesignation = new Button(this, SWT.CHECK);
63 btnDeleteFromTypeDesignation.setText("Delete from type designation");
64
65 btnDeleteMolecularData = new Button(this, SWT.CHECK);
66 btnDeleteMolecularData.setText("Delete molecular data");
67 m_bindingContext = initDataBindings();
68
69 }
70
71 protected DataBindingContext initDataBindings() {
72 DataBindingContext bindingContext = new DataBindingContext();
73 //
74 IObservableValue observeSelectionBtnDeleteChildrenObserveWidget = WidgetProperties.selection().observe(btnDeleteChildren);
75 IObservableValue deleteChildrenConfiguratorObserveValue = PojoProperties.value("deleteChildren").observe(configurator);
76 bindingContext.bindValue(observeSelectionBtnDeleteChildrenObserveWidget, deleteChildrenConfiguratorObserveValue, null, null);
77 //
78 IObservableValue observeSelectionBtnDeleteFromTypeDesignationObserveWidget = WidgetProperties.selection().observe(btnDeleteFromTypeDesignation);
79 IObservableValue deleteFromTypeDesignationConfiguratorObserveValue = PojoProperties.value("deleteFromTypeDesignation").observe(configurator);
80 bindingContext.bindValue(observeSelectionBtnDeleteFromTypeDesignationObserveWidget, deleteFromTypeDesignationConfiguratorObserveValue, null, null);
81 //
82 IObservableValue observeSelectionBtnDeleteMolecularDataObserveWidget = WidgetProperties.selection().observe(btnDeleteMolecularData);
83 IObservableValue deleteMolecularDataConfiguratorObserveValue = PojoProperties.value("deleteMolecularData").observe(configurator);
84 bindingContext.bindValue(observeSelectionBtnDeleteMolecularDataObserveWidget, deleteMolecularDataConfiguratorObserveValue, null, null);
85 //
86 return bindingContext;
87 }
88 }