KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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.IAdaptable;
14
15 import org.eclipse.core.resources.IProject;
16
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
22
23 import org.eclipse.jdt.launching.JavaRuntime;
24
25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26 import org.eclipse.jdt.internal.ui.JavaPlugin;
27
28 /**
29  * Page used to configure both workspace and project specific compiler settings
30  */

31 public class CompliancePreferencePage extends PropertyAndPreferencePage {
32
33     public static final String JavaDoc PREF_ID= "org.eclipse.jdt.ui.preferences.CompliancePreferencePage"; //$NON-NLS-1$
34
public static final String JavaDoc PROP_ID= "org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
35

36     private ComplianceConfigurationBlock fConfigurationBlock;
37
38     public CompliancePreferencePage() {
39         setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
40         //setDescription(PreferencesMessages.CompliancePreferencePage_description);
41

42         // only used when page is shown programatically
43
setTitle(PreferencesMessages.CompliancePreferencePage_title);
44         
45         JavaRuntime.getDefaultVMInstall(); // make sure the default JRE is detected (bug 152384)
46
}
47
48     /*
49      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
50      */

51     public void createControl(Composite parent) {
52         IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
53         fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
54         
55         super.createControl(parent);
56         if (isProjectPreferencePage()) {
57             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
58         } else {
59             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
60         }
61     }
62
63     protected Control createPreferenceContent(Composite composite) {
64         return fConfigurationBlock.createContents(composite);
65     }
66     
67     protected boolean hasProjectSpecificOptions(IProject project) {
68         return fConfigurationBlock.hasProjectSpecificOptions(project);
69     }
70     
71     /* (non-Javadoc)
72      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
73      */

74     protected String JavaDoc getPreferencePageID() {
75         return PREF_ID;
76     }
77     
78     /* (non-Javadoc)
79      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
80      */

81     protected String JavaDoc getPropertyPageID() {
82         return PROP_ID;
83     }
84     
85     /* (non-Javadoc)
86      * @see org.eclipse.jface.dialogs.DialogPage#dispose()
87      */

88     public void dispose() {
89         if (fConfigurationBlock != null) {
90             fConfigurationBlock.dispose();
91         }
92         super.dispose();
93     }
94     
95     /* (non-Javadoc)
96      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
97      */

98     protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
99         super.enableProjectSpecificSettings(useProjectSpecificSettings);
100         if (fConfigurationBlock != null) {
101             fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
102         }
103     }
104     
105     /* (non-Javadoc)
106      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean)
107      */

108     protected void enablePreferenceContent(boolean enable) {
109         if (fConfigurationBlock != null) {
110             fConfigurationBlock.enablePreferenceContent(enable);
111         }
112     }
113     
114     /*
115      * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
116      */

117     protected void performDefaults() {
118         super.performDefaults();
119         if (fConfigurationBlock != null) {
120             fConfigurationBlock.performDefaults();
121         }
122     }
123
124     /*
125      * @see org.eclipse.jface.preference.IPreferencePage#performOk()
126      */

127     public boolean performOk() {
128         if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
129             return false;
130         }
131         return super.performOk();
132     }
133     
134     /*
135      * @see org.eclipse.jface.preference.IPreferencePage#performApply()
136      */

137     public void performApply() {
138         if (fConfigurationBlock != null) {
139             fConfigurationBlock.performApply();
140         }
141     }
142     
143     /* (non-Javadoc)
144      * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
145      */

146     public void setElement(IAdaptable element) {
147         super.setElement(element);
148         setDescription(null); // no description for property page
149
}
150     
151 }
152
Popular Tags