Project

General

Profile

Revision d898479a

IDd898479a7e96e9b83ca7042327ab076846fe143c
Parent 61b8e368
Child 5065f99f

Added by Katja Luther over 4 years ago

fix #6315: adapt the setSecundum for subtree functionality in editor

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/SetSecReferenceForSubtreeHandler.java
18 18
import org.eclipse.core.runtime.IStatus;
19 19
import org.eclipse.core.runtime.Status;
20 20
import org.eclipse.jface.viewers.TreeSelection;
21
import org.eclipse.jface.window.Window;
22
import org.eclipse.jface.wizard.WizardDialog;
21 23
import org.eclipse.ui.handlers.HandlerUtil;
22 24

  
23 25
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
24 26
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
25 27
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
26
import eu.etaxonomy.taxeditor.editor.Messages;
27 28
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
28 29
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
29 30
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
30
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationDialog;
31
import eu.etaxonomy.taxeditor.store.StoreUtil;
32
import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
31 33

  
32 34
/**
33 35
 * @author k.luther
......
85 87
           }
86 88

  
87 89
           configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
88
           if(!SetSecundumForSubtreeConfigurationDialog.openConfirmWithConfigurator(configurator, HandlerUtil.getActiveShell(event), Messages.SetSecundumHandler_confirm, Messages.SetSecundumHandler_configureSettings)){
90
           SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
89 91

  
92
           WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
93

  
94
           if (dialog.open() == Window.OK) {
95
              return Status.OK_STATUS;
96
           }else{
90 97
               return Status.CANCEL_STATUS;
91 98
           }
92 99

  
93

  
94
           return Status.OK_STATUS;
100
//           if(!SetSecundumForSubtreeConfigurationWizard.openConfirmWithConfigurator(configurator)){
101
//
102
//               return Status.CANCEL_STATUS;
103
//           }
104
//
105
//
106
//           return Status.OK_STATUS;
95 107
       }
96 108
       /* (non-Javadoc)
97 109
        * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#doOperations(org.eclipse.core.commands.ExecutionEvent)
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
150 150
SetSecundumConfiguration_OverwriteExistingSynonyms=overwrite existing references for synonyms
151 151
SetSecundumConfiguration_EmptySecundumDetail=empty existing details
152 152
SetSecundumConfiguration_IncludeSharedtaxa=include shared taxa
153
SetSecundumConfiguration_NewSecundum_Label=new secundum reference
153 154

  
154 155
DatabasePreferncesPage_Is_redList=Red List 2020
155 156
DatabasePreferncesPage_Determination_only_for_field_unnits=Determinations only for field units
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
142 142

  
143 143
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
144 144

  
145
SetSecundumConfiguration_IncludeAcceptedTaxa=anwenden auf akzeptierten Taxa
145
SetSecundumConfiguration_IncludeAcceptedTaxa=anwenden auf akzeptierte Taxa
146 146
SetSecundumConfiguration_IncludeSynonyms=anwenden auf Synonyme
147 147
SetSecundumConfiguration_OverwriteExistingAccepted=bestehende Secundum Referenzen bei akzeptierten Taxa ?berschreiben
148 148
SetSecundumConfiguration_OverwriteExistingSynonyms=bestehende Secundum Referenzen bei Synonymen ?berschreiben
149 149
SetSecundumConfiguration_EmptySecundumDetail=bestehende Details von Secundum Referenzen l?schen
150
SetSecundumConfiguration_IncludeSharedtaxa=auch geteilte Taxa mit einbeziehen
150
SetSecundumConfiguration_IncludeSharedtaxa=auch mehrfach verwendete Taxa mit einbeziehen
151
SetSecundumConfiguration_NewSecundum_Label=neue Secundum Referenz
151 152

  
152 153
DatabasePreferncesPage_Is_redList=Rote Liste 2020
153 154
DatabasePreferncesPage_Determination_only_for_field_unnits=Determinations nur f?r Field Units
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
157 157
    public static String SetSecundumConfiguration_OverwriteExistingSynonyms;
158 158
    public static String SetSecundumConfiguration_EmptySecundumDetail;
159 159
    public static String SetSecundumConfiguration_IncludeSharedtaxa;
160

  
160
    public static String SetSecundumConfiguration_NewSecundum_Label;
161 161

  
162 162
    public static String DatabasePreferncesPage_Is_redList;
163 163
    public static String DatabasePreferncesPage_Determination_only_for_field_unnits;
164 164
    public static String DatabasePreferncesPage_Show_Collecting_Areas_in_general_section;
165 165
    public static String DatabasePreferncesPage_Taxon_Associations;
166 166

  
167

  
167 168
    static {
168 169
        // initialize resource bundle
169 170
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/SetSecundumConfiguratorComposite.java
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.ui.dialog.configurator;
10

  
11
import org.eclipse.core.databinding.DataBindingContext;
12
import org.eclipse.core.databinding.beans.PojoProperties;
13
import org.eclipse.core.databinding.observable.value.IObservableValue;
14
import org.eclipse.jface.databinding.swt.WidgetProperties;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.DisposeEvent;
17
import org.eclipse.swt.events.DisposeListener;
18
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.Button;
20
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Display;
22
import org.eclipse.ui.forms.widgets.FormToolkit;
23

  
24
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
25
import eu.etaxonomy.taxeditor.Messages;
26
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
27

  
28
/**
29
 * @author k.luther
30
 * @date 10.02.2017
31
 *
32
 */
