Project

General

Profile

Download (3.44 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;
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.FillLayout;
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.events.ExpansionEvent;
24
import org.eclipse.ui.forms.events.IExpansionListener;
25
import org.eclipse.ui.forms.widgets.FormToolkit;
26
import org.eclipse.ui.forms.widgets.Section;
27

    
28
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
29

    
30
/**
31
 * @author pplitzner
32
 * @date Feb 16, 2015
33
 *
34
 */
35
public class DeleteConfiguratorComposite extends Composite implements IExpansionListener{
36
    private final DataBindingContext m_bindingContext;
37

    
38
    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
39
    private TaxonBaseDeletionConfigurator configurator = null;
40
    private final Button btnDeleteTaxonName;
41

    
42
    /**
43
     * Create the composite.
44
     * @param parent
45
     * @param style
46
     */
47
    public DeleteConfiguratorComposite(TaxonBaseDeletionConfigurator configurator, final Composite parent, int style) {
48
        super(parent, SWT.NONE);
49
        this.configurator = configurator;
50

    
51
        addDisposeListener(new DisposeListener() {
52
            @Override
53
            public void widgetDisposed(DisposeEvent e) {
54
                toolkit.dispose();
55
            }
56
        });
57
        toolkit.paintBordersFor(this);
58
        setLayout(new FillLayout(SWT.HORIZONTAL));
59

    
60
        Section sctnConfigure = toolkit.createSection(this, Section.CLIENT_INDENT | Section.TWISTIE);
61
        sctnConfigure.addExpansionListener(this);
62
        sctnConfigure.setBackground(getBackground());
63
        toolkit.paintBordersFor(sctnConfigure);
64
        sctnConfigure.setText("Configure");
65

    
66
        btnDeleteTaxonName = new Button(sctnConfigure, SWT.CHECK);
67
        sctnConfigure.setClient(btnDeleteTaxonName);
68
        btnDeleteTaxonName.setText("Delete Taxon Name");
69
        m_bindingContext = initDataBindings();
70

    
71
    }
72
    protected DataBindingContext initDataBindings() {
73
        DataBindingContext bindingContext = new DataBindingContext();
74
        //
75
        IObservableValue observeSelectionBtnDeleteTaxonNameObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxonName);
76
        IObservableValue deleteNameIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteNameIfPossible").observe(configurator);
77
        bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
78
        //
79
        return bindingContext;
80
    }
81

    
82
    public Button getBtnDeleteTaxonName() {
83
        return btnDeleteTaxonName;
84
    }
85

    
86
    @Override
87
    public void expansionStateChanged(ExpansionEvent e) {
88
        getShell().setSize(getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT));
89
    }
90
    @Override
91
    public void expansionStateChanging(ExpansionEvent e) {
92
    }
93
}
(2-2/7)