001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.ui.preferences;
011:
012: import org.eclipse.core.runtime.IAdaptable;
013:
014: import org.eclipse.core.resources.IProject;
015:
016: import org.eclipse.swt.widgets.Composite;
017: import org.eclipse.swt.widgets.Control;
018:
019: import org.eclipse.ui.PlatformUI;
020: import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
021:
022: import org.eclipse.jdt.launching.JavaRuntime;
023:
024: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
025: import org.eclipse.jdt.internal.ui.JavaPlugin;
026:
027: /**
028: * Page used to configure both workspace and project specific compiler settings
029: */
030: public class CompliancePreferencePage extends PropertyAndPreferencePage {
031:
032: public static final String PREF_ID = "org.eclipse.jdt.ui.preferences.CompliancePreferencePage"; //$NON-NLS-1$
033: public static final String PROP_ID = "org.eclipse.jdt.ui.propertyPages.CompliancePreferencePage"; //$NON-NLS-1$
034:
035: private ComplianceConfigurationBlock fConfigurationBlock;
036:
037: public CompliancePreferencePage() {
038: setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
039: //setDescription(PreferencesMessages.CompliancePreferencePage_description);
040:
041: // only used when page is shown programatically
042: setTitle(PreferencesMessages.CompliancePreferencePage_title);
043:
044: JavaRuntime.getDefaultVMInstall(); // make sure the default JRE is detected (bug 152384)
045: }
046:
047: /*
048: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
049: */
050: public void createControl(Composite parent) {
051: IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
052: fConfigurationBlock = new ComplianceConfigurationBlock(
053: getNewStatusChangedListener(), getProject(), container);
054:
055: super .createControl(parent);
056: if (isProjectPreferencePage()) {
057: PlatformUI.getWorkbench().getHelpSystem().setHelp(
058: getControl(),
059: IJavaHelpContextIds.COMPILER_PROPERTY_PAGE);
060: } else {
061: PlatformUI.getWorkbench().getHelpSystem().setHelp(
062: getControl(),
063: IJavaHelpContextIds.COMPILER_PREFERENCE_PAGE);
064: }
065: }
066:
067: protected Control createPreferenceContent(Composite composite) {
068: return fConfigurationBlock.createContents(composite);
069: }
070:
071: protected boolean hasProjectSpecificOptions(IProject project) {
072: return fConfigurationBlock.hasProjectSpecificOptions(project);
073: }
074:
075: /* (non-Javadoc)
076: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
077: */
078: protected String getPreferencePageID() {
079: return PREF_ID;
080: }
081:
082: /* (non-Javadoc)
083: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
084: */
085: protected String getPropertyPageID() {
086: return PROP_ID;
087: }
088:
089: /* (non-Javadoc)
090: * @see org.eclipse.jface.dialogs.DialogPage#dispose()
091: */
092: public void dispose() {
093: if (fConfigurationBlock != null) {
094: fConfigurationBlock.dispose();
095: }
096: super .dispose();
097: }
098:
099: /* (non-Javadoc)
100: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
101: */
102: protected void enableProjectSpecificSettings(
103: boolean useProjectSpecificSettings) {
104: super .enableProjectSpecificSettings(useProjectSpecificSettings);
105: if (fConfigurationBlock != null) {
106: fConfigurationBlock
107: .useProjectSpecificSettings(useProjectSpecificSettings);
108: }
109: }
110:
111: /* (non-Javadoc)
112: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enablePreferenceContent(boolean)
113: */
114: protected void enablePreferenceContent(boolean enable) {
115: if (fConfigurationBlock != null) {
116: fConfigurationBlock.enablePreferenceContent(enable);
117: }
118: }
119:
120: /*
121: * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
122: */
123: protected void performDefaults() {
124: super .performDefaults();
125: if (fConfigurationBlock != null) {
126: fConfigurationBlock.performDefaults();
127: }
128: }
129:
130: /*
131: * @see org.eclipse.jface.preference.IPreferencePage#performOk()
132: */
133: public boolean performOk() {
134: if (fConfigurationBlock != null
135: && !fConfigurationBlock.performOk()) {
136: return false;
137: }
138: return super .performOk();
139: }
140:
141: /*
142: * @see org.eclipse.jface.preference.IPreferencePage#performApply()
143: */
144: public void performApply() {
145: if (fConfigurationBlock != null) {
146: fConfigurationBlock.performApply();
147: }
148: }
149:
150: /* (non-Javadoc)
151: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
152: */
153: public void setElement(IAdaptable element) {
154: super .setElement(element);
155: setDescription(null); // no description for property page
156: }
157:
158: }
|