From: Katja Luther Date: Thu, 3 Nov 2016 08:52:00 +0000 (+0100) Subject: add a new DeleteMediaConfiguratorComposite X-Git-Tag: 4.4.0^2~69 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/a4f62469bb1ad728e1231065fee024b0a15320fb?hp=f1a1a089b77b5a3bae78536a91f7e02738daeaef add a new DeleteMediaConfiguratorComposite --- 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 index 000000000..3f5006bbb --- /dev/null +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteMediaConfiguratorComposite.java @@ -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; + } + + +}