Project

General

Profile

« Previous | Next » 

Revision a4f62469

Added by Katja Luther over 7 years ago

add a new DeleteMediaConfiguratorComposite

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteMediaConfiguratorComposite.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
11

  
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;
24

  
25
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
26

  
27
/**
28
 * @author k.luther
29
 * @date 02.11.2016
30
 *
31
 */
32
public class DeleteMediaConfiguratorComposite extends Composite {
33
    private final DataBindingContext m_bindingContext;
34

  
35
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36
    private final MediaDeletionConfigurator configurator;
37
    private final Button btnDeleteIfUsedInTaxonDescription;
38
    private final Button btnDeleteIfUsedInSpecimenDescription;
39

  
40

  
41
    /**
42
     * Create the composite.
43
     * @param parent
44
     * @param style
45
     */
46
    public DeleteMediaConfiguratorComposite(MediaDeletionConfigurator configurator, Composite parent, int style) {
47
        super(parent, style);
48
        this.configurator = configurator;
49
        addDisposeListener(new DisposeListener() {
50
            @Override
51
            public void widgetDisposed(DisposeEvent e) {
52
                toolkit.dispose();
53
            }
54
        });
55
        toolkit.paintBordersFor(this);
56
        setLayout(new RowLayout(SWT.VERTICAL));
57
        setBackground(getBackground());
58

  
59
        btnDeleteIfUsedInTaxonDescription = new Button(this, SWT.CHECK);
60
        btnDeleteIfUsedInTaxonDescription.setText("Delete also if media is used in taxon description. ");
61
        btnDeleteIfUsedInTaxonDescription.setSelection(false);
62

  
63
        btnDeleteIfUsedInSpecimenDescription = new Button(this, SWT.CHECK);
64
        btnDeleteIfUsedInSpecimenDescription.setText("Delete also if media is used in specimen description. ");
65
        btnDeleteIfUsedInSpecimenDescription.setSelection(false);
66

  
67

  
68
        m_bindingContext = initDataBindings();
69

  
70
    }
71

  
72
    protected DataBindingContext initDataBindings() {
73
        DataBindingContext bindingContext = new DataBindingContext();
74
        //
75
        IObservableValue observeSelectionBtnDeleteIfUsedInTaxonDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInTaxonDescription);
76
        IObservableValue deleteIfUsedInTaxonDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInTaxonDescription").observe(configurator);
77
        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInTaxonDescription, deleteIfUsedInTaxonDescriptionConfiguratorObserveValue, null, null);
78

  
79
        IObservableValue observeSelectionBtnDeleteIfUsedInSpecimenDescription = WidgetProperties.selection().observe(btnDeleteIfUsedInSpecimenDescription);
80
        IObservableValue deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue = PojoProperties.value("deleteIfUsedInSpecimenDescription").observe(configurator);
81
        bindingContext.bindValue(observeSelectionBtnDeleteIfUsedInSpecimenDescription, deleteIfUsedInSpecimenDescriptionConfiguratorObserveValue, null, null);
82

  
83
        return bindingContext;
84
    }
85

  
86

  
87
}

Also available in: Unified diff