3 * Copyright (C) 2016 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
.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
.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
;
25 import eu
.etaxonomy
.cdm
.api
.service
.config
.MediaDeletionConfigurator
;
32 public class DeleteMediaConfiguratorComposite
extends Composite
{
33 private final DataBindingContext m_bindingContext
;
35 private final FormToolkit toolkit
= new FormToolkit(Display
.getCurrent());
36 private final MediaDeletionConfigurator configurator
;
37 private final Button btnDeleteIfUsedInTaxonDescription
;
38 private final Button btnDeleteIfUsedInSpecimenDescription
;
42 * Create the composite.
46 public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator
, Composite parent
, int style
) {
48 this.configurator
= configurator
;
49 addDisposeListener(new DisposeListener() {
51 public void widgetDisposed(DisposeEvent e
) {
55 toolkit
.paintBordersFor(this);
56 setLayout(new RowLayout(SWT
.VERTICAL
));
57 setBackground(getBackground());
59 btnDeleteIfUsedInTaxonDescription
= new Button(this, SWT
.CHECK
);
60 btnDeleteIfUsedInTaxonDescription
.setText("Delete also if media is used in taxon description. ");
61 btnDeleteIfUsedInTaxonDescription
.setSelection(false);
63 btnDeleteIfUsedInSpecimenDescription
= new Button(this, SWT
.CHECK
);
64 btnDeleteIfUsedInSpecimenDescription
.setText("Delete also if media is used in specimen description. ");
65 btnDeleteIfUsedInSpecimenDescription
.setSelection(false);
68 m_bindingContext
= initDataBindings();
72 protected DataBindingContext
initDataBindings() {
73 DataBindingContext bindingContext
= new DataBindingContext();
75 IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription
= WidgetProperties
.selection().observe(btnDeleteIfUsedInTaxonDescription
);
76 IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue
= PojoProperties
.value("deleteIfUsedInTaxonDescription").observe(configurator
);
77 bindingContext
.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription
, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue
, null, null);
79 IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription
= WidgetProperties
.selection().observe(btnDeleteIfUsedInSpecimenDescription
);
80 IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue
= PojoProperties
.value("deleteIfUsedInSpecimenDescription").observe(configurator
);
81 bindingContext
.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription
, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue
, null, null);
83 return bindingContext
;