KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.jdt.internal.ui.preferences;
12
13 import org.eclipse.core.runtime.IStatus;
14
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.swt.widgets.Control;
17
18 import org.eclipse.jface.dialogs.Dialog;
19 import org.eclipse.jface.preference.PreferencePage;
20
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.help.WorkbenchHelp;
24
25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26 import org.eclipse.jdt.internal.ui.JavaPlugin;
27 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
28 import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
29
30 /*
31  * The page to configure the compiler options.
32  */

33 public class CompilerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IStatusChangeListener {
34
35     private CompilerConfigurationBlock fConfigurationBlock;
36
37     public CompilerPreferencePage() {
38         setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
39         setDescription(PreferencesMessages.getString("CompilerPreferencePage.description")); //$NON-NLS-1$
40

41         // only used when page is shown programatically
42
setTitle(PreferencesMessages.getString("CompilerPreferencePage.title")); //$NON-NLS-1$
43

44         fConfigurationBlock= new CompilerConfigurationBlock(this, null);
45     }
46         
47     /*
48      * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
49      */

50     public void init(IWorkbench workbench) {
51     }
52
53     /*
54      * @see PreferencePage#createControl(Composite)
55      */

56     public void createControl(Composite parent) {
57         super.createControl(parent);
58         WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
59     }
60
61     /*
62      * @see PreferencePage#createContents(Composite)
63      */

64     protected Control createContents(Composite parent) {
65         Control result= fConfigurationBlock.createContents(parent);
66         Dialog.applyDialogFont(result);
67         return result;
68     }
69
70     /*
71      * @see IPreferencePage#performOk()
72      */

73     public boolean performOk() {
74         if (!fConfigurationBlock.performOk(true)) {
75             return false;
76         }
77         return super.performOk();
78     }
79     
80     /*
81      * @see PreferencePage#performDefaults()
82      */

83     protected void performDefaults() {
84         fConfigurationBlock.performDefaults();
85         super.performDefaults();
86     }
87     
88     /* (non-Javadoc)
89      * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
90      */

91     public void statusChanged(IStatus status) {
92         setValid(!status.matches(IStatus.ERROR));
93         StatusUtil.applyToStatusLine(this, status);
94     }
95
96 }
97
Popular Tags