KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > preferences > SpellingPreferencePage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.preferences;
13
14 import org.eclipse.core.runtime.IStatus;
15
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Control;
18
19 import org.eclipse.jface.dialogs.Dialog;
20 import org.eclipse.jface.preference.PreferencePage;
21
22 import org.eclipse.ui.IWorkbench;
23 import org.eclipse.ui.IWorkbenchPreferencePage;
24 import org.eclipse.ui.help.WorkbenchHelp;
25
26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27 import org.eclipse.jdt.internal.ui.JavaPlugin;
28 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
29 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
30
31 /**
32  * Preference page for spell checking preferences.
33  *
34  * @since 3.0
35  */

36 public class SpellingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener {
37
38     /** The spelling configuration block */
39     private final SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(this, null);
40
41     /**
42      * Creates a new spelling preference page.
43      */

44     public SpellingPreferencePage() {
45
46         setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
47         setDescription(PreferencesMessages.getString("SpellingPreferencePage.description")); //$NON-NLS-1$
48
setTitle(PreferencesMessages.getString("SpellingPreferencePage.title")); //$NON-NLS-1$
49
}
50
51     /*
52      * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
53      */

54     protected Control createContents(final Composite parent) {
55
56         final Control control= fBlock.createContents(parent);
57         Dialog.applyDialogFont(control);
58
59         return control;
60     }
61
62     /*
63      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
64      */

65     public void createControl(final Composite parent) {
66         super.createControl(parent);
67         WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
68     }
69
70     /*
71      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
72      */

73     public void init(final IWorkbench workbench) {
74         // Do nothing
75
}
76
77     /*
78      * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
79      */

80     protected void performDefaults() {
81         fBlock.performDefaults();
82
83         super.performDefaults();
84     }
85
86     /*
87      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
88      */

89     public boolean performOk() {
90
91         if (!fBlock.performOk(true))
92             return false;
93
94         return super.performOk();
95     }
96
97     /*
98      * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
99      */

100     public void statusChanged(final IStatus status) {
101         setValid(!status.matches(IStatus.ERROR));
102
103         StatusUtil.applyToStatusLine(this, status);
104     }
105 }
106
Popular Tags