Project

General

Profile

« Previous | Next » 

Revision 59246837

Added by Katja Luther about 4 years ago

ref #6429: add publish flag preference to admin menu

View differences:

eu.etaxonomy.taxeditor.store/plugin.xml
567 567
</extension>
568 568
<extension
569 569
      point="eu.etaxonomy.taxeditor.store.adminPreferencePage">
570
    <page
571
         class="eu.etaxonomy.taxeditor.preference.TaxonomicEditorGeneralPreferences"
570
   <!-- <page
571
         class="eu.etaxonomy.taxeditor.preference.TaxonomicEditorGeneralAdminPreferences"
572 572
         id="eu.etaxonomy.taxeditor.preferences.general"
573 573
         name="%page.name">
574
   </page>  
574
   </page>  -->
575 575
   <page 
576 576
         category="eu.etaxonomy.taxeditor.preferences.general"
577 577
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.ChecklistEditorGeneralPreference"
......
590 590
         id="eu.etaxonomy.taxeditor.store.abcdImportProvider"
591 591
         name="ABCD Import Provider">
592 592
   </page>
593
   <page
594
        
595
         class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.PublishFlagPreference"
596
         id="eu.etaxonomy.taxeditor.preferences.general"
597
         name="Publish Flag Default Behaviour">
598
   </page>
593 599
   
594 600
   <page
595 601
         category="eu.etaxonomy.taxeditor.preferences.general"
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/AbcdImportProvider.java
61 61
    @Override
62 62
    public boolean performOk() {
63 63
        String providerList = null;
64
        providerList = biocaseProviderList.createAllProviderString();
64
        if (biocaseProviderList != null){
65
            providerList = biocaseProviderList.createAllProviderString();
65 66

  
66
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.BioCaseProvider, providerList);
67
        pref.setAllowOverride(true);
67
            CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.BioCaseProvider, providerList);
68
            pref.setAllowOverride(true);
69

  
70
            ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
71
            if (controller == null){
72
                return false;
73
            }
74
            IPreferenceService service = controller.getPreferenceService();
75
            service.set(pref);
68 76

  
69
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
70
        if (controller == null){
71
            return false;
72 77
        }
73
        IPreferenceService service = controller.getPreferenceService();
74
        service.set(pref);
75 78

  
76 79
        return true;
77 80
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/PublishFlagPreference.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.events.SelectionAdapter;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.layout.GridLayout;
15
import org.eclipse.swt.widgets.Button;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Control;
18

  
19
import eu.etaxonomy.cdm.api.application.ICdmRepository;
20
import eu.etaxonomy.cdm.api.service.IPreferenceService;
21
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
22
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
24
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

  
27
/**
28
 * @author k.luther
29
 * @since 23.03.2018
30
 *
31
 */
32
public class PublishFlagPreference extends CdmPreferencePage implements IE4AdminPreferencePage{
33

  
34
   boolean setPublish = true;
35
   boolean setNotPublish = false;
36
   boolean inheritFromParent = false;
37

  
38
   @Override
39
   public void init() {
40
       super.init();
41
       CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag);
42

  
43
   }
44
    /**
45
     * {@inheritDoc}
46
     */
47
    @Override
48
    protected Control createContents(Composite parent) {
49
        final Composite composite = new Composite(parent, SWT.NULL);
50

  
51
        GridLayout gridLayout = new GridLayout();
52
        composite.setLayout(gridLayout);
53

  
54
        gridLayout.numColumns = 1;
55
        gridLayout.horizontalSpacing= 10;
56
        gridLayout.makeColumnsEqualWidth = true;
57

  
58
        Button setPublishFlagAsDefault = new Button(composite, SWT.RADIO);
59
        setPublishFlagAsDefault.setText("Set publish flag");
60
        setPublishFlagAsDefault.setSelection(setPublish);
61
        setPublishFlagAsDefault.addSelectionListener(new SelectionAdapter() {
62
            @Override
63
            public void widgetSelected(SelectionEvent e) {
64
               setPublish = !setPublish;
65
            }
66
        });
67
        Button setNotPublishFlagAsDefault = new Button(composite, SWT.RADIO);
68
        setNotPublishFlagAsDefault.setText("Set no publish flag");
69
        setNotPublishFlagAsDefault.setSelection(setNotPublish);
70
        setNotPublishFlagAsDefault.addSelectionListener(new SelectionAdapter() {
71
            @Override
72
            public void widgetSelected(SelectionEvent e) {
73
                setNotPublish = !setNotPublish;
74
            }
75
        });
76

  
77
        Button setInheritFromParent = new Button(composite, SWT.RADIO);
78
        setInheritFromParent.setText("Inherit publish flag from parent");
79
        setInheritFromParent.setSelection(inheritFromParent);
80
        setInheritFromParent.addSelectionListener(new SelectionAdapter() {
81
            @Override
82
            public void widgetSelected(SelectionEvent e) {
83
                inheritFromParent = !inheritFromParent;
84
            }
85
        });
86

  
87
        return composite;
88

  
89
    }
90

  
91

  
92
    @Override
93
    public boolean performOk() {
94
        String preferenceValue = null;
95
        if (setPublish){
96
            preferenceValue = "setPublish";
97
        }else if (setNotPublish){
98
            preferenceValue = "setNotPublish";
99
        } else{
100
            preferenceValue = "inheritFromParent";
101
        }
102
        CdmPreference pref = CdmPreference.NewDatabaseInstance( PreferencePredicate.DefaultBehaviourForPublishFlag, preferenceValue);
103
        pref.setAllowOverride(true);
104

  
105
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
106
        if (controller == null){
107
            return false;
108
        }
109
        IPreferenceService service = controller.getPreferenceService();
110
        service.set(pref);
111

  
112
        return true;
113
    }
114

  
115

  
116

  
117

  
118
}

Also available in: Unified diff