Project

General

Profile

Revision 432276e4

ID432276e49d4b5dcbad80f023b7525c5571c43075
Parent fecf5fd5
Child c130c5fe

Added by Katja Luther over 1 year ago

ref #7849: harmonize admin and local preferences for distribution editor and use drop down instead of radio buttons

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/ChecklistLabelProvider.java
43 43
import eu.etaxonomy.cdm.model.taxon.Taxon;
44 44
import eu.etaxonomy.taxeditor.editor.view.checklist.e4.ChecklistEditorE4;
45 45
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
46
import eu.etaxonomy.taxeditor.preference.TermDisplayEnum;
46 47
import eu.etaxonomy.taxeditor.store.CdmStore;
47 48

  
48 49
/**
......
125 126
                                String label = rep.getLabel();
126 127

  
127 128
                                if (label == null){
128
                                    distribution.getStatus().getTitleCache();
129
                                    label = distribution.getStatus().getTitleCache();
129 130
                                }
130
                                if (PreferencesUtil.isShowSymbolInChecklistEditor()){
131
                                    return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
131
                                if (PreferencesUtil.displayStatusInChecklistEditor() != null){
132
                                    if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.IdInVocabulary.getKey())){
133
                                        return (StringUtils.isNotBlank(distribution.getStatus().getIdInVocabulary()))?distribution.getStatus().getIdInVocabulary():label;
134
                                    }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol1.getKey())){
135
                                        System.err.println(columnIndex + " " +label);
136
                                        return (StringUtils.isNotBlank(distribution.getStatus().getSymbol() ))?distribution.getStatus().getSymbol():label;
137
                                    }else if(PreferencesUtil.displayStatusInChecklistEditor().equals(TermDisplayEnum.Symbol2.getKey())){
138
                                        return (StringUtils.isNotBlank(distribution.getStatus().getSymbol2() ))?distribution.getStatus().getSymbol2():label;
139
                                    }else{
140
                                        return (label != null)?label:DEFAULT_ENTRY;
141
                                    }
142

  
132 143
                                }else{
133 144
                                    return (label != null)?label:DEFAULT_ENTRY;
134 145
                                }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditingSupportE4.java
43 43
import eu.etaxonomy.taxeditor.event.EventUtility;
44 44
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
45 45
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
46
import eu.etaxonomy.taxeditor.preference.TermDisplayEnum;
46 47
import eu.etaxonomy.taxeditor.store.CdmStore;
47 48

  
48 49
public final class DistributionEditingSupportE4 extends EditingSupport {
......
82 83
        	    	     label = status.getTitleCache();
83 84
        	    	 }
84 85
        	    	 String result = null;
85
        	    	 if (PreferencesUtil.isShowSymbolInChecklistEditor() && !StringUtils.isBlank(status.getSymbol())){
86
        	    		 result = label + "("+ status.getSymbol()+")";
86
        	    	 String statusDisplay = PreferencesUtil.displayStatusInChecklistEditor();
87
        	    	 if (statusDisplay != null){
88
        	    	     if (statusDisplay.equals(TermDisplayEnum.Symbol1.getKey()) && !StringUtils.isBlank(status.getSymbol())){
89
        	    	         result = label + "("+ status.getSymbol()+")";
90
        	    	     }else if (statusDisplay.equals(TermDisplayEnum.IdInVocabulary.getKey()) && !StringUtils.isBlank(status.getIdInVocabulary())){
91
        	    	         result = label + "("+ status.getIdInVocabulary()+")";
92
        	    	     }else if (statusDisplay.equals(TermDisplayEnum.Symbol2.getKey()) && !StringUtils.isBlank(status.getSymbol2())){
93
                             result = label + "("+ status.getSymbol2()+")";
94
                         }else{
95
        	    	         result = label;
96
        	    	     }
97

  
87 98
        	    	 }else{
88
        	    		 result = label;
99
        	    	     result = label;
89 100
        	    	 }
101
//
102
//        	    	 if (PreferencesUtil.displayStatusInChecklistEditor() != null && !StringUtils.isBlank(status.getSymbol())){
103
//        	    		 result = label + "("+ status.getSymbol()+")";
104
//        	    	 }else{
105
//        	    		 result = label;
106
//        	    	 }
90 107
        	    	 return result;
91 108
        	     }
92 109
        	     return null;
......
168 185
                    descr.removeElement(distribution);
169 186
                    changed = true;
170 187
                }else{
171
                    if (!distribution.getStatus().equals(occurenceStatus)){
188
                    if (distribution.getStatus() == null || !distribution.getStatus().equals(occurenceStatus)){
172 189
                        changed = true;
173 190
                        distribution.setStatus(occurenceStatus);
174 191
                    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/handler/OpenChecklistEditorHandlerE4.java
2 2

  
3 3
import java.util.UUID;
4 4

  
5
import javax.inject.Inject;
6

  
5 7
import org.apache.commons.lang.StringUtils;
8
import org.eclipse.e4.core.services.log.Logger;
6 9
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
7 10
import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
8 11
import org.eclipse.e4.ui.workbench.modeling.EPartService;
......
26 29
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
27 30

  
28 31
public class OpenChecklistEditorHandlerE4 extends DefaultOpenHandlerBaseE4<ITaxonTreeNode> {
29

  
32
    @Inject
33
    private Logger logger;
30 34
    private static final String COULD_NOT_OPEN_DISTRIBUTION_EDITOR_THE_HIERARCHY_IS_CORRUPTED = Messages.OpenChecklistEditorHandler_COULD_NOT_OPEN_MESSAGE;
31 35
    private static final String COULD_NOT_OPEN_DISTRIBUTION_EDITOR = Messages.OpenChecklistEditorHandler_COULD_NOT_OPEN_TITLE;
32 36

  
......
80 84
		if (checklistEditor != null){
81 85
			checklistEditor.init(input);
82 86
		}else{
83
			System.err.println("Editor is null");
87
			logger.debug("Editor is null");
84 88
		}
85 89
	}
86 90

  
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
90 90
import eu.etaxonomy.taxeditor.navigation.navigator.Root;
91 91
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNodeNavigatorComparator;
92 92
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
93
import eu.etaxonomy.taxeditor.preference.NavigatorOrderEnum;
93 94
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
94 95
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
95 96
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
......
218 219
	/** {@inheritDoc} */