33
public class SetSecundumConfiguratorComposite extends Composite {
34
    private final DataBindingContext m_bindingContext;
35

  
36
    private final FormToolkit toolkit = new CdmFormFactory(Display.getCurrent());
37
    private final SetSecundumForSubtreeConfigurator configurator;
38

  
39

  
40
    private final Button btnIncludeAcceptedTaxa;
41
    private final Button btnIncludeSynonyms;
42
    private final Button btnOverwriteExistingAccepted;
43
    private final Button btnOverwriteExistingSynonyms;
44
    private final Button btnEmptySecundumDetail;
45
    private final Button btnIncludeSharedTaxa;
46

  
47

  
48
    /**
49
     * Create the composite.
50
     * @param parent
51
     * @param style
52
     */
53
    public SetSecundumConfiguratorComposite(SetSecundumForSubtreeConfigurator configurator, Composite parent, int style ) {
54
        super(parent, style);
55
        this.configurator = configurator;
56

  
57
        addDisposeListener(new DisposeListener() {
58
            @Override
59
            public void widgetDisposed(DisposeEvent e) {
60
                toolkit.dispose();
61
            }
62
        });
63
        toolkit.paintBordersFor(this);
64
        setLayout(new GridLayout());
65
        setBackground(getBackground());
66

  
67

  
68
        btnIncludeAcceptedTaxa = new Button(this, SWT.CHECK);
69
        btnIncludeAcceptedTaxa.setText(Messages.SetSecundumConfiguration_IncludeAcceptedTaxa);
70
        btnIncludeAcceptedTaxa.setSelection(configurator.isIncludeAcceptedTaxa());
71

  
72
        btnIncludeSynonyms = new Button(this, SWT.CHECK);
73
        btnIncludeSynonyms.setText(Messages.SetSecundumConfiguration_IncludeSynonyms);
74
        btnIncludeSynonyms.setSelection(configurator.isIncludeSynonyms());
75
        btnOverwriteExistingAccepted = new Button(this, SWT.CHECK);
76
        btnOverwriteExistingAccepted.setText(Messages.SetSecundumConfiguration_OverwriteExistingAccepted);
77
        btnOverwriteExistingAccepted.setSelection(configurator.isOverwriteExistingAccepted());
78
        btnOverwriteExistingSynonyms = new Button(this, SWT.CHECK);
79
        btnOverwriteExistingSynonyms.setText(Messages.SetSecundumConfiguration_OverwriteExistingSynonyms);
80
        btnOverwriteExistingSynonyms.setSelection(configurator.isOverwriteExistingSynonyms());
81
        btnEmptySecundumDetail = new Button(this, SWT.CHECK);
82
        btnEmptySecundumDetail.setText(Messages.SetSecundumConfiguration_EmptySecundumDetail);
83
        btnEmptySecundumDetail.setSelection(configurator.isEmptySecundumDetail());
84

  
85
        btnIncludeSharedTaxa = new Button(this, SWT.CHECK);
86
        btnIncludeSharedTaxa.setText(Messages.SetSecundumConfiguration_IncludeSharedtaxa);
87
        btnIncludeSharedTaxa.setSelection(configurator.isIncludeSharedTaxa());
88

  
89
        m_bindingContext = initDataBindings();
90

  
91
    }
92

  
93
    /**
94
     * @return
95
     */
96
    private DataBindingContext initDataBindings() {
97
        DataBindingContext bindingContext = new DataBindingContext();
98
        //
99

  
100
//        private final Button btnIncludeAcceptedTaxa;
101
//        private final Button btnIncludeSynonyms;
102
//        private final Button btnOverwriteExistingAccepted;
103
//        private final Button btnOverwriteExistingSynonyms;
104
//        private final Button btnEmptySecundumDetail;
105
//        private final Button btnIncludeSharedTaxa;
106

  
107
        IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
108
        IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
109
        bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue, null, null);
110

  
111
        IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
112
        IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
113
        bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue, null, null);
