2 * Copyright (C) 2016 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.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
.deleteConfigurator
;
11 import org
.eclipse
.core
.databinding
.DataBindingContext
;
12 import org
.eclipse
.core
.databinding
.beans
.PojoProperties
;
13 import org
.eclipse
.core
.databinding
.observable
.value
.IObservableValue
;
14 import org
.eclipse
.jface
.databinding
.swt
.WidgetProperties
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.events
.DisposeEvent
;
17 import org
.eclipse
.swt
.events
.DisposeListener
;
18 import org
.eclipse
.swt
.layout
.RowLayout
;
19 import org
.eclipse
.swt
.widgets
.Button
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Display
;
22 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
24 import eu
.etaxonomy
.cdm
.api
.service
.config
.MediaDeletionConfigurator
;
31 public class DeleteMediaConfiguratorComposite
extends Composite
{
32 private final DataBindingContext m_bindingContext
;
34 private final FormToolkit toolkit
= new FormToolkit(Display
.getCurrent());
35 private final MediaDeletionConfigurator configurator
;
36 private final Button btnDeleteIfUsedInTaxonDescription
;
37 private final Button btnDeleteIfUsedInSpecimenDescription
;
41 * Create the composite.
45 public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator 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 btnDeleteIfUsedInTaxonDescription
= new Button(this, SWT
.CHECK
);
59 btnDeleteIfUsedInTaxonDescription
.setText("Delete also if media is used in taxon description. ");
60 btnDeleteIfUsedInTaxonDescription
.setSelection(false);
62 btnDeleteIfUsedInSpecimenDescription
= new Button(this, SWT
.CHECK
);
63 btnDeleteIfUsedInSpecimenDescription
.setText("Delete also if media is used in specimen description. ");
64 btnDeleteIfUsedInSpecimenDescription
.setSelection(false);
67 m_bindingContext
= initDataBindings();
71 protected DataBindingContext
initDataBindings() {
72 DataBindingContext bindingContext
= new DataBindingContext();
74 IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription
= WidgetProperties
.selection().observe(btnDeleteIfUsedInTaxonDescription
);
75 IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue
= PojoProperties
.value("deleteIfUsedInTaxonDescription").observe(configurator
);
76 bindingContext
.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription
, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue
, null, null);
78 IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription
= WidgetProperties
.selection().observe(btnDeleteIfUsedInSpecimenDescription
);
79 IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue
= PojoProperties
.value("deleteIfUsedInSpecimenDescription").observe(configurator
);
80 bindingContext
.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription
, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue
, null, null);
82 return bindingContext
;