219 220
	protected IAdaptable getInitialInput() {
220 221
		Comparator<TaxonNodeDto> comparator;
221
		if (PreferencesUtil.getSortNodesNaturally()){
222
		NavigatorOrderEnum orderValue = PreferencesUtil.getSortNodes();
223
		if (orderValue.equals(NavigatorOrderEnum.NaturalOrder)){
222 224
			comparator = new TaxonNodeDtoNaturalComparator();
223
		} else if (PreferencesUtil.getSortNodesStrictlyAlphabetically()){
225
		} else if (orderValue.equals(NavigatorOrderEnum.AlphabeticalOrder)){
224 226
			comparator = new TaxonNodeDtoByNameComparator();
225 227
		}else {
226 228
			comparator = new TaxonNodeDtoByRankAndNameComparator();
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TreeNodeDropAdapterE4.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.navigation.navigator.e4;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.EnumSet;
13 14
import java.util.HashSet;
14 15
import java.util.Iterator;
16
import java.util.List;
15 17
import java.util.Set;
16 18
import java.util.UUID;
17 19

  
......
143 145

  
144 146
		    // do not allow to drop onto itself and
145 147
		    // check users permissions with all selected taxon nodes and taxa
148
		    List<UUID> nodeUuids = new ArrayList<>();
149
		    boolean isNotSameTaxonNode = true;
150
		    boolean isNotSameParent = true;
146 151
		    for(TaxonNodeDto taxonNode : getSelectedTaxa()){
147 152
			    if (logger.isDebugEnabled()){
148 153
			    	logger.debug("selectedTaxa: " + taxonNode.getTaxonUuid() == null? "-" : taxonNode.getTitleCache()); //$NON-NLS-1$
......
154 159
	                    }
155 160
	                    return false;
156 161
	                }
157
			    boolean isSameTaxonNode = taxonNode.equals(target);
158
			    boolean isSameParent = taxonNode.getParentUUID().equals(((TaxonNodeDto) target).getUuid());
159
			    TaxonNode node = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid());
160
				boolean hasTaxonNodePermission = CdmStore.currentAuthentiationHasPermission(node, UPDATE);
162
			    isNotSameTaxonNode = isNotSameTaxonNode && !taxonNode.equals(target);
163
			    isNotSameParent = isNotSameParent && !taxonNode.getParentUUID().equals(((TaxonNodeDto) target).getUuid());
164
			    nodeUuids.add(taxonNode.getUuid());
161 165

  
162
				boolean hasTaxonPermission =
163
	        			CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE);CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE);
166
		    }
167
			    List<TaxonNode> nodes = CdmStore.getService(ITaxonNodeService.class).load(nodeUuids, null);
168
			    boolean hasPermission = true;
169
			    for (TaxonNode node: nodes){
170
			        hasPermission = hasPermission && CdmStore.currentAuthentiationHasPermission(node, UPDATE) && CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE);
171
			    }
172
//				boolean hasTaxonPermission =
173
//	        			CdmStore.currentAuthentiationHasPermission(node.getTaxon(), UPDATE);
164 174
                if (
165
			        isSameTaxonNode
166
			        || isSameParent
167
			        || !hasTaxonNodePermission
168
    	            || !hasTaxonPermission
175
			        !isNotSameTaxonNode
176
			        || !isNotSameParent
177
			        || !hasPermission
178

  
169 179
    	            ) {
170 180
                    if(logger.isDebugEnabled()){
171
                        logger.debug("CANCEL_STATUS for selected  " + isSameTaxonNode + Messages.TreeNodeDropAdapter_10 + hasTaxonNodePermission + " " + hasTaxonPermission + " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
181
                        logger.debug("CANCEL_STATUS for selected  " + isNotSameTaxonNode + Messages.TreeNodeDropAdapter_10 + hasPermission +  " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
172 182
                    }
173 183
					return false;
174 184
				}
175 185
			}
176 186
			logger.debug("OK_STATUS"); //$NON-NLS-1$
177 187
			return true;
178
		}
179
		logger.debug("CANCEL_STATUS"); //$NON-NLS-1$
180
		return false;
188
//		}
189
//		logger.debug("CANCEL_STATUS"); //$NON-NLS-1$
190
//		return false;
181 191
	}
182 192

  
183 193

  
......
191 201
        }
192 202
        IUndoContext workspaceUndoContext = taxonNavigator.getUndoContext();
193 203
         int movingTypeInt = 0;
194
		if (PreferencesUtil.getSortNodesNaturally()){
204
		if (PreferencesUtil.isNodesSortedNaturally()){
195 205
			String[] buttonLables = {TREE_NODE_DROP_ADAPTER_CHILD, TREE_NODE_DROP_ADAPTER_BEHIND,TREE_NODE_DROP_ADAPTER_CANCEL};
196 206
			MessageDialog dialog = new MessageDialog(null, TARGET_NODE, null, DO_YOU_WANT_TO_MOVE_THE_TAXONNODE_AS_CHILD_OR_BEHIND_THE_TARGET_NODE, MessageDialog.QUESTION_WITH_CANCEL, buttonLables, 0);
197 207
			dialog.open();
......
233 243
            public void run() {
234 244
                AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ",
235 245
                        uuid,
236
                        500,
246
                        1000,
237 247
                        false,
238 248
                        TreeNodeDropAdapterE4.this,
239 249
                        null,
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveTaxonNodeHandlerE4.java
94 94
        TaxonNode parentTaxonNode;
95 95
        MovingType moveToNewParent = MovingType.CHILD;
96 96

  
97
        if (PreferencesUtil.getSortNodesNaturally()){
98

  
99

  
97
        if (PreferencesUtil.isNodesSortedNaturally()){
100 98
            parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
101 99
                    Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON,
102 100
                    oldTaxonNodeUUIDs,
eu.etaxonomy.taxeditor.store/plugin.xml
605 605
   </page>
606 606
    <page 
607 607
         category="eu.etaxonomy.taxeditor.store.distribution"
608
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.ChecklistEditorGeneralPreference"
608
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.ChecklistEditorGeneralAdminPreference"
609 609
         id="eu.etaxonomy.taxeditor.store.checklist"
610 610
         name="%page.name.21">
611 611
   </page>
612 612
   <page
613
         category="eu.etaxonomy.taxeditor.preferences.general"
614
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.AbcdImportPreference"
615
         id="eu.etaxonomy.taxeditor.store.abcdImportPreference"
616
         name="%page.name.40">
617
   </page>
618
   <page
619 613
         category="eu.etaxonomy.taxeditor.store.abcdImportPreference"
620 614
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.AbcdImportProvider"
621 615
         id="eu.etaxonomy.taxeditor.store.abcdImportProvider"
......
623 617
   </page>
624 618
   <page
625 619
         category="eu.etaxonomy.taxeditor.preferences.general"
626
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.VokabularyAdminPreferences"
620
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.VocabularyAdminPreferences"
627 621
         id="eu.etaxonomy.taxeditor.store.vocabularyAdminPreference"
628 622
         name="%page.name.47">
629 623
   </page>
......
656 650
         id="eu.etaxonomy.taxeditor.store.page3"
657 651
         name="%page.name.44">
658 652
   </page>
653
   <page
654
         category="eu.etaxonomy.taxeditor.preferences.general"
655
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.AbcdImportPreference"
656
         id="eu.etaxonomy.taxeditor.store.abcdImportPreference"
657
         name="%page.name.40">
658
   </page>
659 659
</extension>
660 660
</plugin>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/AbcdImportPreference.java
25 25
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
26 26
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
27 27
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
28
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
29 28
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
30 29
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
31 30
import eu.etaxonomy.taxeditor.l10n.Messages;
31
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
32
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
32 33
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
33 34
import eu.etaxonomy.taxeditor.store.CdmStore;
34 35

  
......
55 56
        configurator = Abcd206ImportConfigurator.NewInstance(null,null);
56 57
        ICdmRepository controller;
57 58
        controller = CdmStore.getCurrentApplicationConfiguration();
58
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AbcdImportConfig);
59
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), EditorPreferencePredicate.AbcdImportConfig);
59 60

  
60 61
        if (controller == null){
61 62
            return null;
......
65 66
        if (preference != null ){
66 67
            allowOverride = preference.isAllowOverride();
67 68
        }else{
68
            preference = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AbcdImportConfig, configurator.toString());
69
            preference = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.AbcdImportConfig, configurator.toString());
69 70
        }
70 71

  
71 72
        if (preference != null){
......
110 111
                     configurator.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
111 112
                 }else if (keyString.equals("nomenclaturalCode")){ //$NON-NLS-1$
112 113
                     configurator.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
114
                 }else if (keyString.equals("getSiblings")){ //$NON-NLS-1$
115
                     configurator.setGetSiblings(Boolean.valueOf(valueString));
116
                 }else if (keyString.equals("removeCountryFromLocalityText")){ //$NON-NLS-1$
117
                     configurator.setRemoveCountryFromLocalityText(Boolean.valueOf(valueString));
113 118
                 }
119

  
114 120
             }
