Project

General

Profile

Download (2.74 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2015 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

    
10
package eu.etaxonomy.taxeditor.ui.dialog.configurator.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.widgets.Button;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.swt.events.DisposeEvent;
22
import org.eclipse.swt.events.DisposeListener;
23
import org.eclipse.swt.layout.RowLayout;
24

    
25
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
26
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
27
/**
28
 * @author kluther
29
 * @date Jul 13, 2015
30
 *
31
 */
32
public class DeleteNodeConfiguratorComposite extends Composite {
33
	// $Id$
34
	
35
	private final DataBindingContext m_bindingContext;
36

    
37
	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
38
	private final TaxonNodeDeletionConfigurator configurator;
39
	private final Button btnDeleteTaxon;
40

    
41

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

    
60
	        btnDeleteTaxon = new Button(this, SWT.CHECK);
61
	        btnDeleteTaxon.setText("Delete taxon if possible");
62
	     
63
	        m_bindingContext = initDataBindings();
64

    
65
	    }
66

    
67
	    protected DataBindingContext initDataBindings() {
68
	        DataBindingContext bindingContext = new DataBindingContext();
69
	        //
70
	        IObservableValue observeSelectionBtnDeleteTaxonObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxon);
71
	        IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteTaxon").observe(configurator);
72
	        bindingContext.bindValue(observeSelectionBtnDeleteTaxonObserveWidget, deleteTaxonIfPossibleConfiguratorObserveValue, null, null);
73
	        //
74
	        return bindingContext;
75
	    }
76
	}
77

    
78

    
(5-5/8)