3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.preference
;
13 import org
.eclipse
.jface
.preference
.PreferencePage
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.custom
.CLabel
;
16 import org
.eclipse
.swt
.events
.ModifyEvent
;
17 import org
.eclipse
.swt
.events
.ModifyListener
;
18 import org
.eclipse
.swt
.events
.SelectionAdapter
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.layout
.GridData
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.layout
.RowLayout
;
23 import org
.eclipse
.swt
.widgets
.Button
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.Control
;
26 import org
.eclipse
.swt
.widgets
.Text
;
27 import org
.eclipse
.ui
.IWorkbench
;
28 import org
.eclipse
.ui
.IWorkbenchPreferencePage
;
31 * <p>TaxonomicEditorGeneralPreferences class.</p>
34 * @created Sep 1, 2009
37 public class TaxonomicEditorGeneralPreferences
extends PreferencePage
implements
38 IWorkbenchPreferencePage
{
40 boolean showUuidInSupplementalView
;
42 private String editMapServiceAccessPoint
;
44 private boolean shouldConnectAtStartup
;
46 private boolean shouldExpandSectionWhenDataAvailable
;
48 private boolean shouldShowExperimentalFeatures
;
52 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
56 protected Control
createContents(Composite parent
) {
57 Composite container
= new Composite(parent
, SWT
.NULL
);
58 final GridLayout gridLayout
= new GridLayout();
59 container
.setLayout(gridLayout
);
61 createShowUuidInSupplementalView(container
);
62 createMapServiceAccessPoint(container
);
63 createShouldConnectAtStartUp(container
);
64 createShouldExpandSectionWhenDataAvailable(container
);
66 createShowExperimentalFeatures(container
);
72 private void createShouldExpandSectionWhenDataAvailable(Composite container
) {
73 shouldExpandSectionWhenDataAvailable
= getPreferenceStore().getBoolean(IPreferenceKeys
.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE
);
75 final Composite composite
= createComposite(container
);
77 final Button button
= new Button(composite
, SWT
.CHECK
);
78 button
.setText("Should expand sections when data is available (Details View)");
80 button
.setSelection(shouldExpandSectionWhenDataAvailable
);
82 button
.addSelectionListener(new SelectionAdapter(){
84 public void widgetSelected(SelectionEvent e
) {
85 shouldExpandSectionWhenDataAvailable
= button
.getSelection();
91 private void createMapServiceAccessPoint(Composite composite
) {
92 editMapServiceAccessPoint
= PreferencesUtil
.getMapServiceAccessPoint();
94 // Composite composite = createComposite(parent);
96 final CLabel label
= new CLabel(composite
, SWT
.NULL
);
97 label
.setText("EDIT Map Service Access Point:");
99 final Text text
= new Text(composite
, SWT
.BORDER
);
100 text
.setText(editMapServiceAccessPoint
);
101 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false));
103 text
.addModifyListener(new ModifyListener() {
105 public void modifyText(ModifyEvent e
) {
106 editMapServiceAccessPoint
= text
.getText();
113 private void createShowUuidInSupplementalView(Composite parent
){
114 showUuidInSupplementalView
= getPreferenceStore().getBoolean(PreferencesUtil
.SHOW_DEBUG_INFORMATION
);
116 final Composite composite
= createComposite(parent
);
118 final Button button_toggle
= new Button(composite
, SWT
.CHECK
);
121 button_toggle
.setText("Show UUID and object ID in supplemental data view.");
123 button_toggle
.setSelection(showUuidInSupplementalView
);
126 button_toggle
.addSelectionListener(new SelectionAdapter(){
128 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
131 public void widgetSelected(SelectionEvent e
) {
132 showUuidInSupplementalView
= button_toggle
.getSelection();
138 private void createShouldConnectAtStartUp(Composite parent
){
139 shouldConnectAtStartup
= getPreferenceStore().getBoolean(IPreferenceKeys
.SHOULD_CONNECT_AT_STARTUP
);
141 final Composite composite
= createComposite(parent
);
143 final Button button_toggle
= new Button(composite
, SWT
.CHECK
);
146 button_toggle
.setText("Connect to last used datasource when launching.");
148 button_toggle
.setSelection(shouldConnectAtStartup
);
151 button_toggle
.addSelectionListener(new SelectionAdapter(){
153 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
156 public void widgetSelected(SelectionEvent e
) {
157 shouldConnectAtStartup
= button_toggle
.getSelection();
165 private void createShowExperimentalFeatures(Composite parent
) {
166 shouldShowExperimentalFeatures
= getPreferenceStore().getBoolean(IPreferenceKeys
.SHOW_EXPERIMENTAL_FEATURES
);
167 final Composite composite
= createComposite(parent
);
169 final Button button_toggle
= new Button(composite
, SWT
.CHECK
);
172 button_toggle
.setText("Show experimental features-");
174 button_toggle
.setSelection(shouldShowExperimentalFeatures
);
177 button_toggle
.addSelectionListener(new SelectionAdapter(){
179 * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
182 public void widgetSelected(SelectionEvent e
) {
183 shouldShowExperimentalFeatures
= button_toggle
.getSelection();
188 private Composite
createComposite(Composite parent
){
189 Composite composite
= new Composite(parent
, SWT
.NULL
);
190 composite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.TOP
, true, false, 2, 1));
191 composite
.setLayout(new RowLayout(SWT
.HORIZONTAL
));
196 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
199 public void init(IWorkbench workbench
) {
200 setPreferenceStore(PreferencesUtil
.getPreferenceStore());
205 public boolean performOk() {
207 getPreferenceStore().setValue(IPreferenceKeys
.SHOW_DEBUG_INFORMATION
, showUuidInSupplementalView
);
208 getPreferenceStore().setValue(IPreferenceKeys
.EDIT_MAP_SERVICE_ACCES_POINT
, editMapServiceAccessPoint
);
209 getPreferenceStore().setValue(IPreferenceKeys
.SHOULD_CONNECT_AT_STARTUP
, shouldConnectAtStartup
);
210 getPreferenceStore().setValue(IPreferenceKeys
.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE
, shouldExpandSectionWhenDataAvailable
);
211 getPreferenceStore().setValue(IPreferenceKeys
.SHOW_EXPERIMENTAL_FEATURES
, shouldShowExperimentalFeatures
);
213 return super.performOk();