115 121

  
116 122
         }
......
224 230
        checkBoxImportSiblings.addSelectionListener(new SelectionAdapter() {
225 231
            @Override
226 232
            public void widgetSelected(SelectionEvent e) {
227
                configurator.setGetSiblings(checkBoxImportSiblings.getSelection());
233
                configurator.setGetSiblings(!configurator.isGetSiblings());
228 234
            }
229 235
        });
230 236

  
......
260 266
        checkBoxReuseExistingTaxa.addSelectionListener(new SelectionAdapter() {
261 267
            @Override
262 268
            public void widgetSelected(SelectionEvent e) {
263
                configurator.setReuseExistingDescriptiveGroups(!configurator.isReuseExistingDescriptiveGroups());
269
                configurator.setReuseExistingTaxaWhenPossible(!configurator.isReuseExistingTaxaWhenPossible());
264 270
            }
265 271
        });
266 272

  
......
318 324
        if (configurator != null){
319 325
            String configString = configurator.toString();
320 326

  
321
            CdmPreference pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.AbcdImportConfig, configString);
327
            CdmPreference pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.AbcdImportConfig, configString);
322 328
            pref.setAllowOverride(allowOverride);
323 329

  
324 330
            ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
......
327 333
            }
328 334
            IPreferenceService service = controller.getPreferenceService();
329 335
            service.set(pref);
336
            PreferencesUtil.updateDBPreferences();
330 337

  
331 338
        }
332 339
        return true;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralAdminPreference.java
1
/**
2
 * Copyright (C) 2014 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.databaseAdmin.preferencePage;
10

  
11
import org.eclipse.swt.widgets.Composite;
12
import org.eclipse.swt.widgets.Control;
13

  
14
import eu.etaxonomy.cdm.api.application.ICdmRepository;
15
import eu.etaxonomy.cdm.api.service.IPreferenceService;
16
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
17
import eu.etaxonomy.taxeditor.preference.ChecklistEditorGeneralPreference;
18
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
19
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20
import eu.etaxonomy.taxeditor.store.CdmStore;
21

  
22
/**
23
 * @author a.oppermann
24
 * @date 21.07.2014
25
 *
26
 */