114

  
115
        IObservableValue observeSelectionBtnOverwriteExistingAccepted = WidgetProperties.selection().observe(btnOverwriteExistingAccepted);
116
        IObservableValue overwriteExistingAcceptedConfiguratorObserveValue = PojoProperties.value("overwriteExistingAccepted").observe(configurator);
117
        bindingContext.bindValue(observeSelectionBtnOverwriteExistingAccepted, overwriteExistingAcceptedConfiguratorObserveValue, null, null);
118

  
119
        IObservableValue observeSelectionBtnOverwriteExistingSynonyms = WidgetProperties.selection().observe(btnOverwriteExistingSynonyms);
120
        IObservableValue overwriteExistingSynonymsConfiguratorObserveValue = PojoProperties.value("overwriteExistingSynonyms").observe(configurator);
121
        bindingContext.bindValue(observeSelectionBtnOverwriteExistingSynonyms, overwriteExistingSynonymsConfiguratorObserveValue, null, null);
122

  
123
        IObservableValue observeSelectionBtnEmptySecundumDetail = WidgetProperties.selection().observe(btnEmptySecundumDetail);
124
        IObservableValue emptySecundumDetailConfiguratorObserveValue = PojoProperties.value("emptySecundumDetail").observe(configurator);
125
        bindingContext.bindValue(observeSelectionBtnEmptySecundumDetail, emptySecundumDetailConfiguratorObserveValue, null, null);
126

  
127
        IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
128
        IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
129
        bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue, null, null);
130
        return bindingContext;
131
    }
132

  
133

  
134

  
135

  
136
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/SetSecundumConfiguratorWizardPage.java
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.ui.dialog.configurator;
10

  
11
import org.eclipse.core.databinding.DataBindingContext;
12
import org.eclipse.core.databinding.beans.PojoProperties;
13
import org.eclipse.core.databinding.observable.value.IObservableValue;
14
import org.eclipse.jface.databinding.swt.WidgetProperties;
15
import org.eclipse.jface.wizard.Wizard;
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.Label;
25
import org.eclipse.swt.widgets.Listener;
26
import org.eclipse.swt.widgets.Text;
27
import org.eclipse.ui.forms.widgets.FormToolkit;
28
import org.eclipse.wb.swt.ResourceManager;
29

  
30
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
31
import eu.etaxonomy.cdm.model.reference.Reference;
32
import eu.etaxonomy.taxeditor.Messages;
33
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
34
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
35

  
36
/**
37
 * @author k.luther
38
 * @date 10.02.2017
39
 *
40
 */
