2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.databaseAdmin
.preferencePage
;
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
;
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
.CdmPreference
.PrefKey
;
23 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferencePredicate
;
24 import eu
.etaxonomy
.cdm
.model
.metadata
.PreferenceSubject
;
25 import eu
.etaxonomy
.taxeditor
.l10n
.Messages
;
26 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
27 import eu
.etaxonomy
.taxeditor
.preference
.menu
.CdmPreferencePage
;
28 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
35 public class GeneralAdminPreferencePage
extends CdmPreferencePage
implements IE4AdminPreferencePage
{
38 boolean isShowIOMenu
= true;
39 boolean isShowMediaView
= true;
40 boolean isShowCheckListPerspective
= false;
41 boolean isShowTaxonNodeWizard
= true;
46 protected Control
createContents(Composite parent
) {
47 final Composite composite
= new Composite(parent
, SWT
.NULL
);
49 GridLayout gridLayout
= new GridLayout();
50 composite
.setLayout(gridLayout
);
51 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
52 if (controller
!= null){
53 IPreferenceService service
= controller
.getPreferenceService();
54 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowImportExportMenu
);
55 CdmPreference isShowSpecimenPref
= service
.find(key
);
56 if (isShowSpecimenPref
!= null){
57 this.isShowIOMenu
= Boolean
.valueOf(isShowSpecimenPref
.getValue());
60 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowMediaView
);
61 CdmPreference isShowMediaViewPref
= service
.find(key
);
62 if (isShowMediaViewPref
!= null){
63 this.isShowMediaView
= Boolean
.valueOf(isShowMediaViewPref
.getValue());
66 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowChecklistPerspective
);
67 CdmPreference isShowChecklistPref
= service
.find(key
);
68 if (isShowChecklistPref
!= null){
69 this.isShowCheckListPerspective
= Boolean
.valueOf(isShowChecklistPref
.getValue());
72 key
= CdmPreference
.NewKey(PreferenceSubject
.NewDatabaseInstance(), PreferencePredicate
.ShowTaxonNodeWizard
);
73 CdmPreference isShowTaxonNodeWizardPref
= service
.find(key
);
74 if (isShowTaxonNodeWizardPref
!= null){
75 this.isShowTaxonNodeWizard
= Boolean
.valueOf(isShowTaxonNodeWizardPref
.getValue());
78 final Button showIOMenuButton
= new Button(composite
, SWT
.CHECK
);
80 showIOMenuButton
.setText(Messages
.DatabasePreferncesPage_Show_IOMenu
);
82 showIOMenuButton
.setSelection(isShowIOMenu
);
83 showIOMenuButton
.addSelectionListener(new SelectionAdapter(){
85 public void widgetSelected(SelectionEvent e
) {
86 isShowIOMenu
= showIOMenuButton
.getSelection();
91 final Button showMediaViewButton
= new Button(composite
, SWT
.CHECK
);
93 showMediaViewButton
.setText(Messages
.DatabasePreferncesPage_Show_MediaView
);
95 showMediaViewButton
.setSelection(isShowMediaView
);
96 showMediaViewButton
.addSelectionListener(new SelectionAdapter(){
98 public void widgetSelected(SelectionEvent e
) {
99 isShowMediaView
= showIOMenuButton
.getSelection();
103 final Button showChecklistPerspectiveButton
= new Button(composite
, SWT
.CHECK
);
105 showChecklistPerspectiveButton
.setText(Messages
.DatabasePreferncesPage_Show_ChecklistPerspective
);
107 showChecklistPerspectiveButton
.setSelection(isShowCheckListPerspective
);
108 showChecklistPerspectiveButton
.addSelectionListener(new SelectionAdapter(){
110 public void widgetSelected(SelectionEvent e
) {
111 isShowCheckListPerspective
= showChecklistPerspectiveButton
.getSelection();
116 final Button showTaxonNodeWizardButton
= new Button(composite
, SWT
.CHECK
);
118 showTaxonNodeWizardButton
.setText(Messages
.DatabasePreferncesPage_Show_TaxonNodeWizard
);
120 showTaxonNodeWizardButton
.setSelection(isShowTaxonNodeWizard
);
121 showTaxonNodeWizardButton
.addSelectionListener(new SelectionAdapter(){
123 public void widgetSelected(SelectionEvent e
) {
124 isShowTaxonNodeWizard
= showTaxonNodeWizardButton
.getSelection();
133 public void createControl(Composite parent
){
134 super.createControl(parent
);
135 getControl().setVisible(false);
139 public boolean performOk() {
140 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
141 if (controller
!= null){
142 IPreferenceService service
= controller
.getPreferenceService();
144 CdmPreference pref
= CdmPreference
.NewDatabaseInstance(PreferencePredicate
.ShowImportExportMenu
, Boolean
.toString(this.isShowIOMenu
));
145 pref
.setAllowOverride(false);
147 pref
= CdmPreference
.NewDatabaseInstance(PreferencePredicate
.ShowMediaView
, Boolean
.toString(this.isShowMediaView
));
148 pref
.setAllowOverride(false);
150 pref
= CdmPreference
.NewDatabaseInstance(PreferencePredicate
.ShowChecklistPerspective
, Boolean
.toString(this.isShowCheckListPerspective
));
151 pref
.setAllowOverride(false);
153 pref
= CdmPreference
.NewDatabaseInstance(PreferencePredicate
.ShowTaxonNodeWizard
, Boolean
.toString(this.isShowTaxonNodeWizard
));
154 pref
.setAllowOverride(false);
156 PreferencesUtil
.updateDBPreferences();