27
public class ChecklistEditorGeneralAdminPreference extends ChecklistEditorGeneralPreference implements IE4AdminPreferencePage {
28

  
29

  
30

  
31

  
32

  
33
    @Override
34
    protected Control createContents(Composite parent) {
35

  
36
//        allowOverride = distributionPref.isAllowOverride();
37
//
38
//        final Button allowOverrideCheckButton = new Button(parent, SWT.CHECK);
39
//        allowOverrideCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
40
//        allowOverrideCheckButton.setSelection(allowOverride);
41
//        allowOverrideCheckButton.addSelectionListener(new SelectionAdapter(){
42
//            @Override
43
//            public void widgetSelected(SelectionEvent e) {
44
//                allowOverride = allowOverrideCheckButton.getSelection();
45
//            }
46
//        });
47
//
48
        return super.createContents(parent);
49
//
50
//        final Button activateCheckButton = new Button(composite, SWT.CHECK);
51
//        activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable);
52
//        activateCheckButton.setSelection(isEditorActivated);
53
//        activateCheckButton.addSelectionListener(new SelectionAdapter(){
54
//            @Override
55
//            public void widgetSelected(SelectionEvent e) {
56
//                isEditorActivated = activateCheckButton.getSelection();
57
//
58
//                if(isEditorActivated){
59
//                    child.setVisible(true);
60
//                    child.setEnabled(true);
61
//                }else{
62
//                    child.setVisible(false);
63
//                    child.setEnabled(false);
64
//                }
65
//
66
//            }
67
//        });
68
//
69
//        child  = new Composite(composite, SWT.NULL);
70
//        child.setLayout(new GridLayout());
71
//        child.setVisible(isEditorActivated);
72
//
73
//
74
//
75
////
76
//
77
//
78
////
79
////        final CommandHandlerButton button_openWizard = new CommandHandlerButton(child, SWT.PUSH,
80
////                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler");
81
////
82
////        button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
83
//
84
////        Table table = new Table
85
//        final CLabel description = new CLabel(child, SWT.NULL);
86
//        description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
87
//
88
//
89
//        GridData gridData = new GridData();
90
//        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
91
//        gridData.horizontalIndent = 5;
92
////      classificationSelection.setLayoutData(gridData);
93
//
94
//
95
//        final Button showIdInVocabulary = new Button(child, SWT.RADIO);
96
//        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInVocabulary);
97
//        if (pref != null){
98
//            isShowIdInVocabulary = Boolean.valueOf(pref.getValue());
99
//        }else{
100
//            isShowIdInVocabulary = false;
101
//        }
102
//        showIdInVocabulary.setText(Messages.ChecklistEditorGeneralPreference_show_id_in_voc);
103
//        showIdInVocabulary.setSelection(isShowIdInVocabulary);
104
//        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
105
//            @Override
106
//            public void widgetSelected(SelectionEvent e) {
107
//                isShowIdInVocabulary = showIdInVocabulary.getSelection();
108
//
109
//             }
110
//        });
111
//        final Button showSymbol1 = new Button(child, SWT.RADIO);
112
//        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbol1);
113
//        if (pref != null){
114
//            isShowSymbol1 = Boolean.valueOf(pref.getValue());
115
//        }else{
116
//            isShowSymbol1 = false;
117
//        }
118
//        showSymbol1.setText(Messages.ChecklistEditorGeneralPreference_show_symbol1);
119
//        showSymbol1.setSelection(isShowSymbol1);
120
//        showSymbol1.addSelectionListener(new SelectionAdapter(){
121
//            @Override
122
//            public void widgetSelected(SelectionEvent e) {
123
//                isShowSymbol1 = showSymbol1.getSelection();
124
//
125
//             }
126
//        });
127
//        final Button showSymbol2 = new Button(child, SWT.RADIO);
128
//        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbol2);
129
//        if (pref != null){
130
//            isShowSymbol2 = Boolean.valueOf(pref.getValue());
131
//        }else{
132
//            isShowSymbol2 = false;
133
//        }
134
//        showSymbol2.setText(Messages.ChecklistEditorGeneralPreference_show_symbol2);
135
//        showSymbol2.setSelection(isShowSymbol2);
136
//        showSymbol2.addSelectionListener(new SelectionAdapter(){
137
//            @Override
138
//            public void widgetSelected(SelectionEvent e) {
139
//                isShowSymbol2 = showSymbol2.getSelection();
140
//
141
//             }
142
//        });
143
//        final Button showTitle = new Button(child, SWT.RADIO);
144
//        isShowTitle = !(isShowIdInVocabulary || isShowSymbol1 || isShowSymbol2);
145
//
146
//        showTitle.setText(Messages.ChecklistEditorGeneralPreference_show_title);
147
//        showTitle.setSelection(isShowTitle);
148
//        showTitle.addSelectionListener(new SelectionAdapter(){
149
//            @Override
150
//            public void widgetSelected(SelectionEvent e) {
151
//                isShowTitle = showTitle.getSelection();
152
//
153
//             }
154
//        });
155
//
156
//        final Label seperator1 = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
157
//        final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
158
//
159
//        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedByIdInVocabulary);
160
//        if (pref != null){
161
//            isSortByVocabularyOrder = Boolean.valueOf(pref.getValue());
162
//        }else{
163
//            isSortByVocabularyOrder = false;
164
//        }
165
//
166
//        sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
167
//        sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
168
//        sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
169
//            @Override
170
//            public void widgetSelected(SelectionEvent e) {
171
//                isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
172
//             }
173
//        });
174
//        final Label seperator2 = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
175
//        final CLabel descriptionStatus = new CLabel(child, SWT.NULL);
176
//        descriptionStatus.setText(Messages.ChecklistEditorGeneralPreference_STATUS_DISPLAY_TEXT);
177
//        final Button showSymbol = new Button(child, SWT.CHECK);
178
//        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbolForStatus);
179
//        if (pref != null){
180
//            isShowSymbol = Boolean.valueOf(pref.getValue());
181
//        }else{
182
//            isShowSymbol = false;
183
//        }
184
//
185
//        showSymbol.setText(Messages.ChecklistEditorGeneralPreference_show_symbol);
186
//        showSymbol.setSelection(isShowSymbol);
187
//        showSymbol.addSelectionListener(new SelectionAdapter(){
188
//            @Override
189
//            public void widgetSelected(SelectionEvent e) {
190
//                isShowSymbol = showSymbol.getSelection();
191
//             }
192
//        });
193
////        PreferencesUtil.recursiveSetEnabled(button_openWizard, CdmStore.isActive());
194
//        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
195
//        if (pref != null){
196
//            isShowRank = Boolean.valueOf(pref.getValue());
197
//        }else{
198
//            isShowRank = false;
199
//        }
200
//
201
//        final Button activateRankButton = new Button(child, SWT.CHECK);
202
//        activateRankButton.setText(Messages.ChecklistEditorGeneralPreference_show_rank);
203
//        activateRankButton.setSelection(isShowRank);
204
//        activateRankButton.addSelectionListener(new SelectionAdapter(){
205
//            @Override
206
//            public void widgetSelected(SelectionEvent e) {
207
//                isShowRank = activateRankButton.getSelection();
208
//            }
209
//        });
210
//
211
//
212
//        if(isEditorActivated){
213
//            child.setEnabled(true);
214
//        }else{
215
//            child.setEnabled(false);
216
//        }
217

  
218
  //      return composite;
219
    }
220

  
221
    @Override
222
    public boolean performOk() {
223
        if (this.distributionEditorPref == null){
224
            return true;
225
        }
226
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
227
        if (controller == null){
228
            return false;
229
        }
230
        IPreferenceService service = controller.getPreferenceService();
231

  
232
        CdmPreference pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
233
        //ToDo
234
        pref.setAllowOverride(this.allowOverrideActivated);
235
        service.set(pref);
236

  
237
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DisplayOfAreasInDistributionEditor, this.displayArea);
238
        //ToDo
239
        pref.setAllowOverride(this.allowOverrideAreaDisplay);
240
        service.set(pref);
241

  
242

  
243

  
244
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.DisplayOfStatus, this.displayStatus);
245
        //ToDo
246
        pref.setAllowOverride(this.allowOverrideStatusDisplay);
247
        service.set(pref);
248

  
249
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
250
        //ToDo
251
        pref.setAllowOverride(this.allowOverrideRank);
252
        service.set(pref);
253
        pref = CdmPreference.NewTaxEditorInstance( EditorPreferencePredicate.AreasSortedByIdInVocabulary, Boolean.toString(isSortByVocabularyOrder));
254
        //ToDo
255
        pref.setAllowOverride(this.allowOverrideOrderAreas);
256
        service.set(pref);
257

  
258

  
259
        PreferencesUtil.updateDBPreferences();
260

  
261
        return true;
262
    }
263

  
264
    @Override
265
    public void init() {
266
        setPreferenceStore(PreferencesUtil.getPreferenceStore());
267
        distributionEditorPref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DistributionEditorActivated);
268
        if (distributionEditorPref == null){
269
            distributionEditorPref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DistributionEditorActivated, EditorPreferencePredicate.DistributionEditorActivated.getDefaultValue().toString());
270
        }
271
        isEditorActivated = Boolean.valueOf(distributionEditorPref.getValue());
272
        allowOverrideActivated = distributionEditorPref.isAllowOverride();
273
        isAdminPreference = true;
274

  
275
        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfAreasInDistributionEditor);
276
        if (pref != null){
277
            this.displayArea = pref.getValue();
278
            this.allowOverrideAreaDisplay = pref.isAllowOverride();
279
        }else{
280
            this.displayArea = EditorPreferencePredicate.DisplayOfAreasInDistributionEditor.getDefaultValue().toString();
281
            this.allowOverrideAreaDisplay = true;
282
        }
283

  
284
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.DisplayOfStatus);
285
        if (pref != null){
286
            this.displayStatus = pref.getValue();
287
            this.allowOverrideStatusDisplay = pref.isAllowOverride();
288
        }else{
289
            this.displayStatus = EditorPreferencePredicate.DisplayOfStatus.getDefaultValue().toString();
290
            this.allowOverrideStatusDisplay = true;
291
        }
292

  
293
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.AreasSortedByIdInVocabulary);
294
        if (pref != null){
295
            this.isSortByVocabularyOrder = Boolean.valueOf(pref.getValue().toString());
296
            this.allowOverrideOrderAreas = pref.isAllowOverride();
297
        }else{
298
            this.isSortByVocabularyOrder = Boolean.valueOf(EditorPreferencePredicate.AreasSortedByIdInVocabulary.getDefaultValue().toString());
299
            this.allowOverrideOrderAreas = true;
300
        }
