2 * Copyright (C) 2014 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
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Control
;
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
;
27 public class ChecklistEditorGeneralAdminPreference
extends ChecklistEditorGeneralPreference
implements IE4AdminPreferencePage
{
34 protected Control
createContents(Composite parent
) {
36 // allowOverride = distributionPref.isAllowOverride();
38 // final Button allowOverrideCheckButton = new Button(parent, SWT.CHECK);
39 // allowOverrideCheckButton.setText(Messages.ChecklistEditorGeneralPreference_allowOverride);
40 // allowOverrideCheckButton.setSelection(allowOverride);
41 // allowOverrideCheckButton.addSelectionListener(new SelectionAdapter(){
43 // public void widgetSelected(SelectionEvent e) {
44 // allowOverride = allowOverrideCheckButton.getSelection();
48 return super.createContents(parent
);
50 // final Button activateCheckButton = new Button(composite, SWT.CHECK);
51 // activateCheckButton.setText(Messages.ChecklistEditorGeneralPreference_enable);
52 // activateCheckButton.setSelection(isEditorActivated);
53 // activateCheckButton.addSelectionListener(new SelectionAdapter(){
55 // public void widgetSelected(SelectionEvent e) {
56 // isEditorActivated = activateCheckButton.getSelection();
58 // if(isEditorActivated){
59 // child.setVisible(true);
60 // child.setEnabled(true);
62 // child.setVisible(false);
63 // child.setEnabled(false);
69 // child = new Composite(composite, SWT.NULL);
70 // child.setLayout(new GridLayout());
71 // child.setVisible(isEditorActivated);
79 //// final CommandHandlerButton button_openWizard = new CommandHandlerButton(child, SWT.PUSH,
80 //// "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler");
82 //// button_openWizard.setText(Messages.ChecklistEditorGeneralPreference_open_distribution_selection);
84 //// Table table = new Table
85 // final CLabel description = new CLabel(child, SWT.NULL);
86 // description.setText(Messages.ChecklistEditorGeneralPreference_Configure_display_of_Areas);
89 // GridData gridData = new GridData();
90 // gridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
91 // gridData.horizontalIndent = 5;
92 //// classificationSelection.setLayoutData(gridData);
95 // final Button showIdInVocabulary = new Button(child, SWT.RADIO);
96 // CdmPreference pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInVocabulary);
98 // isShowIdInVocabulary = Boolean.valueOf(pref.getValue());
100 // isShowIdInVocabulary = false;
102 // showIdInVocabulary.setText(Messages.ChecklistEditorGeneralPreference_show_id_in_voc);
103 // showIdInVocabulary.setSelection(isShowIdInVocabulary);
104 // showIdInVocabulary.addSelectionListener(new SelectionAdapter(){
106 // public void widgetSelected(SelectionEvent e) {
107 // isShowIdInVocabulary = showIdInVocabulary.getSelection();
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());
116 // isShowSymbol1 = false;
118 // showSymbol1.setText(Messages.ChecklistEditorGeneralPreference_show_symbol1);
119 // showSymbol1.setSelection(isShowSymbol1);
120 // showSymbol1.addSelectionListener(new SelectionAdapter(){
122 // public void widgetSelected(SelectionEvent e) {
123 // isShowSymbol1 = showSymbol1.getSelection();
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());
132 // isShowSymbol2 = false;
134 // showSymbol2.setText(Messages.ChecklistEditorGeneralPreference_show_symbol2);
135 // showSymbol2.setSelection(isShowSymbol2);
136 // showSymbol2.addSelectionListener(new SelectionAdapter(){
138 // public void widgetSelected(SelectionEvent e) {
139 // isShowSymbol2 = showSymbol2.getSelection();
143 // final Button showTitle = new Button(child, SWT.RADIO);
144 // isShowTitle = !(isShowIdInVocabulary || isShowSymbol1 || isShowSymbol2);
146 // showTitle.setText(Messages.ChecklistEditorGeneralPreference_show_title);
147 // showTitle.setSelection(isShowTitle);
148 // showTitle.addSelectionListener(new SelectionAdapter(){
150 // public void widgetSelected(SelectionEvent e) {
151 // isShowTitle = showTitle.getSelection();
156 // final Label seperator1 = new Label(child, SWT.HORIZONTAL | SWT.SEPARATOR);
157 // final Button sortNamedAreaByVocabularyOrder = new Button(child, SWT.CHECK);
159 // pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.AreasSortedByIdInVocabulary);
160 // if (pref != null){
161 // isSortByVocabularyOrder = Boolean.valueOf(pref.getValue());
163 // isSortByVocabularyOrder = false;
166 // sortNamedAreaByVocabularyOrder.setText(Messages.ChecklistEditorGeneralPreference_sort_areas);
167 // sortNamedAreaByVocabularyOrder.setSelection(isSortByVocabularyOrder);
168 // sortNamedAreaByVocabularyOrder.addSelectionListener(new SelectionAdapter(){
170 // public void widgetSelected(SelectionEvent e) {
171 // isSortByVocabularyOrder = sortNamedAreaByVocabularyOrder.getSelection();
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());
182 // isShowSymbol = false;
185 // showSymbol.setText(Messages.ChecklistEditorGeneralPreference_show_symbol);
186 // showSymbol.setSelection(isShowSymbol);
187 // showSymbol.addSelectionListener(new SelectionAdapter(){
189 // public void widgetSelected(SelectionEvent e) {
190 // isShowSymbol = showSymbol.getSelection();
193 //// PreferencesUtil.recursiveSetEnabled(button_openWizard, CdmStore.isActive());
194 // pref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowRankInDistributionEditor);
195 // if (pref != null){
196 // isShowRank = Boolean.valueOf(pref.getValue());
198 // isShowRank = false;
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(){
206 // public void widgetSelected(SelectionEvent e) {
207 // isShowRank = activateRankButton.getSelection();
212 // if(isEditorActivated){
213 // child.setEnabled(true);
215 // child.setEnabled(false);
222 public boolean performOk() {
226 ICdmRepository controller
= CdmStore
.getCurrentApplicationConfiguration();
227 if (controller
== null){
230 IPreferenceService service
= controller
.getPreferenceService();
232 CdmPreference pref
= CdmPreference
.NewTaxEditorInstance( EditorPreferencePredicate
.DistributionEditorActivated
, Boolean
.toString(isEditorActivated
));
234 pref
.setAllowOverride(this.allowOverrideActivated
);
237 pref
= CdmPreference
.NewTaxEditorInstance( EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
, this.displayArea
);
239 pref
.setAllowOverride(this.allowOverrideAreaDisplay
);
244 pref
= CdmPreference
.NewTaxEditorInstance( EditorPreferencePredicate
.DisplayOfStatus
, this.displayStatus
);
246 pref
.setAllowOverride(this.allowOverrideStatusDisplay
);
249 pref
= CdmPreference
.NewTaxEditorInstance( EditorPreferencePredicate
.ShowRankInDistributionEditor
, Boolean
.toString(isShowRank
));
251 pref
.setAllowOverride(this.allowOverrideRank
);
253 pref
= CdmPreference
.NewTaxEditorInstance( EditorPreferencePredicate
.AreasSortedByIdInVocabulary
, Boolean
.toString(isSortByVocabularyOrder
));
255 pref
.setAllowOverride(this.allowOverrideOrderAreas
);
259 PreferencesUtil
.updateDBPreferences();
266 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
267 distributionEditorPref
= PreferencesUtil
.getPreferenceFromDB(EditorPreferencePredicate
.DistributionEditorActivated
);
268 if (distributionEditorPref
== null){
269 distributionEditorPref
= CdmPreference
.NewTaxEditorInstance(EditorPreferencePredicate
.DistributionEditorActivated
, EditorPreferencePredicate
.DistributionEditorActivated
.getDefaultValue().toString());
271 isEditorActivated
= Boolean
.valueOf(distributionEditorPref
.getValue());
272 allowOverrideActivated
= distributionEditorPref
.isAllowOverride();
273 isAdminPreference
= true;
275 CdmPreference pref
= PreferencesUtil
.getPreferenceFromDB(EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
);
277 this.displayArea
= pref
.getValue();
278 this.allowOverrideAreaDisplay
= pref
.isAllowOverride();
280 this.displayArea
= EditorPreferencePredicate
.DisplayOfAreasInDistributionEditor
.getDefaultValue().toString();
281 this.allowOverrideAreaDisplay
= true;
284 pref
= PreferencesUtil
.getPreferenceFromDB(EditorPreferencePredicate
.DisplayOfStatus
);
286 this.displayStatus
= pref
.getValue();
287 this.allowOverrideStatusDisplay
= pref
.isAllowOverride();
289 this.displayStatus
= EditorPreferencePredicate
.DisplayOfStatus
.getDefaultValue().toString();
290 this.allowOverrideStatusDisplay
= true;
293 pref
= PreferencesUtil
.getPreferenceFromDB(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
);
295 this.isSortByVocabularyOrder
= Boolean
.valueOf(pref
.getValue().toString());
296 this.allowOverrideOrderAreas
= pref
.isAllowOverride();
298 this.isSortByVocabularyOrder
= Boolean
.valueOf(EditorPreferencePredicate
.AreasSortedByIdInVocabulary
.getDefaultValue().toString());
299 this.allowOverrideOrderAreas
= true;
302 pref
= PreferencesUtil
.getPreferenceFromDB(EditorPreferencePredicate
.ShowRankInDistributionEditor
);
304 this.isShowRank
= Boolean
.valueOf(pref
.getValue().toString());
305 this.allowOverrideRank
= pref
.isAllowOverride();
307 this.isShowRank
= Boolean
.valueOf(EditorPreferencePredicate
.ShowRankInDistributionEditor
.getDefaultValue().toString());
308 this.allowOverrideRank
= true;
310 commandHandlerString
= "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardAdminHandler";
311 commandHandlerStringStatus
= "eu.etaxonomy.taxeditor.store.open.OpenDistributionStatusWizardAdminHandler";