Project

General

Profile

« Previous | Next » 

Revision 3b975922

Added by Katja Luther over 5 years ago

ref #7793: add DB preferences to hide specimen and import issues and smaller changes in db preferences

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SpecimenAdminPreferences.java
16 16
import org.eclipse.swt.widgets.Button;
17 17
import org.eclipse.swt.widgets.Composite;
18 18
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Label;
19 20

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

  
......
33 35
 *
34 36
 */
35 37
public class SpecimenAdminPreferences extends CdmPreferencePage implements IE4AdminPreferencePage {
38
    public SpecimenAdminPreferences() {
39
    }
36 40

  
37 41

  
38

  
42
    boolean isShowSpecimenRelatedIssues;
39 43
    boolean isShowCollectingAreaInGeneralSection;
40 44
    boolean isDeterminationOnlyForFieldUnits;
41 45
    boolean isShowTaxonAssociation;
42 46
    boolean isShowLifeForm;
43 47
    boolean isUseLocalPreference;
44

  
48
    Composite composite;
45 49

  
46 50
    @Override
47 51
    protected Control createContents(Composite parent) {
48
        Composite composite = new Composite(parent, SWT.NULL);
52

  
49 53
        getValues();
54

  
55

  
56
        final Button showSpecimenButton = new Button(parent, SWT.CHECK);
57

  
58
        showSpecimenButton.setText(Messages.DatabasePreferncesPage_Show_Specimen);
59

  
60
        showSpecimenButton.setSelection(isShowSpecimenRelatedIssues);
61
        showSpecimenButton.addSelectionListener(new SelectionAdapter(){
62
             @Override
63
             public void widgetSelected(SelectionEvent e) {
64
                 isShowSpecimenRelatedIssues = showSpecimenButton.getSelection();
65
                 if(isShowSpecimenRelatedIssues){
66
                     composite.setVisible(true);
67
                     composite.setEnabled(true);
68
                 }else{
69
                     composite.setVisible(false);
70
                     composite.setEnabled(false);
71
                 }
72
              }
73
         });
74
        composite = new Composite(parent, SWT.NULL);
50 75
        GridLayout gridLayout = new GridLayout();
51 76
        composite.setLayout(gridLayout);
77
        composite.setEnabled(isShowSpecimenRelatedIssues);
78
        Label separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
79
        separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
80

  
52 81
        final Button showCollectingAreaInGeneralSectionButton = new Button(composite, SWT.CHECK);
53 82

  
54 83
        showCollectingAreaInGeneralSectionButton.setText(Messages.DatabasePreferncesPage_Show_Collecting_Areas_in_general_section);
......
71 100
             @Override
72 101
             public void widgetSelected(SelectionEvent e) {
73 102
                 isDeterminationOnlyForFieldUnits = determinationOnlyForFieldUnitsButton.getSelection();
74
                               }
103
             }
75 104
         });
76 105

  
77 106
        final Button showTaxonAssociationButton = new Button(composite, SWT.CHECK);
......
134 163
        ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration();
135 164
        if (controller != null){
136 165
            IPreferenceService service = controller.getPreferenceService();
137
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
166
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowSpecimen);
167
            CdmPreference isShowSpecimenPref = service.find(key);
168
            if (isShowSpecimenPref != null){
169
                this.isShowSpecimenRelatedIssues = Boolean.valueOf(isShowSpecimenPref.getValue());
170
            }
171

  
172

  
173
            key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.ShowCollectingAreasInGeneralSection);
138 174
            CdmPreference isShowCollectingAreaInGeneralSectionPref = service.find(key);
139 175
            if (isShowCollectingAreaInGeneralSectionPref != null){
140 176
                this.isShowCollectingAreaInGeneralSection = Boolean.valueOf(isShowCollectingAreaInGeneralSectionPref.getValue());
......
185 221
            pref = CdmPreference.NewDatabaseInstance(PreferencePredicate.ShowLifeForm, Boolean.toString(this.isShowLifeForm));
186 222
            pref.setAllowOverride(isUseLocalPreference);
187 223
            service.set(pref);
224
            PreferencesUtil.updateDBPreferences();
188 225

  
189 226

  
190 227
        }

Also available in: Unified diff