2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.deleteConfigurator
;
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
.widgets
.Button
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Display
;
20 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
21 import org
.eclipse
.swt
.events
.DisposeEvent
;
22 import org
.eclipse
.swt
.events
.DisposeListener
;
23 import org
.eclipse
.swt
.layout
.RowLayout
;
25 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
26 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonNodeDeletionConfigurator
;
32 public class DeleteNodeConfiguratorComposite
extends Composite
{
35 private final DataBindingContext m_bindingContext
;
37 private final FormToolkit toolkit
= new FormToolkit(Display
.getCurrent());
38 private final TaxonNodeDeletionConfigurator configurator
;
39 private final Button btnDeleteTaxon
;
43 * Create the composite.
47 public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator
, Composite parent
, int style
) {
49 this.configurator
= configurator
;
50 addDisposeListener(new DisposeListener() {
52 public void widgetDisposed(DisposeEvent e
) {
56 toolkit
.paintBordersFor(this);
57 setLayout(new RowLayout(SWT
.VERTICAL
));
58 setBackground(getBackground());
60 btnDeleteTaxon
= new Button(this, SWT
.CHECK
);
61 btnDeleteTaxon
.setText("Delete taxon if possible");
63 m_bindingContext
= initDataBindings();
67 protected DataBindingContext
initDataBindings() {
68 DataBindingContext bindingContext
= new DataBindingContext();
70 IObservableValue observeSelectionBtnDeleteTaxonObserveWidget
= WidgetProperties
.selection().observe(btnDeleteTaxon
);
71 IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue
= PojoProperties
.value("deleteTaxon").observe(configurator
);
72 bindingContext
.bindValue(observeSelectionBtnDeleteTaxonObserveWidget
, deleteTaxonIfPossibleConfiguratorObserveValue
, null, null);
74 return bindingContext
;