301

  
302
        pref = PreferencesUtil.getPreferenceFromDB(EditorPreferencePredicate.ShowRankInDistributionEditor);
303
        if (pref != null){
304
            this.isShowRank = Boolean.valueOf(pref.getValue().toString());
305
            this.allowOverrideRank = pref.isAllowOverride();
306
        }else{
307
            this.isShowRank = Boolean.valueOf(EditorPreferencePredicate.ShowRankInDistributionEditor.getDefaultValue().toString());
308
            this.allowOverrideRank = true;
309
        }
310
        commandHandlerString = "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
311
        commandHandlerStringStatus = "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler";
312

  
313
    }
314

  
315
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/ChecklistEditorGeneralPreference.java
1
/**
2
 * Copyright (C) 2014 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.databaseAdmin.preferencePage;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Label;
20

  
21
import eu.etaxonomy.cdm.api.application.ICdmRepository;
22
import eu.etaxonomy.cdm.api.service.IPreferenceService;
23
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
24
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
25
import eu.etaxonomy.taxeditor.l10n.Messages;
26
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
27
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
28
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
29
import eu.etaxonomy.taxeditor.store.CdmStore;
30

  
31
/**
32
 * @author a.oppermann
33
 * @date 21.07.2014
34
 *
35
 */
36
public class ChecklistEditorGeneralPreference extends CdmPreferencePage implements IE4AdminPreferencePage {
37

  
38
    private boolean isEditorActivated;
39
    private boolean allowOverride;
40
    private boolean isShowRank;
41
    private boolean isSortByVocabularyOrder;
42
    private boolean isShowSymbol;
43
    private boolean isShowIdInVocabulary;
44
    private boolean isShowSymbol1;
45
    private boolean isShowSymbol2;
46
    private boolean isShowTitle;
47
    private String displayString;
48
    private Composite child ;
49
    private CdmPreference distributionPref = null;
50

  
51
    @Override
52
    protected Control createContents(Composite parent) {
53

  
54
        Composite composite = new Composite(parent, SWT.NULL);
55
        composite.setLayout(new GridLayout());
56
        distributionPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DistributionEditorActivated);
57
        if (distributionPref != null){
58
            isEditorActivated = Boolean.valueOf(distributionPref.getValue());
59
            allowOverride = distributionPref.isAllowOverride();
60
        }else{
61
            distributionPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DistributionEditorActivated, "false"); //$NON-NLS-1$
62
            isEditorActivated = false;
63
            allowOverride = true;
64
        }
65

  
66
        final Button activateCheckButton = new Button(composite, SWT.CHECK);
67
        activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable);
68
        activateCheckButton.setSelection(isEditorActivated);
69
        activateCheckButton.addSelectionListener(new SelectionAdapter(){
70
            @Override
71
            public void widgetSelected(SelectionEvent e) {
72
                isEditorActivated = activateCheckButton.getSelection();
73

  
74
                if(isEditorActivated){
75
                    child.setVisible(true);
76
                    child.setEnabled(true);
77
                }else{
78
                    child.setVisible(false);
79
                    child.setEnabled(false);
80
                }
81

  
82
            }
83
        });
84
        final Button allowOverrideCheckButton = new Button(composite, SWT.CHECK);
85
        allowOverrideCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
86
        allowOverrideCheckButton.setSelection(allowOverride);
87
        allowOverrideCheckButton.addSelectionListener(new SelectionAdapter(){
88
            @Override
89
            public void widgetSelected(SelectionEvent e) {
90
                allowOverride = allowOverrideCheckButton.getSelection();
91

  
92
            }
93
        });
94

  
95
        child  = new Composite(composite, SWT.NULL);
96
        child.setLayout(new GridLayout());
97
        child.setVisible(isEditorActivated);
98

  
99

  
100

  
101
//
102

  
103

  
104
//
105
//        final CommandHandlerButton button_openWizard = new CommandHandlerButton(child, SWT.PUSH,
106
//                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler");
107
//
108
//        button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
109

  
110
//        Table table = new Table
111
        final CLabel description = new CLabel(child, SWT.NULL);
112
        description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
113

  
114
        final Button showIdInVocabulary = new Button(child, SWT.RADIO);
115
        CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInVocabulary);
116
        if (pref != null){
117
            isShowIdInVocabulary = Boolean.valueOf(pref.getValue());
118
        }else{
119
            isShowIdInVocabulary = false;
120
        }
121
        showIdInVocabulary.setText(Messages.ChecklistEditorGeneralPreference_show_id_in_voc);
122
        showIdInVocabulary.setSelection(isShowIdInVocabulary);
123
        showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
124
            @Override
125
            public void widgetSelected(SelectionEvent e) {
126
                isShowIdInVocabulary = showIdInVocabulary.getSelection();
127

  
128
             }
129
        });
130
        final Button showSymbol1 = new Button(child, SWT.RADIO);
131
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbol1);
132
        if (pref != null){
133
            isShowSymbol1 = Boolean.valueOf(pref.getValue());
134
        }else{
135
            isShowSymbol1 = false;
136
        }
137
        showSymbol1.setText(Messages.ChecklistEditorGeneralPreference_show_symbol1);
138
        showSymbol1.setSelection(isShowSymbol1);
139
        showSymbol1.addSelectionListener(new SelectionAdapter(){
140
            @Override
141
            public void widgetSelected(SelectionEvent e) {
142
                isShowSymbol1 = showSymbol1.getSelection();
143

  
144
             }
145
        });
146
        final Button showSymbol2 = new Button(child, SWT.RADIO);
147
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbol2);
148
        if (pref != null){
149
            isShowSymbol2 = Boolean.valueOf(pref.getValue());
150
        }else{
151
            isShowSymbol2 = false;
152
        }
153
        showSymbol2.setText(Messages.ChecklistEditorGeneralPreference_show_symbol2);
154
        showSymbol2.setSelection(isShowSymbol2);
155
        showSymbol2.addSelectionListener(new SelectionAdapter(){
156
            @Override
157
            public void widgetSelected(SelectionEvent e) {
158
                isShowSymbol2 = showSymbol2.getSelection();
159

  
160
             }
161
        });
162
        final Button showTitle = new Button(child, SWT.RADIO);
163
        isShowTitle = !(isShowIdInVocabulary || isShowSymbol1 || isShowSymbol2);
164

  
165
        showTitle.setText(Messages.ChecklistEditorGeneralPreference_show_title);
166
        showTitle.setSelection(isShowTitle);
167
        showTitle.addSelectionListener(new SelectionAdapter(){
168
            @Override
169
            public void widgetSelected(SelectionEvent e) {
170
                isShowTitle = showTitle.getSelection();
171

  
172
             }
173
        });
174

  
175
        final Label seperator1 = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
176
        final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
177

  
178
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedByIdInVocabulary);
179
        if (pref != null){
180
            isSortByVocabularyOrder = Boolean.valueOf(pref.getValue());
181
        }else{
182
            isSortByVocabularyOrder = false;
183
        }
