Project

General

Profile

Download (3.59 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
10

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

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

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

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

    
39

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

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

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

    
66

    
67
        m_bindingContext = initDataBindings();
68

    
69
    }
70

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

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

    
82
        return bindingContext;
83
    }
84

    
85

    
86
}
(3-3/8)