add a new DeleteMediaConfiguratorComposite
authorKatja Luther <k.luther@bgbm.org>
Thu, 3 Nov 2016 08:52:00 +0000 (09:52 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 3 Nov 2016 08:52:00 +0000 (09:52 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteMediaConfiguratorComposite.java [new file with mode: 0755]

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteMediaConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteMediaConfiguratorComposite.java
new file mode 100755 (executable)
index 0000000..3f5006b
--- /dev/null
@@ -0,0 +1,87 @@
+// $Id$
+/**
+* Copyright (C) 2016 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.PojoProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
+
+/**
+ * @author k.luther
+ * @date 02.11.2016
+ *
+ */
+public class DeleteMediaConfiguratorComposite extends Composite {
+    private final DataBindingContext m_bindingContext;
+
+    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+    private final MediaDeletionConfigurator configurator;
+    private final Button btnDeleteIfUsedInTaxonDescription;
+    private final Button btnDeleteIfUsedInSpecimenDescription;
+
+
+    /**
+     * Create the composite.
+     * @param parent
+     * @param style
+     */
+    public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style) {
+        super(parent, style);
+        this.configurator = configurator;
+        addDisposeListener(new DisposeListener() {
+            @Override
+            public void widgetDisposed(DisposeEvent e) {
+                toolkit.dispose();
+            }
+        });
+        toolkit.paintBordersFor(this);
+        setLayout(new RowLayout(SWT.VERTICAL));
+        setBackground(getBackground());
+
+        btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
+        btnDeleteIfUsedInTaxonDescription.setText("Delete also if media is used in taxon description. ");
+        btnDeleteIfUsedInTaxonDescription.setSelection(false);
+
+        btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
+        btnDeleteIfUsedInSpecimenDescription.setText("Delete also if media is used in specimen description. ");
+        btnDeleteIfUsedInSpecimenDescription.setSelection(false);
+
+
+        m_bindingContext = initDataBindings();
+
+    }
+
+    protected DataBindingContext initDataBindings() {
+        DataBindingContext bindingContext = new DataBindingContext();
+        //
+        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
+        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
+
+        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
+        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
+
+        return bindingContext;
+    }
+
+
+}