Project

General

Profile

Download (12.3 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.Listener;
28

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

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

    
40
    private DataBindingContext m_bindingContext;
41

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

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

    
52
    private Combo btnPublish;
53

    
54

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

    
62
        this.setDescription(Messages.SetPublishConfiguration_Description_Configurator);
63

    
64
    }
65

    
66

    
67

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

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

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

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

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

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

    
98

    
99
      //  Composite control = toolkit.createComposite(composite);
100
        btnIncludeAcceptedTaxa = new Button(control, SWT.CHECK);
101
        btnIncludeAcceptedTaxa.setText(Messages.SetPublishConfiguration_IncludeAcceptedTaxa);
102
//        btnIncludeAcceptedTaxa.setSelection(configurator.isIncludeAcceptedTaxa());
103
//        btnIncludeAcceptedTaxa.addListener(SWT.Selection, new Listener() {
104
//            @Override
105
//         public void handleEvent(Event e) {
106
//                Button b = (Button) e.widget;
107
//                GridData data = (GridData)  btnIncludeAcceptedTaxa.getLayoutData();
108
//                data.exclude = b.getSelection();
109
//
110
//                btnIncludeSharedTaxa.setVisible(data.exclude);
111
//                if (!btnIncludeSynonyms.getSelection() && !data.exclude && !btnIncludeHybrids.getSelection() && !btnIncludeMisappliedNames.getSelection() && !btnIncludeProParteSynonyms.getSelection()){
112
//                   setPageComplete(false);
113
//                }else{
114
//                   setPageComplete(true);
115
//                }
116
//            }
117
//        });
118

    
119

    
120
        btnIncludeSharedTaxa = new Button(control, SWT.CHECK);
121
        GridData gd_btnIncludeSharedTaxa = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
122
        gd_btnIncludeSharedTaxa.horizontalIndent = 10;
123
        btnIncludeSharedTaxa.setLayoutData(gd_btnIncludeSharedTaxa);
124
        btnIncludeSharedTaxa.setText(Messages.SetPublishConfiguration_IncludeSharedtaxa);
125
        btnIncludeSharedTaxa.setSelection(configurator.isIncludeSharedTaxa());
126

    
127
        btnIncludeMisappliedNames = new Button(control, SWT.CHECK);
128
        btnIncludeMisappliedNames.setText(Messages.SetPublishConfiguration_IncludeMisappliedNames);
129
//        btnIncludeMisappliedNames.setSelection(configurator.isIncludeMisapplications());
130
//        btnIncludeMisappliedNames.addListener(SWT.Selection, new Listener() {
131
//            @Override
132
//         public void handleEvent(Event e) {
133
//                Button b = (Button) e.widget;
134
//                GridData data = (GridData)  btnIncludeMisappliedNames.getLayoutData();
135
//                data.exclude = b.getSelection();
136
//
137
//                if (!btnIncludeSynonyms.getSelection() && !data.exclude && !btnIncludeAcceptedTaxa.getSelection() && !btnIncludeProParteSynonyms.getSelection() && !btnIncludeHybrids.getSelection()){
138
//                   setPageComplete(false);
139
//                }else{
140
//                   setPageComplete(true);
141
//                }
142
//            }
143
//        });
144

    
145

    
146
        btnIncludeProParteSynonyms = new Button(control, SWT.CHECK);
147
        btnIncludeProParteSynonyms.setText(Messages.SetPublishConfiguration_IncludeProParteSynonyms);
148
//        btnIncludeProParteSynonyms.setSelection(configurator.isIncludeProParteSynonyms());
149
//        btnIncludeProParteSynonyms.addListener(SWT.Selection, new Listener() {
150
//            @Override
151
//         public void handleEvent(Event e) {
152
//                Button b = (Button) e.widget;
153
//                GridData data = (GridData)  btnIncludeProParteSynonyms.getLayoutData();
154
//                data.exclude = b.getSelection();
155
//
156
//                if (!btnIncludeSynonyms.getSelection() && !data.exclude && !btnIncludeAcceptedTaxa.getSelection() && !btnIncludeMisappliedNames.getSelection() && !btnIncludeHybrids.getSelection()){
157
//                   setPageComplete(false);
158
//                }else{
159
//                   setPageComplete(true);
160
//                }
161
//            }
162
//        });
163

    
164
        btnIncludeHybrids = new Button(control, SWT.CHECK);
165
        btnIncludeHybrids.setText(Messages.SetPublishConfiguration_IncludeHybrids);
