Project

General

Profile

Download (8.57 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.events.SelectionEvent;
19
import org.eclipse.swt.events.SelectionListener;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Combo;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Display;
26
import org.eclipse.swt.widgets.Event;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Listener;
29

    
30
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
31
import eu.etaxonomy.taxeditor.l10n.Messages;
32
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
33

    
34
/**
35
 * @author k.luther
36
 * @date 10.10.2017
37
 *
38
 */
39
public class PublishSubTreeConfiguratorWizardPage extends WizardPage implements Listener, SelectionListener {
40

    
41
    private DataBindingContext m_bindingContext;
42

    
43
    private final static CdmFormFactory toolkit = new CdmFormFactory(Display.getCurrent());
44
    private final PublishForSubtreeConfigurator configurator;
45

    
46
    private Button btnIncludeAcceptedTaxa;
47
    private Button btnIncludeSynonyms;
48
    private Button btnIncludeSharedTaxa;
49
    private Button btnIncludeMisappliedNames;
50
    private Button btnIncludeProParteSynonyms;
51
    private Button btnIncludeHybrids;
52

    
53
    private Combo btnPublish;
54

    
55

    
56
    /**
57
     * @param string
58
     */
59
    public PublishSubTreeConfiguratorWizardPage(PublishForSubtreeConfigurator configurator) {
60
        super("Set Publish Flag Configuration");
61
        this.configurator = configurator;
62

    
63
        this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
64

    
65
    }
66

    
67

    
68

    
69
    /* (non-Javadoc)
70
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
71
     */
72
    @Override
73
    public void createControl(Composite parent) {
74

    
75
        final Composite composite = new Composite(parent, SWT.NULL);
76

    
77
        GridLayout gridLayout = new GridLayout();
78
        gridLayout.numColumns = 1;
79

    
80
        composite.setLayout(gridLayout);
81
        final Composite control = new Composite(composite, SWT.NULL);
82
        GridLayout gridLayoutControl = new GridLayout();
83

    
84
        control.setLayout(gridLayoutControl);
85
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
86

    
87
        btnPublish = new Combo(control, SWT.BORDER| SWT.READ_ONLY);
88
        btnPublish.setText(Messages.SetPublishConfiguration_Publish);
89
        btnPublish.setToolTipText(Messages.SetPublishConfiguration_Publish_tooltip);
90
        btnPublish.add(Messages.SetPublishConfiguration_publish, 0);
91
        btnPublish.add(Messages.SetPublishConfiguration_dont_publish,1);
92
        if (configurator.isPublish()){
93
            btnPublish.select(0);
94
        }else{
95
            btnPublish.select(1);
96
        }
97
        btnPublish.addSelectionListener(this);
98

    
99
        btnIncludeAcceptedTaxa = new Button(control, SWT.CHECK);
100
        btnIncludeAcceptedTaxa.setText(Messages.SetPublishConfiguration_IncludeAcceptedTaxa);
101
        btnIncludeAcceptedTaxa.addSelectionListener(this);
102

    
103
        btnIncludeMisappliedNames = new Button(control, SWT.CHECK);
104
        btnIncludeMisappliedNames.setText(Messages.SetPublishConfiguration_IncludeMisappliedNames);
105
        btnIncludeMisappliedNames.addSelectionListener(this);
106

    
107
        btnIncludeProParteSynonyms = new Button(control, SWT.CHECK);
108
        btnIncludeProParteSynonyms.setText(Messages.SetPublishConfiguration_IncludeProParteSynonyms);
109
        btnIncludeProParteSynonyms.addSelectionListener(this);
110

    
111
        btnIncludeHybrids = new Button(control, SWT.CHECK);
112
        btnIncludeHybrids.setText(Messages.SetPublishConfiguration_IncludeHybrids);
113
        btnIncludeHybrids.addSelectionListener(this);
114

    
115
        btnIncludeSynonyms = new Button(control, SWT.CHECK);
116
        btnIncludeSynonyms.setText(Messages.SetPublishConfiguration_IncludeSynonyms);
117

    
118
        Label space = new Label(control, SWT.NONE);
119

    
120
        btnIncludeSharedTaxa = new Button(control, SWT.CHECK);
121
        btnIncludeSharedTaxa.setText(Messages.SetPublishConfiguration_IncludeSharedtaxa);
122

    
123
        m_bindingContext = initDataBindings();
124

    
125
        setControl(composite);
126
    }
127

    
128
    /* (non-Javadoc)
129
     * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
130
     */
131
    @Override
132
    public void handleEvent(Event event) {
133
        // TODO Auto-generated method stub
134

    
135
    }
136

    
137
    protected DataBindingContext initDataBindings() {
138
        DataBindingContext bindingContext = new DataBindingContext();
139

    
140
        IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
141
        IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
142
        bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue);
143

    
144
        IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
145
        IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
146
        bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue);
147

    
148
        IObservableValue observeSelectionBtnIncludeMisappliedNames = WidgetProperties.selection().observe(btnIncludeMisappliedNames);
149
        IObservableValue includeMisappliedNamesConfiguratorObserveValue = PojoProperties.value("includeMisapplications").observe(configurator);
150
        bindingContext.bindValue(observeSelectionBtnIncludeMisappliedNames, includeMisappliedNamesConfiguratorObserveValue);
151

    
152
        IObservableValue observeSelectionBtnIncludeProParteSynonyms = WidgetProperties.selection().observe(btnIncludeProParteSynonyms);
153
        IObservableValue includeProParteSynonymsConfiguratorObserveValue = PojoProperties.value("includeProParteSynonyms").observe(configurator);
154
        bindingContext.bindValue(observeSelectionBtnIncludeProParteSynonyms, includeProParteSynonymsConfiguratorObserveValue);
155

    
156
        IObservableValue observeSelectionBtnIncludeHybrids = WidgetProperties.selection().observe(btnIncludeHybrids);
157
        IObservableValue includeHybridsConfiguratorObserveValue = PojoProperties.value("includeHybrids").observe(configurator);
158
        bindingContext.bindValue(observeSelectionBtnIncludeHybrids, includeHybridsConfiguratorObserveValue);
159

    
160
        IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
161
        IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
162
        bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue);
163

    
164

    
165

    
166
//        IObservableValue observeSelectionBtnPublish = WidgetProperties.selection().observe(btnPublish);
167
//        IObservableValue publishConfiguratorObserveValue = PojoProperties.value("publish").observe(configurator);
168
//        bindingContext.bindValue(observeSelectionBtnPublish, publishConfiguratorObserveValue, null, null);
169
        return bindingContext;
170

    
171
    }
172

    
173
    public void updateContext(){
174
        m_bindingContext.updateTargets();
175
    }
176

    
177

    
178

    
179
    /* (non-Javadoc)
180
     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
181
     */
182
    @Override
183
    public void widgetSelected(SelectionEvent e) {
184
        if (btnPublish.getSelectionIndex() > 0){
185
            configurator.setPublish(false);
186
        } else{
187
            configurator.setPublish(true);
188
        }
189
        if (!btnIncludeMisappliedNames.getSelection() && !btnIncludeAcceptedTaxa.getSelection() && !btnIncludeProParteSynonyms.getSelection() ){
190
            btnIncludeSharedTaxa.setEnabled(false);
191
        }else{
192
            btnIncludeSharedTaxa.setEnabled(true);
193

    
194
        }
195
    }
196

    
197

    
198

    
199
    /* (non-Javadoc)
200
     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
201
     */
202
    @Override
203
    public void widgetDefaultSelected(SelectionEvent e) {
204
        // TODO Auto-generated method stub
205

    
206
    }
207
}
(2-2/5)