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
.preference
;
11 import org
.eclipse
.jface
.preference
.PreferencePage
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.custom
.CLabel
;
14 import org
.eclipse
.swt
.events
.SelectionAdapter
;
15 import org
.eclipse
.swt
.events
.SelectionEvent
;
16 import org
.eclipse
.swt
.layout
.GridLayout
;
17 import org
.eclipse
.swt
.widgets
.Button
;
18 import org
.eclipse
.swt
.widgets
.Composite
;
19 import org
.eclipse
.swt
.widgets
.Control
;
20 import org
.eclipse
.ui
.IWorkbench
;
21 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CommandHandlerButton
;
31 public class ChecklistEditorGeneralPreference
extends PreferencePage
implements IWorkbenchPreferencePage
{
33 boolean isEditorActivated
;
39 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
43 protected Control
createContents(Composite parent
) {
45 Composite composite
= new Composite(parent
, SWT
.NULL
);
46 composite
.setLayout(new GridLayout());
47 isEditorActivated
= PreferencesUtil
.getPreferenceStore().getBoolean(IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
);
48 final Button activateCheckButton
= new Button(composite
, SWT
.CHECK
);
49 activateCheckButton
.setText("Enable Distribution Editor");
50 activateCheckButton
.setSelection(isEditorActivated
);
51 activateCheckButton
.addSelectionListener(new SelectionAdapter(){
53 public void widgetSelected(SelectionEvent e
) {
54 isEditorActivated
= activateCheckButton
.getSelection();
55 PreferencesUtil
.getPreferenceStore().setValue(IPreferenceKeys
.DISTRIBUTION_AREA_PREFRENCES_ACTIVE
, isEditorActivated
);
56 if(isEditorActivated
){
57 child
.setVisible(true);
58 child
.setEnabled(true);
60 child
.setVisible(false);
61 child
.setEnabled(false);
67 child
= new Composite(composite
, SWT
.NULL
);
68 child
.setLayout(new GridLayout());
69 child
.setVisible(isEditorActivated
);
70 final CLabel label
= new CLabel(child
, SWT
.NULL
);
71 label
.setText("Please open the wizard below, in order to \n" + "choose the areas for the Distribution Editor");
72 final CommandHandlerButton button_openFeatureTree
= new CommandHandlerButton(child
, SWT
.PUSH
,
73 "eu.etaxonomy.taxeditor.store.open.OpenDistributionEditorWizardHandler");
75 button_openFeatureTree
.setText("Open Distribution Selection Wizard");
76 final Button showIdInVocabulary
= new Button(child
, SWT
.CHECK
);
77 boolean isShowIdInVocabulary
= PreferencesUtil
.isShowIdInVocabularyInChecklistEditor();
78 showIdInVocabulary
.setText("Show Id in Vocabulary instead of full title of the areas");
79 showIdInVocabulary
.setSelection(isShowIdInVocabulary
);
80 showIdInVocabulary
.addSelectionListener(new SelectionAdapter(){
82 public void widgetSelected(SelectionEvent e
) {
83 boolean isShowIdInVocabulary
= showIdInVocabulary
.getSelection();
84 PreferencesUtil
.setShowIdInVocabularyInChecklistEditor(isShowIdInVocabulary
);
87 PreferencesUtil
.recursiveSetEnabled(button_openFeatureTree
, CdmStore
.isActive());
88 boolean isShowRank
= PreferencesUtil
.isShowRankInChecklistEditor();
89 final Button activateRankButton
= new Button(child
, SWT
.CHECK
);
90 activateRankButton
.setText("Show Rank in Distribution Editor");
91 activateRankButton
.setSelection(isShowRank
);
92 activateRankButton
.addSelectionListener(new SelectionAdapter(){
94 public void widgetSelected(SelectionEvent e
) {
95 boolean isShowRank
= activateRankButton
.getSelection();
96 PreferencesUtil
.setShowRankInChecklistEditor(isShowRank
);
101 if(isEditorActivated
){
102 child
.setEnabled(true);
104 child
.setEnabled(false);
114 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
117 public void init(IWorkbench workbench
) {