1 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.deleteConfigurator
;
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 import org
.eclipse
.core
.databinding
.DataBindingContext
;
11 import org
.eclipse
.core
.databinding
.beans
.PojoProperties
;
12 import org
.eclipse
.core
.databinding
.observable
.value
.IObservableValue
;
13 import org
.eclipse
.jface
.databinding
.swt
.WidgetProperties
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.widgets
.Button
;
16 import org
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.swt
.widgets
.Display
;
18 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
19 import org
.eclipse
.swt
.events
.DisposeEvent
;
20 import org
.eclipse
.swt
.events
.DisposeListener
;
21 import org
.eclipse
.swt
.layout
.RowLayout
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
24 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonNodeDeletionConfigurator
;
30 public class DeleteNodeConfiguratorComposite
extends Composite
{
33 private final DataBindingContext m_bindingContext
;
35 private final FormToolkit toolkit
= new FormToolkit(Display
.getCurrent());
36 private final TaxonNodeDeletionConfigurator configurator
;
37 private final Button btnDeleteTaxon
;
41 * Create the composite.
45 public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator
, Composite parent
, int style
) {
47 this.configurator
= configurator
;
48 addDisposeListener(new DisposeListener() {
50 public void widgetDisposed(DisposeEvent e
) {
54 toolkit
.paintBordersFor(this);
55 setLayout(new RowLayout(SWT
.VERTICAL
));
56 setBackground(getBackground());
58 btnDeleteTaxon
= new Button(this, SWT
.CHECK
);
59 btnDeleteTaxon
.setText("Delete taxon if possible");
61 m_bindingContext
= initDataBindings();
65 protected DataBindingContext
initDataBindings() {
66 DataBindingContext bindingContext
= new DataBindingContext();
68 IObservableValue observeSelectionBtnDeleteTaxonObserveWidget
= WidgetProperties
.selection().observe(btnDeleteTaxon
);
69 IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue
= PojoProperties
.value("deleteTaxon").observe(configurator
);
70 bindingContext
.bindValue(observeSelectionBtnDeleteTaxonObserveWidget
, deleteTaxonIfPossibleConfiguratorObserveValue
, null, null);
72 return bindingContext
;