184

  
185
        sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
186
        sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
187
        sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
188
            @Override
189
            public void widgetSelected(SelectionEvent e) {
190
                isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
191
             }
192
        });
193
        final Label seperator2 = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
194
        final CLabel descriptionStatus = new CLabel(child, SWT.NULL);
195
        descriptionStatus.setText(Messages.ChecklistEditorGeneralPreference_STATUS_DISPLAY_TEXT);
196
        final Button showSymbol = new Button(child, SWT.CHECK);
197
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowSymbolForStatus);
198
        if (pref != null){
199
            isShowSymbol = Boolean.valueOf(pref.getValue());
200
        }else{
201
            isShowSymbol = false;
202
        }
203

  
204
        showSymbol.setText(Messages.ChecklistEditorGeneralPreference_show_symbol);
205
        showSymbol.setSelection(isShowSymbol);
206
        showSymbol.addSelectionListener(new SelectionAdapter(){
207
            @Override
208
            public void widgetSelected(SelectionEvent e) {
209
                isShowSymbol = showSymbol.getSelection();
210
             }
211
        });
212
//        PreferencesUtil.recursiveSetEnabled(button_openWizard, CdmStore.isActive());
213
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
214
        if (pref != null){
215
            isShowRank = Boolean.valueOf(pref.getValue());
216
        }else{
217
            isShowRank = false;
218
        }
219

  
220
        final Button activateRankButton = new Button(child, SWT.CHECK);
221
        activateRankButton.setText(Messages.ChecklistEditorGeneralPreference_show_rank);
222
        activateRankButton.setSelection(isShowRank);
223
        activateRankButton.addSelectionListener(new SelectionAdapter(){
224
            @Override
225
            public void widgetSelected(SelectionEvent e) {
226
                isShowRank = activateRankButton.getSelection();
227
            }
228
        });
229

  
230

  
231
        if(isEditorActivated){
232
            child.setEnabled(true);
233
        }else{
234
            child.setEnabled(false);
235
        }
236

  
237
        return composite;
238
    }
239

  
240
    @Override
241
    public boolean performOk() {
242
        if (distributionPref == null){
243
            return true;
244
        }
245
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
246
        if (controller == null){
247
            return false;
248
        }
249
        IPreferenceService service = controller.getPreferenceService();
250

  
251
        CdmPreference pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DistributionEditorActivated, Boolean.toString(isEditorActivated));
252
        //ToDo
253
        pref.setAllowOverride(allowOverride);
254
        service.set(pref);
255

  
256
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowIdInVocabulary, Boolean.toString(isShowIdInVocabulary));
257
        //ToDo
258
        pref.setAllowOverride(true);
259
        service.set(pref);
260

  
261
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowSymbol1, Boolean.toString(isShowSymbol1));
262
        //ToDo
263
        pref.setAllowOverride(true);
264
        service.set(pref);
265
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowSymbol2, Boolean.toString(isShowSymbol2));
266
        //ToDo
267
        pref.setAllowOverride(true);
268
        service.set(pref);
269

  
270

  
271
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowSymbolForStatus, Boolean.toString(isShowSymbol));
272
        //ToDo
273
        pref.setAllowOverride(true);
274
        service.set(pref);
275

  
276
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.ShowRankInDistributionEditor, Boolean.toString(isShowRank));
277
        //ToDo
278
        pref.setAllowOverride(true);
279
        service.set(pref);
280
        pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.AreasSortedByIdInVocabulary, Boolean.toString(isSortByVocabularyOrder));
281
        //ToDo
282
        pref.setAllowOverride(true);
283
        service.set(pref);
284

  
285
        PreferencesUtil.setBooleanValue(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, isEditorActivated);
286
        PreferencesUtil.setSortNamedAreasByOrderInVocabulary(isSortByVocabularyOrder);
287
        PreferencesUtil.setShowRankInChecklistEditor(isShowRank);
288
        PreferencesUtil.setShowSymbolInChecklistEditor(isShowSymbol);
289

  
290
        if (isShowIdInVocabulary){
291
            displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_ID_IN_VOCABULARY;
292
        }else if (isShowSymbol1){
293
            displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_SYMBOL1;
294
        }else if (isShowSymbol2){
295
            displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_SYMBOL2;
296
        }else{
297
            displayString = IPreferenceKeys.CHECKLIST_AREA_DISPLAY_TITLE;
298
        }
299
        PreferencesUtil.setShowIdInVocabularyInChecklistEditor(displayString);
300
        PreferencesUtil.updateDBPreferences();
301

  
302
        return true;
303
    }
304

  
305
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/DistributionAdminPreferences.java
12 12
import org.eclipse.swt.custom.CLabel;
13 13
import org.eclipse.swt.events.SelectionAdapter;
14 14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
15
import org.eclipse.swt.layout.GridData;
16 16
import org.eclipse.swt.widgets.Button;
17 17
import org.eclipse.swt.widgets.Composite;
18 18
import org.eclipse.swt.widgets.Control;
......
38 38

  
39 39
    @Override
