Project

General

Profile

Download (4.65 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2015 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.SpecimenDeleteConfigurator;
26

    
27
/**
28
 * @author pplitzner
29
 * @date Feb 18, 2015
30
 *
31
 */
32
public class DeleteSpecimenConfiguratorComposite extends Composite {
33
    private final DataBindingContext m_bindingContext;
34

    
35
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
36

    
37
    private final SpecimenDeleteConfigurator configurator;
38
    private final Button btnDeleteChildren;
39
    private final Button btnDeleteFromTypeDesignation;
40
    private final Button btnDeleteIndividualsassociationsfactual;
41
    private final Button btnDeleteSpecimenDescription;
42

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

    
60
        btnDeleteChildren = new Button(this, SWT.CHECK);
61
        btnDeleteChildren.setText("Delete Children");
62

    
63
        btnDeleteFromTypeDesignation = new Button(this, SWT.CHECK);
64
        btnDeleteFromTypeDesignation.setText("Delete from type designations");
65

    
66
        btnDeleteIndividualsassociationsfactual = new Button(this, SWT.CHECK);
67
        btnDeleteIndividualsassociationsfactual.setText("Delete from factual data");
68

    
69
        btnDeleteSpecimenDescription = new Button(this, SWT.CHECK);
70
        btnDeleteSpecimenDescription.setText("Delete from \"Described specimen\" in taxon descriptions");
71
        m_bindingContext = initDataBindings();
72

    
73
    }
74
    protected DataBindingContext initDataBindings() {
75
        DataBindingContext bindingContext = new DataBindingContext();
76
        //
77
        IObservableValue observeSelectionBtnDeleteChildrenObserveWidget = WidgetProperties.selection().observe(btnDeleteChildren);
78
        IObservableValue deleteChildrenConfiguratorObserveValue = PojoProperties.value("deleteChildren").observe(configurator);
79
        bindingContext.bindValue(observeSelectionBtnDeleteChildrenObserveWidget, deleteChildrenConfiguratorObserveValue, null, null);
80
        //
81
        IObservableValue observeSelectionBtnDeleteFromTypeDesignationObserveWidget = WidgetProperties.selection().observe(btnDeleteFromTypeDesignation);
82
        IObservableValue deleteFromTypeDesignationConfiguratorObserveValue = PojoProperties.value("deleteFromTypeDesignation").observe(configurator);
83
        bindingContext.bindValue(observeSelectionBtnDeleteFromTypeDesignationObserveWidget, deleteFromTypeDesignationConfiguratorObserveValue, null, null);
84
        //
85
        IObservableValue observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget = WidgetProperties.selection().observe(btnDeleteIndividualsassociationsfactual);
86
        IObservableValue deleteFromIndividualsAssociationConfiguratorObserveValue = PojoProperties.value("deleteFromIndividualsAssociation").observe(configurator);
87
        bindingContext.bindValue(observeSelectionBtnDeleteIndividualsassociationsfactualObserveWidget, deleteFromIndividualsAssociationConfiguratorObserveValue, null, null);
88
        //
89
        IObservableValue observeSelectionBtnDeleteSpecimenDescriptionObserveWidget = WidgetProperties.selection().observe(btnDeleteSpecimenDescription);
90
        IObservableValue deleteFromDescriptionConfiguratorObserveValue = PojoProperties.value("deleteFromDescription").observe(configurator);
91
        bindingContext.bindValue(observeSelectionBtnDeleteSpecimenDescriptionObserveWidget, deleteFromDescriptionConfiguratorObserveValue, null, null);
92
        //
93
        return bindingContext;
94
    }
95
}
(5-5/6)