41
public class SetSecundumConfiguratorWizardPage extends WizardPage implements Listener{
42
    private DataBindingContext m_bindingContext;
43

  
44
    private final FormToolkit toolkit = new CdmFormFactory(Display.getCurrent());
45
    private final SetSecundumForSubtreeConfigurator configurator;
46

  
47
    private  Button btnBrowseReference = null;
48
    private  Text textReference = null;
49
    private  Button btnClear = null;
50

  
51
    private  Button btnIncludeAcceptedTaxa;
52
    private Button btnIncludeSynonyms;
53
    private Button btnOverwriteExistingAccepted;
54
    private Button btnOverwriteExistingSynonyms;
55
    private Button btnEmptySecundumDetail;
56
    private Button btnIncludeSharedTaxa;
57

  
58

  
59
    /**
60
     * Create the composite.
61
     * @param parent
62
     * @param style
63
     */
64
    public SetSecundumConfiguratorWizardPage(SetSecundumForSubtreeConfigurator configurator, Wizard parent, int style ) {
65
        super("Set Secundum Reference Configuration");
66
        this.configurator = configurator;
67

  
68
//        addDisposeListener(new DisposeListener() {
69
//            @Override
70
//            public void widgetDisposed(DisposeEvent e) {
71
//                toolkit.dispose();
72
//            }
73
//        });
74
      //  toolkit.paintBordersFor(this);
75
//        setLayout(new GridLayout());
76
//        setBackground(getBackground());
77

  
78

  
79

  
80

  
81
    }
82

  
83
    /**
84
     * @return
85
     */
86
    private DataBindingContext initDataBindings() {
87
        DataBindingContext bindingContext = new DataBindingContext();
88

  
89
        IObservableValue observeSelectionBtnIncludeAcceptedTaxa = WidgetProperties.selection().observe(btnIncludeAcceptedTaxa);
90
        IObservableValue includeAcceptedTaxaConfiguratorObserveValue = PojoProperties.value("includeAcceptedTaxa").observe(configurator);
91
        bindingContext.bindValue(observeSelectionBtnIncludeAcceptedTaxa, includeAcceptedTaxaConfiguratorObserveValue, null, null);
92

  
93
        IObservableValue observeSelectionBtnIncludeSynonyms = WidgetProperties.selection().observe(btnIncludeSynonyms);
94
        IObservableValue includeSynonymsConfiguratorObserveValue = PojoProperties.value("includeSynonyms").observe(configurator);
95
        bindingContext.bindValue(observeSelectionBtnIncludeSynonyms, includeSynonymsConfiguratorObserveValue, null, null);
96

  
97
        IObservableValue observeSelectionBtnOverwriteExistingAccepted = WidgetProperties.selection().observe(btnOverwriteExistingAccepted);
98
        IObservableValue overwriteExistingAcceptedConfiguratorObserveValue = PojoProperties.value("overwriteExistingAccepted").observe(configurator);
99
        bindingContext.bindValue(observeSelectionBtnOverwriteExistingAccepted, overwriteExistingAcceptedConfiguratorObserveValue, null, null);
100

  
101
        IObservableValue observeSelectionBtnOverwriteExistingSynonyms = WidgetProperties.selection().observe(btnOverwriteExistingSynonyms);
102
        IObservableValue overwriteExistingSynonymsConfiguratorObserveValue = PojoProperties.value("overwriteExistingSynonyms").observe(configurator);
103
        bindingContext.bindValue(observeSelectionBtnOverwriteExistingSynonyms, overwriteExistingSynonymsConfiguratorObserveValue, null, null);
104

  
105
        IObservableValue observeSelectionBtnEmptySecundumDetail = WidgetProperties.selection().observe(btnEmptySecundumDetail);
106
        IObservableValue emptySecundumDetailConfiguratorObserveValue = PojoProperties.value("emptySecundumDetail").observe(configurator);
107
        bindingContext.bindValue(observeSelectionBtnEmptySecundumDetail, emptySecundumDetailConfiguratorObserveValue, null, null);
108

  
109
        IObservableValue observeSelectionBtnIncludeSharedTaxal = WidgetProperties.selection().observe(btnIncludeSharedTaxa);
110
        IObservableValue includeSharedTaxaConfiguratorObserveValue = PojoProperties.value("includeSharedTaxa").observe(configurator);
111
        bindingContext.bindValue(observeSelectionBtnIncludeSharedTaxal, includeSharedTaxaConfiguratorObserveValue, null, null);
112
        return bindingContext;
113
    }
114

  
115
    @Override
116
    public void createControl(Composite parent) {
117

  
118
        final Composite composite = new Composite(parent, SWT.NULL);
119

  
120
        GridLayout gridLayout = new GridLayout();
121
        gridLayout.numColumns = 1;
122

  
123
        composite.setLayout(gridLayout);
124
        final Composite compositeRef = new Composite(composite, SWT.NULL);
125

  
126
        GridLayout gridLayoutRef = new GridLayout();
127
        gridLayoutRef.numColumns = 4;
128

  
129
        compositeRef.setLayout(gridLayoutRef);
130
        compositeRef.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
131
        Label label = new Label(compositeRef, SWT.NONE);
132
        label.setText(Messages.SetSecundumConfiguration_NewSecundum_Label);
133
        //label.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
134

  
135
        textReference = new Text(compositeRef, SWT.BORDER);
136
        textReference.setEditable(false);
137
        textReference.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
138
        textReference.setTextLimit(Text.LIMIT);
139

  
140
        btnBrowseReference = new Button(compositeRef, SWT.NONE);
141
        btnBrowseReference.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
142
        btnBrowseReference.addListener(SWT.Selection, this);
143
        btnClear = new Button(compositeRef, SWT.NONE);
144
        btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
145
        btnClear.addListener(SWT.Selection, this);
146

  
147
        final Composite control = new Composite(composite, SWT.NULL);
148
        GridLayout gridLayoutControl = new GridLayout();
149
        gridLayoutControl.numColumns = 1;
150

  
151
        control.setLayout(gridLayoutControl);
152
        control.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
153
      //  Composite control = toolkit.createComposite(composite);
154
        btnIncludeAcceptedTaxa = new Button(control, SWT.CHECK);
155
        btnIncludeAcceptedTaxa.setText(Messages.SetSecundumConfiguration_IncludeAcceptedTaxa);
156
        btnIncludeAcceptedTaxa.setSelection(configurator.isIncludeAcceptedTaxa());
157
        btnIncludeAcceptedTaxa.addListener(SWT.Selection, new Listener() {
158
            @Override
159
         public void handleEvent(Event e) {
160
                Button b = (Button) e.widget;
161
                GridData data = (GridData)  btnIncludeAcceptedTaxa.getLayoutData();
162
                data.exclude = b.getSelection();
163
                btnOverwriteExistingAccepted.setVisible(data.exclude);
164
                btnIncludeSharedTaxa.setVisible(data.exclude);
165
                if (!btnIncludeSynonyms.getSelection() && !data.exclude){
166
                    btnEmptySecundumDetail.setVisible(false);
167
                    setPageComplete(false);
168
                }else{
169
                    btnEmptySecundumDetail.setVisible(true);
170
                    setPageComplete(true);
171
                }
172
            }
173
        });
174

  
175
        btnOverwriteExistingAccepted = new Button(control, SWT.CHECK);
176
        btnOverwriteExistingAccepted.setText(Messages.SetSecundumConfiguration_OverwriteExistingAccepted);
177

  
178
        btnIncludeSynonyms = new Button(control, SWT.CHECK);
179
        btnIncludeSynonyms.setText(Messages.SetSecundumConfiguration_IncludeSynonyms);
180
        btnIncludeSynonyms.setSelection(configurator.isIncludeSynonyms());
181
        btnIncludeSynonyms.addListener(SWT.Selection, new Listener() {
182
            @Override
183
         public void handleEvent(Event e) {
184
                Button b = (Button) e.widget;
185
                GridData data = (GridData)  btnIncludeSynonyms.getLayoutData();
186
                data.exclude = b.getSelection();
187
                btnOverwriteExistingSynonyms.setVisible(data.exclude);
188
                if (!btnIncludeAcceptedTaxa.getSelection() && !data.exclude){
189
                    btnEmptySecundumDetail.setVisible(false);
190
                    setPageComplete(false);
191
                }else{
192
                    btnEmptySecundumDetail.setVisible(true);
193
                    setPageComplete(true);
194
                }
195

  
196
            }
197
        });
198

  
199
        btnOverwriteExistingAccepted.setSelection(configurator.isOverwriteExistingAccepted());
200
        btnOverwriteExistingSynonyms = new Button(control, SWT.CHECK);
201
        btnOverwriteExistingSynonyms.setText(Messages.SetSecundumConfiguration_OverwriteExistingSynonyms);
202
        btnOverwriteExistingSynonyms.setSelection(configurator.isOverwriteExistingSynonyms());
203
        btnEmptySecundumDetail = new Button(control, SWT.CHECK);
204
        btnEmptySecundumDetail.setText(Messages.SetSecundumConfiguration_EmptySecundumDetail);
205
        btnEmptySecundumDetail.setSelection(configurator.isEmptySecundumDetail());
206

  
207
        btnIncludeSharedTaxa = new Button(control, SWT.CHECK);
208
        btnIncludeSharedTaxa.setText(Messages.SetSecundumConfiguration_IncludeSharedtaxa);
209
        btnIncludeSharedTaxa.setSelection(configurator.isIncludeSharedTaxa());
210

  
211
        m_bindingContext = initDataBindings();
212
        setControl(composite);
213
    }
214

  
215

  
216

  
217
    @Override
218
    public void handleEvent(Event event) {
219
        Reference reference;
220
        if(event.widget==btnBrowseReference){
221
            reference = SelectionDialogFactory.getSelectionFromDialog(Reference.class, this.getShell(), null, null);
222
            if(reference!=null){
223
                this.configurator.setNewSecundum(reference);
224
                textReference.setText(reference.getTitleCache());
225

  
226
            }
227

  
228
        } else if(event.widget==btnClear){
229
            reference = null;
230
            textReference.setText("");
231
            this.configurator.setNewSecundum(null);
232
        } else{
233
            reference = null;
234
            textReference.setText("");
235
            this.configurator.setNewSecundum(null);
236
        }
237

  
238
    }
239

  
240

  
241

  
242

  
243
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/SetSecundumForSubtreeConfigurationDialog.java
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.ui.dialog.configurator;
10

  
11
import org.eclipse.jface.dialogs.IDialogConstants;
12
import org.eclipse.jface.dialogs.MessageDialog;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Event;
21
import org.eclipse.swt.widgets.Label;
22
import org.eclipse.swt.widgets.Listener;
23
import org.eclipse.swt.widgets.Shell;
24
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.wb.swt.ResourceManager;
26

  
27
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
28
import eu.etaxonomy.cdm.model.reference.Reference;
29
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
30

  
31
/**
32
 * @author k.luther
33
 * @date 10.02.2017
34
 *
35
 */
36
public class SetSecundumForSubtreeConfigurationDialog extends MessageDialog implements Listener{
37

  
38
    Reference newSecRef;
39
    private final SetSecundumForSubtreeConfigurator configurator;
40
    private  Button btnBrowseReference = null;
41
    private  Text textReference = null;
42
    private  Button btnClear = null;
43

  
44

  
45

  
46
    /**
47
     * @param parentShell
48
     * @param dialogTitle
49
     * @param dialogTitleImage
50
     * @param dialogMessage
51
     * @param dialogImageType
52
     * @param dialogButtonLabels
53
     * @param defaultIndex
54
     * @param config
55
     */
56
    public SetSecundumForSubtreeConfigurationDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage,
57
            String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, SetSecundumForSubtreeConfigurator config) {
58
        super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
59
        this.configurator = config;
60

  
61

  
62

  
63
    }
64

  
65
    @Override
66
    protected Control createCustomArea(Composite parent) {
67
        final Composite composite = new Composite(parent, SWT.NULL);
68

  
69
        GridLayout gridLayout = new GridLayout();
70
        gridLayout.numColumns = 1;
71
        composite.setLayout(gridLayout);
72
        final Composite compositeRef = new Composite(composite, SWT.NULL);
73

  
74
        GridLayout gridLayoutRef = new GridLayout();
75
        gridLayoutRef.numColumns = 4;
76

  
77
        compositeRef.setLayout(gridLayoutRef);
78
        compositeRef.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, true));
