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
.preference
;
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
;
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
.menu
.CdmPreferencePage
;
26 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 import eu
.etaxonomy
.taxeditor
.ui
.element
.CommandHandlerButton
;
34 public class CommonNameVocabularySelection
extends CdmPreferencePage
implements IE4PreferencePage
{
36 boolean allowOverride
;
37 CdmPreference pref
= null;
40 protected Control
createContents(Composite parent
) {
42 Composite composite
= createComposite(parent
);
46 final CLabel commonNameAreaLabel
= new CLabel(composite
, SWT
.NULL
);
47 commonNameAreaLabel
.setText(Messages
.VokabularyAdminPreferences_SELECT_VOCABULARY_TEXT
);
49 GridData gridData
= new GridData();
50 gridData
.horizontalSpan
= 2;
51 commonNameAreaLabel
.setLayoutData(gridData
);
53 final CommandHandlerButton button_opencommonNameAreaWizard
= new CommandHandlerButton(composite
, SWT
.PUSH
,
54 "eu.etaxonomy.taxeditor.store.open.OpenCommonNameAreaWizardHandler"); //$NON-NLS-1$
56 button_opencommonNameAreaWizard
.setText(Messages
.GeneralPreference_open_common_name_area_selection
);
57 final Button allowOverrideCommonNameAreaCheckButton
= createAllowOverrideButton(composite
);
60 allowOverride
= pref
.isAllowOverride();
61 allowOverrideCommonNameAreaCheckButton
.setSelection(allowOverride
);
64 allowOverrideCommonNameAreaCheckButton
.setSelection(true);
67 allowOverrideCommonNameAreaCheckButton
.addSelectionListener(new SelectionAdapter(){
69 public void widgetSelected(SelectionEvent e
) {
71 allowOverride
= allowOverrideCommonNameAreaCheckButton
.getSelection();
80 public boolean performOk() {
84 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
87 IPreferenceService service
= controller
.getPreferenceService();
89 CdmPreference pref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.CommonNameAreaVocabularies
);
91 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameAreaVocabularies
, "");
93 pref
.setAllowOverride(allowOverride
);
96 PreferencesUtil
.updateDBPreferences();
103 public void getValues() {
104 this.isAdminPreference
= false;
105 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
106 pref
= PreferencesUtil
.getPreferenceFromDB(PreferencePredicate
.CommonNameAreaVocabularies
);
110 allowOverride
= pref
.isAllowOverride();
112 pref
= CdmPreference
.NewTaxEditorInstance(PreferencePredicate
.CommonNameAreaVocabularies
, "");
113 allowOverride
= true;
118 protected void performDefaults() {
120 super.performDefaults();