166
//        btnIncludeHybrids.setSelection(configurator.isIncludeHybrids());
167
//        btnIncludeHybrids.addListener(SWT.Selection, new Listener() {
168
//            @Override
169
//         public void handleEvent(Event e) {
170
//                Button b = (Button) e.widget;
171
//                GridData data = (GridData)  btnIncludeHybrids.getLayoutData();
172
//                data.exclude = b.getSelection();
173
//
174
//                if (!btnIncludeSynonyms.getSelection() && !data.exclude && !btnIncludeAcceptedTaxa.getSelection() && !btnIncludeMisappliedNames.getSelection() && !btnIncludeProParteSynonyms.getSelection()){
175
//                   setPageComplete(false);
176
//                }else{
177
//                   setPageComplete(true);
178
//                }
179
//            }
180
//        });
181

    
182
        btnIncludeSynonyms = new Button(control, SWT.CHECK);
183
        btnIncludeSynonyms.setText(Messages.SetPublishConfiguration_IncludeSynonyms);
184
//        btnIncludeSynonyms.setSelection(configurator.isIncludeSynonyms());
185
//        btnIncludeSynonyms.addListener(SWT.Selection, new Listener() {
186
//            @Override
187
//         public void handleEvent(Event e) {
188
//                Button b = (Button) e.widget;
189
//                GridData data = (GridData)  btnIncludeSynonyms.getLayoutData();
190
//                data.exclude = b.getSelection();
191
//
192
//                if (!btnIncludeAcceptedTaxa.getSelection() && !data.exclude && !btnIncludeHybrids.getSelection() && !btnIncludeMisappliedNames.getSelection() && !btnIncludeProParteSynonyms.getSelection()){
193
//                   setPageComplete(false);
194
//                }else{
195
//                   setPageComplete(true);
196
//                }
197
//
198
//            }
199
//        });
200

    
201

    
202
        m_bindingContext = initDataBindings();
203

    
204
        setControl(composite);
205
    }
206

    
207
    /* (non-Javadoc)
208
     * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
209
     */
210
    @Override
211
    public void handleEvent(Event event) {
212
        // TODO Auto-generated method stub
213

    
214
    }
215

    
216
    protected DataBindingContext initDataBindings() {
217
        DataBindingContext bindingContext = new DataBindingContext();
218

    
219
        IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
220
        IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
221
        bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue);
222

    
223
        IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
224
        IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
225
        bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue);
226

    
227
        IObservableValue observeSelectionBtnIncludeMisappliedNames = WidgetProperties.selection().observe(btnIncludeMisappliedNames);
228
        IObservableValue includeMisappliedNamesConfiguratorObserveValue = PojoProperties.value("includeMisapplications").observe(configurator);
229
        bindingContext.bindValue(observeSelectionBtnIncludeMisappliedNames, includeMisappliedNamesConfiguratorObserveValue);
230

    
231
        IObservableValue observeSelectionBtnIncludeProParteSynonyms = WidgetProperties.selection().observe(btnIncludeProParteSynonyms);
232
        IObservableValue includeProParteSynonymsConfiguratorObserveValue = PojoProperties.value("includeProParteSynonyms").observe(configurator);
233
        bindingContext.bindValue(observeSelectionBtnIncludeProParteSynonyms, includeProParteSynonymsConfiguratorObserveValue);
234

    
235
        IObservableValue observeSelectionBtnIncludeHybrids = WidgetProperties.selection().observe(btnIncludeHybrids);
236
        IObservableValue includeHybridsConfiguratorObserveValue = PojoProperties.value("includeHybrids").observe(configurator);
237
        bindingContext.bindValue(observeSelectionBtnIncludeHybrids, includeHybridsConfiguratorObserveValue);
238

    
239
        IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
240
        IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
241
        bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue);
242

    
243

    
244

    
245
//        IObservableValue observeSelectionBtnPublish = WidgetProperties.selection().observe(btnPublish);
246
//        IObservableValue publishConfiguratorObserveValue = PojoProperties.value("publish").observe(configurator);
247
//        bindingContext.bindValue(observeSelectionBtnPublish, publishConfiguratorObserveValue, null, null);
248
        return bindingContext;
249

    
250
    }
251

    
252
    public void updateContext(){
253
        m_bindingContext.updateTargets();
254
    }
255

    
256

    
257

    
258
    /* (non-Javadoc)
259
     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
260
     */
261
    @Override
262
    public void widgetSelected(SelectionEvent e) {
263
        if (btnPublish.getSelectionIndex() > 0){
264
            configurator.setPublish(false);
265
        } else{
266
            configurator.setPublish(true);
267
        }
268

    
269
    }
270

    
271

    
272

    
273
    /* (non-Javadoc)
274
     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
275
     */
276
    @Override
277
    public void widgetDefaultSelected(SelectionEvent e) {
278
        // TODO Auto-generated method stub
279

    
280
    }
281
}
(2-2/5)