Project

General

Profile

Download (6.78 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2017 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.configurator;
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.jface.wizard.WizardPage;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.layout.GridLayout;
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.swt.widgets.Event;
24
import org.eclipse.swt.widgets.Listener;
25

    
26
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
27
import eu.etaxonomy.taxeditor.l10n.Messages;
28
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
29

    
30
/**
31
 * @author k.luther
32
 * @date 10.10.2017
33
 *
34
 */
35
public class PublishSubTreeConfiguratorWizardPage extends WizardPage implements Listener {
36

    
37
    private DataBindingContext m_bindingContext;
38

    
39
    private final static CdmFormFactory toolkit = new CdmFormFactory(Display.getCurrent());
40
    private final PublishForSubtreeConfigurator configurator;
41

    
42
    private Button btnIncludeAcceptedTaxa;
43
    private Button btnIncludeSynonyms;
44
    private Button btnIncludeSharedTaxa;
45

    
46
    private Button btnPublish;
47

    
48

    
49
    /**
50
     * @param string
51
     */
52
    public PublishSubTreeConfiguratorWizardPage(PublishForSubtreeConfigurator configurator) {
53
        super("Set Publish Flag Configuration");
54
        this.configurator = configurator;
55
        this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
56

    
57
    }
58

    
59

    
60

    
61
    /* (non-Javadoc)
62
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
63
     */
64
    @Override
65
    public void createControl(Composite parent) {
66

    
67
        final Composite composite = new Composite(parent, SWT.NULL);
68

    
69
        GridLayout gridLayout = new GridLayout();
70
        gridLayout.numColumns = 1;
71

    
72
        composite.setLayout(gridLayout);
73
        final Composite control = new Composite(composite, SWT.NULL);
74
        GridLayout gridLayoutControl = new GridLayout();
75

    
76
        control.setLayout(gridLayoutControl);
77
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
78

    
79
        btnPublish = new Button(control, SWT.CHECK);
80
        btnPublish.setText(Messages.SetPublishConfiguration_Publish);
81
        btnPublish.setToolTipText(Messages.SetPublishConfiguration_Publish_tooltip);
82
        btnPublish.setSelection(configurator.isPublish());
83

    
84

    
85
      //  Composite control = toolkit.createComposite(composite);
86
        btnIncludeAcceptedTaxa = new Button(control, SWT.CHECK);
87
        btnIncludeAcceptedTaxa.setText(Messages.SetPublishConfiguration_IncludeAcceptedTaxa);
88
        btnIncludeAcceptedTaxa.setSelection(configurator.isIncludeAcceptedTaxa());
89
        btnIncludeAcceptedTaxa.addListener(SWT.Selection, new Listener() {
90
            @Override
91
         public void handleEvent(Event e) {
92
                Button b = (Button) e.widget;
93
                GridData data = (GridData)  btnIncludeAcceptedTaxa.getLayoutData();
94
                data.exclude = b.getSelection();
95

    
96
                btnIncludeSharedTaxa.setVisible(data.exclude);
97
                if (!btnIncludeSynonyms.getSelection() && !data.exclude){
98
                   setPageComplete(false);
99
                }else{
100
                   setPageComplete(true);
101
                }
102
            }
103
        });
104

    
105

    
106
        btnIncludeSharedTaxa = new Button(control, SWT.CHECK);
107
        GridData gd_btnIncludeSharedTaxa = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
108
        gd_btnIncludeSharedTaxa.horizontalIndent = 10;
109
        btnIncludeSharedTaxa.setLayoutData(gd_btnIncludeSharedTaxa);
110
        btnIncludeSharedTaxa.setText(Messages.SetPublishConfiguration_IncludeSharedtaxa);
111
        btnIncludeSharedTaxa.setSelection(configurator.isIncludeSharedTaxa());
112

    
113
        btnIncludeSynonyms = new Button(control, SWT.CHECK);
114
        btnIncludeSynonyms.setText(Messages.SetPublishConfiguration_IncludeSynonyms);
115
        btnIncludeSynonyms.setSelection(configurator.isIncludeSynonyms());
116
        btnIncludeSynonyms.addListener(SWT.Selection, new Listener() {
117
            @Override
118
         public void handleEvent(Event e) {
119
                Button b = (Button) e.widget;
120
                GridData data = (GridData)  btnIncludeSynonyms.getLayoutData();
121
                data.exclude = b.getSelection();
122

    
123
                if (!btnIncludeAcceptedTaxa.getSelection() && !data.exclude){
124
                   setPageComplete(false);
125
                }else{
126
                   setPageComplete(true);
127
                }
128

    
129
            }
130
        });
131

    
132

    
133
        m_bindingContext = initDataBindings();
134
        setControl(composite);
135
    }
136

    
137
    /* (non-Javadoc)
138
     * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
139
     */
140
    @Override
141
    public void handleEvent(Event event) {
142
        // TODO Auto-generated method stub
143

    
144
    }
145

    
146
    protected DataBindingContext initDataBindings() {
147
        DataBindingContext bindingContext = new DataBindingContext();
148

    
149
        IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
150
        IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
151
        bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue, null, null);
152

    
153
        IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
154
        IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
155
        bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue, null, null);
156

    
157

    
158
        IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
159
        IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
160
        bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue, null, null);
161

    
162
        IObservableValue observeSelectionBtnPublish = WidgetProperties.selection().observe(btnPublish);
163
        IObservableValue publishConfiguratorObserveValue = PojoProperties.value("publish").observe(configurator);
164
        bindingContext.bindValue(observeSelectionBtnPublish, publishConfiguratorObserveValue, null, null);
165
        return bindingContext;
166

    
167
    }
168
}
(2-2/5)