79
        Label label = new Label(compositeRef, SWT.NONE);
80
        label.setText("New secundum reference");
81
        //label.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
82

  
83
        textReference = new Text(compositeRef, SWT.BORDER);
84
        textReference.setEditable(false);
85
        textReference.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
86
        textReference.setTextLimit(Text.LIMIT);
87

  
88
        btnBrowseReference = new Button(compositeRef, SWT.NONE);
89
        btnBrowseReference.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/open.gif"));
90
        btnBrowseReference.addListener(SWT.Selection, this);
91
        btnClear = new Button(compositeRef, SWT.NONE);
92
        btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
93
        btnClear.addListener(SWT.Selection, this);
94
        ConfiguratorComposite compositeConfigure = new ConfiguratorComposite(composite, NONE);
95

  
96
        compositeConfigure.addConfiguratorComposite(new SetSecundumConfiguratorComposite(configurator, compositeConfigure.getSectionConfigure(), SWT.NONE));
97
        return composite;
98

  
99
    }
100

  
101
    /**
102
     * @param configurator
103
     * @param activeShell
104
     * @param setSecundumHandler_confirm
105
     * @param setSecundumHandler_configureSettings
106
     * @return
107
     */
108
    public static boolean openConfirmWithConfigurator(SetSecundumForSubtreeConfigurator configurator, Shell parent, String title, String message) {
109

  
110
        SetSecundumForSubtreeConfigurationDialog dialog = new SetSecundumForSubtreeConfigurationDialog(parent, title, getDefaultImage(), message, CONFIRM, getButtonLabels(CONFIRM), 0, configurator);
111

  
112
        return dialog.open() == 0;
113
    }
