1
|
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
|
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
|
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;
|
22
|
|
23
|
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
24
|
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
|
25
|
/**
|
26
|
* @author kluther
|
27
|
* @date Jul 13, 2015
|
28
|
*
|
29
|
*/
|
30
|
public class DeleteNodeConfiguratorComposite extends Composite {
|
31
|
// $Id$
|
32
|
|
33
|
private final DataBindingContext m_bindingContext;
|
34
|
|
35
|
private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
|
36
|
private final TaxonNodeDeletionConfigurator configurator;
|
37
|
private final Button btnDeleteTaxon;
|
38
|
|
39
|
|
40
|
/**
|
41
|
* Create the composite.
|
42
|
* @param parent
|
43
|
* @param style
|
44
|
*/
|
45
|
public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator, Composite parent, int style) {
|
46
|
super(parent, style);
|
47
|
this.configurator = configurator;
|
48
|
addDisposeListener(new DisposeListener() {
|
49
|
@Override
|
50
|
public void widgetDisposed(DisposeEvent e) {
|
51
|
toolkit.dispose();
|
52
|
}
|
53
|
});
|
54
|
toolkit.paintBordersFor(this);
|
55
|
setLayout(new RowLayout(SWT.VERTICAL));
|
56
|
setBackground(getBackground());
|
57
|
|
58
|
btnDeleteTaxon = new Button(this, SWT.CHECK);
|
59
|
btnDeleteTaxon.setText("Delete taxon if possible");
|
60
|
|
61
|
m_bindingContext = initDataBindings();
|
62
|
|
63
|
}
|
64
|
|
65
|
protected DataBindingContext initDataBindings() {
|
66
|
DataBindingContext bindingContext = new DataBindingContext();
|
67
|
//
|
68
|
IObservableValue observeSelectionBtnDeleteTaxonObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxon);
|
69
|
IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteTaxon").observe(configurator);
|
70
|
bindingContext.bindValue(observeSelectionBtnDeleteTaxonObserveWidget, deleteTaxonIfPossibleConfiguratorObserveValue, null, null);
|
71
|
//
|
72
|
return bindingContext;
|
73
|
}
|
74
|
}
|
75
|
|
76
|
|