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 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
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
.FillLayout
;
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
.events
.ExpansionEvent
;
24 import org
.eclipse
.ui
.forms
.events
.IExpansionListener
;
25 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
26 import org
.eclipse
.ui
.forms
.widgets
.Section
;
28 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonBaseDeletionConfigurator
;
35 public class DeleteConfiguratorComposite
extends Composite
implements IExpansionListener
{
36 private final DataBindingContext m_bindingContext
;
38 private final FormToolkit toolkit
= new FormToolkit(Display
.getCurrent());
39 private TaxonBaseDeletionConfigurator configurator
= null;
40 private final Button btnDeleteTaxonName
;
43 * Create the composite.
47 public DeleteConfiguratorComposite(TaxonBaseDeletionConfigurator configurator
, final Composite parent
, int style
) {
48 super(parent
, SWT
.NONE
);
49 this.configurator
= configurator
;
51 addDisposeListener(new DisposeListener() {
53 public void widgetDisposed(DisposeEvent e
) {
57 toolkit
.paintBordersFor(this);
58 setLayout(new FillLayout(SWT
.HORIZONTAL
));
60 Section sctnConfigure
= toolkit
.createSection(this, Section
.CLIENT_INDENT
| Section
.TWISTIE
);
61 sctnConfigure
.addExpansionListener(this);
62 sctnConfigure
.setBackground(getBackground());
63 toolkit
.paintBordersFor(sctnConfigure
);
64 sctnConfigure
.setText("Configure");
66 btnDeleteTaxonName
= new Button(sctnConfigure
, SWT
.CHECK
);
67 sctnConfigure
.setClient(btnDeleteTaxonName
);
68 btnDeleteTaxonName
.setText("Delete Taxon Name");
69 m_bindingContext
= initDataBindings();
72 protected DataBindingContext
initDataBindings() {
73 DataBindingContext bindingContext
= new DataBindingContext();
75 IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget
= WidgetProperties
.selection().observe(btnDeleteTaxonName
);
76 IObservableValue deleteNameIfPossibleConfiguratorObserveValue
= PojoProperties
.value("deleteNameIfPossible").observe(configurator
);
77 bindingContext
.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget
, deleteNameIfPossibleConfiguratorObserveValue
, null, null);
79 return bindingContext
;
82 public Button
getBtnDeleteTaxonName() {
83 return btnDeleteTaxonName
;
87 public void expansionStateChanged(ExpansionEvent e
) {
88 getShell().setSize(getShell().computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
));
91 public void expansionStateChanging(ExpansionEvent e
) {