114

  
115

  
116
    protected static String[] getButtonLabels(int kind) {
117
        String[] dialogButtonLabels;
118
        switch (kind) {
119

  
120
        case WARNING: {
121
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL };
122
            break;
123
        }
124
        case CONFIRM: {
125
            dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL,
126
                    IDialogConstants.CANCEL_LABEL };
127
            break;
128
        }
129
        case QUESTION: {
130
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
131
                    IDialogConstants.NO_LABEL };
132
            break;
133
        }
134
        case QUESTION_WITH_CANCEL: {
135
            dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL,
136
                    IDialogConstants.NO_LABEL,
137
                    IDialogConstants.CANCEL_LABEL };
138
            break;
139
        }
140
        default: {
141
            throw new IllegalArgumentException(
142
                    "Illegal value for kind in MessageDialog.open()"); //$NON-NLS-1$
143
        }
144
        }
145
        return dialogButtonLabels;
146
    }
147

  
148
    /**
149
     * {@inheritDoc}
150
     */
151
    @Override
152
    public void handleEvent(Event event) {
153
        Reference reference;
154
        if(event.widget==btnBrowseReference){
155
            reference = SelectionDialogFactory.getSelectionFromDialog(Reference.class, this.getShell(), null, null);
156
            if(reference!=null){
157
                this.configurator.setNewSecundum(reference);
158
                textReference.setText(reference.getTitleCache());
159

  
160
            }
161

  
162
        }
163
        else if(event.widget==btnClear){
164
            reference = null;
165
            textReference.setText("");
166
            this.configurator.setNewSecundum(null);
167
        }
168
        else{
169
            reference = null;
170
            textReference.setText("");
171
            this.configurator.setNewSecundum(null);
172
        }
173

  
174
    }
