1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.preferences;
13 import org.eclipse.swt.widgets.Composite;
14 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.core.resources.IProject;
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
23 import org.eclipse.jdt.launching.JavaRuntime;
25 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
26 import org.eclipse.jdt.internal.ui.JavaPlugin;
29 * Page used to configure both workspace and project specific compiler settings
31 public class CompliancePreferencePage extends PropertyAndPreferencePage {
33 public static final String PREF_ID= "org.eclipse.jdt.ui.preferences.CompliancePreferencePage"; //$NON-NLS-1$
34 public static final String PROP_ID= "org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
36 private ComplianceConfigurationBlock fConfigurationBlock;
38 public CompliancePreferencePage() {
39 setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
40 //setDescription(PreferencesMessages.CompliancePreferencePage_description);
42 // only used when page is shown programatically
43 setTitle(PreferencesMessages.CompliancePreferencePage_title);
45 JavaRuntime.getDefaultVMInstall(); // make sure the default JRE is detected (bug 152384)
49 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
52 public void createControl(Composite parent) {
53 IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
54 fConfigurationBlock= new ComplianceConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
56 super.createControl(parent);
57 if (isProjectPreferencePage()) {
58 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
60 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
65 protected Control createPreferenceContent(Composite composite) {
66 return fConfigurationBlock.createContents(composite);
70 protected boolean hasProjectSpecificOptions(IProject project) {
71 return fConfigurationBlock.hasProjectSpecificOptions(project);
75 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
78 protected String getPreferencePageID() {
83 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
86 protected String getPropertyPageID() {
91 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
94 public void dispose() {
95 if (fConfigurationBlock != null) {
96 fConfigurationBlock.dispose();
102 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
105 protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
106 super.enableProjectSpecificSettings(useProjectSpecificSettings);
107 if (fConfigurationBlock != null) {
108 fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
113 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean)
116 protected void enablePreferenceContent(boolean enable) {
117 if (fConfigurationBlock != null) {
118 fConfigurationBlock.enablePreferenceContent(enable);
123 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
127 public void setVisible(boolean visible) {
128 super.setVisible(visible);
129 if (visible && fConfigurationBlock != null) {
130 fConfigurationBlock.refreshComplianceSettings();
135 * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
138 protected void performDefaults() {
139 super.performDefaults();
140 if (fConfigurationBlock != null) {
141 fConfigurationBlock.performDefaults();
146 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
149 public boolean performOk() {
150 if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
153 return super.performOk();
157 * @see org.eclipse.jface.preference.IPreferencePage#performApply()
160 public void performApply() {
161 if (fConfigurationBlock != null) {
162 fConfigurationBlock.performApply();
167 * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
170 public void setElement(IAdaptable element) {
171 super.setElement(element);
172 setDescription(null); // no description for property page