40 40
    protected Control createContents(Composite parent) {
41
        Composite composite = new Composite(parent, SWT.NULL);
42
        composite.setLayout(new GridLayout());
43

  
41
        isAdminPreference = true;
42
        Composite composite = createComposite(parent);
43
        GridData labelGridData = new GridData();
44
        labelGridData.horizontalSpan = 2;
45
        labelGridData.verticalSpan = 4;
44 46

  
45 47
        prefAreas = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
46 48
        allowOverrideAreas = prefAreas != null?prefAreas.isAllowOverride():true;
47 49

  
48

  
49

  
50 50
        final CLabel label = new CLabel(composite, SWT.NULL);
51 51
        label.setText(Messages.ChecklistEditorGeneralPreference_open_wizard);
52

  
52
        label.setLayoutData(labelGridData);
53 53
        final CommandHandlerButton button_openWizard = new CommandHandlerButton(composite, SWT.PUSH,
54 54
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler"); //$NON-NLS-1$
55 55

  
......
72 72

  
73 73
        final CLabel labelStatus = new CLabel(composite, SWT.NULL);
74 74
        labelStatus.setText(Messages.DistributionAdminPreferences_SELECT_STATUS);
75

  
75
        GridData labelStatusGridData = new GridData();
76
        labelStatusGridData.horizontalSpan = 2;
77
        labelStatusGridData.verticalSpan = 2;
78
        labelStatus.setLayoutData(labelStatusGridData);
76 79
        final CommandHandlerButton button_openStatusWizard = new CommandHandlerButton(composite, SWT.PUSH,
77 80
                "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler"); //$NON-NLS-1$
78 81

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.java
10 10

  
11 11
import org.eclipse.swt.SWT;
12 12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
13
import org.eclipse.swt.layout.GridData;
15 14
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
15
import org.eclipse.swt.widgets.Combo;
17 16
import org.eclipse.swt.widgets.Composite;
18 17
import org.eclipse.swt.widgets.Control;
19 18

  
......
22 21
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
23 22
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
24 23
import eu.etaxonomy.taxeditor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
24
import eu.etaxonomy.taxeditor.preference.EditorPreferencePredicate;
26 25
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26
import eu.etaxonomy.taxeditor.preference.PublishEnum;
27 27
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
28 28
import eu.etaxonomy.taxeditor.store.CdmStore;
29 29

  
......
34 34
 */
35 35
public class PublishFlagPreference extends CdmPreferencePage implements IE4AdminPreferencePage{
36 36

  
37
   boolean setPublish;
38
   boolean setNotPublish;
39
   boolean inheritFromParent;
37
    PublishEnum publishBehaviour;
40 38

  
41
   String do_not_publish = "DO NOT PUBLISH";
42
   String inherit_from_parent = "PARENT";
43
   String publish = "PUBLISH";
44
   CdmPreference pref = null;
39
    Combo publishFlagBehaviour;
40
    CdmPreference pref = null;
45 41

  
46 42
   @Override
47 43
   public void init() {
......
56 52
    protected Control createContents(Composite parent) {
57 53
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
58 54
        if (pref == null){
59
            pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.DefaultBehaviourForPublishFlag, IPreferenceKeys.PUBLISH);
55
            pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DefaultBehaviourForPublishFlag, EditorPreferencePredicate.DefaultBehaviourForPublishFlag.getDefaultValue().toString());
60 56
        }
61 57

  
62
        if (pref.getValue().equals(IPreferenceKeys.DO_NOT_PUBLISH)){
63
            setNotPublish = true;
64
            setPublish = false;
65
            inheritFromParent = false;
66
        }
67

  
68
        if (pref.getValue().equals(IPreferenceKeys.INHERIT_FROM_PARENT)){
69
            setNotPublish = false;
70
            setPublish = false;
71
            inheritFromParent = true;
72
        }
73

  
74
        if (pref.getValue().equals(IPreferenceKeys.PUBLISH)){
75
            setNotPublish = false;
76
            setPublish = true;
77
            inheritFromParent = false;
78
        }
79 58
        final Composite composite = new Composite(parent, SWT.NULL);
80 59

  
81 60
        GridLayout gridLayout = new GridLayout();
82 61
        composite.setLayout(gridLayout);
83 62
        final CLabel description = new CLabel(composite, SWT.NULL);
84 63
        description.setText(Messages.PublishFlagPreference_description);
85
        gridLayout.numColumns = 1;
86
        gridLayout.horizontalSpacing= 10;
87
        gridLayout.makeColumnsEqualWidth = true;
88

  
89
        Button setPublishFlagAsDefault = new Button(composite, SWT.RADIO);
90
        setPublishFlagAsDefault.setText(Messages.PublishFlagPreference_set);
91
        setPublishFlagAsDefault.setSelection(setPublish);
92
        setPublishFlagAsDefault.addSelectionListener(new SelectionAdapter() {
93
            @Override
94
            public void widgetSelected(SelectionEvent e) {
95
               setPublish = !setPublish;
96
            }
97
        });
98
        Button setNotPublishFlagAsDefault = new Button(composite, SWT.RADIO);
99
        setNotPublishFlagAsDefault.setText(Messages.PublishFlagPreference_do_not_set);
100
        setNotPublishFlagAsDefault.setSelection(setNotPublish);
101
        setNotPublishFlagAsDefault.addSelectionListener(new SelectionAdapter() {
102
            @Override
103
            public void widgetSelected(SelectionEvent e) {
104
                setNotPublish = !setNotPublish;
105
            }
106
        });
107

  
108
        Button setInheritFromParent = new Button(composite, SWT.RADIO);
109
        setInheritFromParent.setText(Messages.PublishFlagPreference_inherit);
110
        setInheritFromParent.setSelection(inheritFromParent);
111
        setInheritFromParent.addSelectionListener(new SelectionAdapter() {
112
            @Override
113
            public void widgetSelected(SelectionEvent e) {
114
                inheritFromParent = !inheritFromParent;
64

  
65
        GridData gridData = new GridData();
66
        gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
67
        gridData.horizontalIndent = 5;
68

  
69
        publishFlagBehaviour = new Combo(composite, SWT.BORDER| SWT.READ_ONLY);
70
        publishFlagBehaviour.setLayoutData(gridData);
71

  
72
        for(PublishEnum display: PublishEnum.values()){
73
            publishFlagBehaviour.add(display.getLabel());
74
        }
75

  
76
        int index = 0;
77

  
78
        PublishEnum publishFlag = PublishEnum.valueOf(pref.getValue());
79
        for (String itemLabel : publishFlagBehaviour.getItems()){
80
            if (itemLabel.equalsIgnoreCase(publishFlag.getLabel())){
81
                publishFlagBehaviour.select(index);
82
                break;
115 83
            }
116
        });
84
            index++;
85
        }
86

  
117 87

  
118 88
        return composite;
119 89

  
......
125 95
        if (pref == null){
126 96
            return true;
127 97
        }
128
        String preferenceValue = null;
129
        if (setPublish){
130
            preferenceValue = publish;
131
        }else if (setNotPublish){
132
            preferenceValue = do_not_publish;
133
        } else{
134
            preferenceValue = inherit_from_parent;
135
        }
136
        CdmPreference pref = CdmPreference.NewTaxEditorInstance( PreferencePredicate.DefaultBehaviourForPublishFlag, preferenceValue);
98

  
99
        CdmPreference pref = CdmPreference.NewTaxEditorInstance(EditorPreferencePredicate.DefaultBehaviourForPublishFlag, publishFlagBehaviour.getText());
137 100
        pref.setAllowOverride(true);
138 101

  
139 102
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/VocabularyAdminPreferences.java
1
/**
2
* Copyright (C) 2018 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.databaseAdmin.preferencePage;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19

  
20
import eu.etaxonomy.cdm.api.application.ICdmRepository;
21
import eu.etaxonomy.cdm.api.service.IPreferenceService;
22
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
23
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
24
import eu.etaxonomy.taxeditor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
27
import eu.etaxonomy.taxeditor.store.CdmStore;
28
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
29

  
30
/**
31
 * @author k.luther
32
 * @since 05.10.2018
33
 *
34
 */
35
public class VocabularyAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
36

  
37
    boolean allowOverride;
38
    CdmPreference pref = null;
39

  
40
    @Override
41
    protected Control createContents(Composite parent) {
42
        this.isAdminPreference = true;
43
        Composite composite = createComposite(parent);
44
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
45

  
46

  
47
        final CLabel commonNameAreaLabel = new CLabel(composite, SWT.NULL);
48
        commonNameAreaLabel.setText(Messages.VokabularyAdminPreferences_SELECT_VOCABULARY_TEXT);
49

  
50
        GridData gridData = new GridData();
51
        gridData.horizontalSpan = 2;
52
        commonNameAreaLabel.setLayoutData(gridData);
53

  
54
        final CommandHandlerButton button_opencommonNameAreaWizard = new CommandHandlerButton(composite, SWT.PUSH,
55
                "eu.etaxonomy.taxeditor.store.open.OpenCommonNameAreaWizardAdminHandler"); //$NON-NLS-1$
56

  
57
        button_opencommonNameAreaWizard.setText(Messages.GeneralPreference_open_common_name_area_selection);
58
        final Button allowOverrideCommonNameAreaCheckButton = new Button(composite, SWT.CHECK);
59
        allowOverrideCommonNameAreaCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
60

  
61
        if (pref != null){
62
            allowOverride = pref.isAllowOverride();
63
            allowOverrideCommonNameAreaCheckButton.setSelection(allowOverride);
64
        }
65
        else{
66
            allowOverrideCommonNameAreaCheckButton.setSelection(true);
67
        }
68

  
69
        allowOverrideCommonNameAreaCheckButton.addSelectionListener(new SelectionAdapter(){
70
            @Override
71
            public void widgetSelected(SelectionEvent e) {
72
                allowOverride = allowOverrideCommonNameAreaCheckButton.getSelection();
73

  
74
            }
75
        });
76

  
77
        return composite;
78
    }
79

  
80
    @Override
81
    public boolean performOk() {
82
        if (pref == null){
83
            return true;
84
        }
85
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
86

  
87
        if(controller!=null){
88
            IPreferenceService service = controller.getPreferenceService();
89

  
90
            CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
91
            if(pref==null){
92
                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameAreaVocabularies, "");
93
            }
94
            pref.setAllowOverride(allowOverride);
95
            service.set(pref);
96

  
97
            PreferencesUtil.updateDBPreferences();
98
        }
99
        return true;
100

  
101
    }
102

  
103

  
104
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/VokabularyAdminPreferences.java
1
/**
2
* Copyright (C) 2018 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.databaseAdmin.preferencePage;
10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13
import org.eclipse.swt.events.SelectionAdapter;
14
import org.eclipse.swt.events.SelectionEvent;
15
import org.eclipse.swt.layout.GridLayout;
16
import org.eclipse.swt.widgets.Button;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
19

  
20
import eu.etaxonomy.cdm.api.application.ICdmRepository;
21
import eu.etaxonomy.cdm.api.service.IPreferenceService;
22
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
23
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
24
import eu.etaxonomy.taxeditor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
27
import eu.etaxonomy.taxeditor.store.CdmStore;
28
import eu.etaxonomy.taxeditor.ui.element.CommandHandlerButton;
29

  
30
/**
31
 * @author k.luther
32
 * @since 05.10.2018
33
 *
34
 */
35
public class VokabularyAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
36

  
37
    boolean allowOverride;
38
    CdmPreference pref = null;
39

  
40
    @Override
41
    protected Control createContents(Composite parent) {
42

  
43
        Composite composite = new Composite(parent, SWT.NULL);
44
        composite.setLayout(new GridLayout());
45

  
46
        pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
47

  
48

  
49
        final CLabel commonNameAreaLabel = new CLabel(composite, SWT.NULL);
50
        commonNameAreaLabel.setText(Messages.VokabularyAdminPreferences_SELECT_VOCABULARY_TEXT);
51

  
52
        final CommandHandlerButton button_opencommonNameAreaWizard = new CommandHandlerButton(composite, SWT.PUSH,
53
                "eu.etaxonomy.taxeditor.store.open.OpenCommonNameAreaWizardAdminHandler"); //$NON-NLS-1$
54

  
55
        button_opencommonNameAreaWizard.setText(Messages.GeneralPreference_open_common_name_area_selection);
56
        final Button allowOverrideCommonNameAreaCheckButton = new Button(composite, SWT.CHECK);
57
        allowOverrideCommonNameAreaCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
58

  
59
        if (pref != null){
60
            allowOverride = pref.isAllowOverride();
61
            allowOverrideCommonNameAreaCheckButton.setSelection(allowOverride);
62
        }
63
        else{
64
            allowOverrideCommonNameAreaCheckButton.setSelection(true);
65
        }
66

  
67
        allowOverrideCommonNameAreaCheckButton.addSelectionListener(new SelectionAdapter(){
68
            @Override
69
            public void widgetSelected(SelectionEvent e) {
70
                allowOverride = allowOverrideCommonNameAreaCheckButton.getSelection();
71

  
72
            }
73
        });
74

  
75
        return composite;
76
    }
77

  
78
    @Override
79
    public boolean performOk() {
80
        if (pref == null){
81
            return true;
82
        }
83
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
84

  
85
        if(controller!=null){
86
            IPreferenceService service = controller.getPreferenceService();
87

  
88
            CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameAreaVocabularies);
89
            if(pref==null){
90
                pref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameAreaVocabularies, "");
91
            }
92
            pref.setAllowOverride(allowOverride);
93
            service.set(pref);
94

  
95
            PreferencesUtil.updateDBPreferences();
96
        }
97
        return true;
98

  
99
    }
100

  
101

  
102
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/DatabasePreferencesWizard.java
56 56

  
57 57
//       getPreferencePage().performOk();
58 58

  
59
        String value =getPreferencePage().doGetPreferenceStore().getString(IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY);
59
        String value =PreferencesUtil.getStringValue(IPreferenceKeys.PREFERRED_NOMENCLATURAL_CODE_KEY);
60 60

  
61
        boolean allowOverride =  getPreferencePage().doGetPreferenceStore().getBoolean(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
61
        boolean allowOverride =  PreferencesUtil.getBooleanValue(IPreferenceKeys.ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY);
62 62
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.NomenclaturalCode, value);
63 63
        pref.setAllowOverride(allowOverride);
64 64

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/wizard/ImportPreferencesWizard.java
10 10

  
11 11
import org.eclipse.jface.wizard.Wizard;
12 12

  
13
import eu.etaxonomy.cdm.api.application.ICdmRepository;
14
import eu.etaxonomy.cdm.api.service.IPreferenceService;
15
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
17 13
import eu.etaxonomy.taxeditor.io.wizard.AbcdImportConfiguratorWizardPage;
18 14
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19
import eu.etaxonomy.taxeditor.store.CdmStore;
20 15

  
21 16
/**
22 17
 * @author k.luther
......
30 25
    public ImportPreferencesWizard() {
31 26
        setWindowTitle("Abcd Import Configuration Wizard");
32 27

  
33
        configPage = AbcdImportConfiguratorWizardPage.createPreferencePage(PreferencesUtil.getAbcdImportConfigurationPreference());
28
        configPage = AbcdImportConfiguratorWizardPage.createPreferencePage(PreferencesUtil.getLocalAbcdImportConfigurator());
34 29

  
35 30
    }
36 31
    @Override
......
44 39
    public boolean performFinish() {
45 40
        String configString = "";
46 41
        this.configPage.saveConfigToPrefernceStore();
47
        configString = this.configPage.createConfigString();
48 42

  
49
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.AbcdImportConfig, configString);
50
        pref.setAllowOverride(true);
51

  
52
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
53
        if (controller == null){
54
            return false;
55
        }
56
        IPreferenceService service = controller.getPreferenceService();
57
        service.set(pref);
58 43

  
59 44

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)