175

  
176
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/configurator/SetSecundumForSubtreeConfigurationWizard.java
1
/**
2
* Copyright (C) 2017 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
package eu.etaxonomy.taxeditor.ui.dialog.configurator;
10

  
11
import org.eclipse.jface.wizard.Wizard;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.widgets.Shell;
14

  
15
import eu.etaxonomy.cdm.api.service.config.SetSecundumForSubtreeConfigurator;
16
import eu.etaxonomy.cdm.model.reference.Reference;
17

  
18
/**
19
 * @author k.luther
20
 * @date 10.02.2017
21
 *
22
 */
23
public class SetSecundumForSubtreeConfigurationWizard extends Wizard {
24

  
25
    Reference newSecRef;
26
    private final SetSecundumForSubtreeConfigurator configurator;
27

  
28

  
29
    private SetSecundumConfiguratorWizardPage page;
30

  
31

  
32

  
33
    /**
34
     * @param parentShell
35
     * @param dialogTitle
36
     * @param dialogTitleImage
37
     * @param dialogMessage
38
     * @param dialogImageType
39
     * @param dialogButtonLabels
40
     * @param defaultIndex
41
     * @param config
42
     */
43
    public SetSecundumForSubtreeConfigurationWizard(SetSecundumForSubtreeConfigurator config) {
44
        super();
45
       // super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
46
        this.configurator = config;
47
        setNeedsProgressMonitor(true);
48

  
49

  
50

  
51
    }
52

  
53

  
54

  
55
    /**
56
     * @param configurator
57
     * @param activeShell
58
     * @param setSecundumHandler_confirm
59
     * @param setSecundumHandler_configureSettings
60
     * @return
61
     */
62
    public static void openConfirmWithConfigurator(SetSecundumForSubtreeConfigurator configurator, Shell parent, String title, String message) {
63

  
64
        SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
65

  
66

  
67
    }
68

  
69

  
70

  
71

  
72

  
73
    /**
74
     * {@inheritDoc}
75
     */
76
    @Override
77
    public boolean performFinish() {
78
       if (!(configurator.isIncludeAcceptedTaxa() || configurator.isIncludeSynonyms())){
79
           return false;
80
       }else{
81
           return true;
82
       }
83
    }
84

  
85
    /* (non-Javadoc)
86
     * @see org.eclipse.jface.wizard.Wizard#addPages()
87
     */
88
    /** {@inheritDoc} */
89
    @Override
90
    public void addPages() {
91
        page = new SetSecundumConfiguratorWizardPage(configurator, this, SWT.NONE);
92
        addPage(page);
93
    }
94

  
95

  
96
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)