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.internal.ui.IJavaHelpContextIds;
023: import org.eclipse.jdt.internal.ui.JavaPlugin;
024:
025: /**
026: * Page used to configure both workspace and project specific compiler settings
027: */
028: public class JavaBuildPreferencePage extends PropertyAndPreferencePage {
029:
030: public static final String PREF_ID = "org.eclipse.jdt.ui.preferences.JavaBuildPreferencePage"; //$NON-NLS-1$
031: public static final String PROP_ID = "org.eclipse.jdt.ui.propertyPages.JavaBuildPreferencePage"; //$NON-NLS-1$
032:
033: private JavaBuildConfigurationBlock fConfigurationBlock;
034:
035: public JavaBuildPreferencePage() {
036: setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
037: //setDescription(PreferencesMessages.JavaBuildPreferencePage_description);
038:
039: // only used when page is shown programatically
040: setTitle(PreferencesMessages.JavaBuildPreferencePage_title);
041: }
042:
043: /*
044: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
045: */
046: public void createControl(Composite parent) {
047: IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
048: fConfigurationBlock = new JavaBuildConfigurationBlock(
049: getNewStatusChangedListener(), getProject(), container);
050:
051: super .createControl(parent);
052: if (isProjectPreferencePage()) {
053: PlatformUI.getWorkbench().getHelpSystem().setHelp(
054: getControl(),
055: IJavaHelpContextIds.JAVA_BUILD_PROPERTY_PAGE);
056: } else {
057: PlatformUI.getWorkbench().getHelpSystem().setHelp(
058: getControl(),
059: IJavaHelpContextIds.JAVA_BUILD_PREFERENCE_PAGE);
060: }
061: }
062:
063: protected Control createPreferenceContent(Composite composite) {
064: return fConfigurationBlock.createContents(composite);
065: }
066:
067: protected boolean hasProjectSpecificOptions(IProject project) {
068: return fConfigurationBlock.hasProjectSpecificOptions(project);
069: }
070:
071: /* (non-Javadoc)
072: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
073: */
074: protected String getPreferencePageID() {
075: return PREF_ID;
076: }
077:
078: /* (non-Javadoc)
079: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
080: */
081: protected String getPropertyPageID() {
082: return PROP_ID;
083: }
084:
085: /* (non-Javadoc)
086: * @see org.eclipse.jface.dialogs.DialogPage#dispose()
087: */
088: public void dispose() {
089: if (fConfigurationBlock != null) {
090: fConfigurationBlock.dispose();
091: }
092: super .dispose();
093: }
094:
095: /* (non-Javadoc)
096: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
097: */
098: protected void enableProjectSpecificSettings(
099: boolean useProjectSpecificSettings) {
100: super .enableProjectSpecificSettings(useProjectSpecificSettings);
101: if (fConfigurationBlock != null) {
102: fConfigurationBlock
103: .useProjectSpecificSettings(useProjectSpecificSettings);
104: }
105: }
106:
107: /*
108: * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
109: */
110: protected void performDefaults() {
111: super .performDefaults();
112: if (fConfigurationBlock != null) {
113: fConfigurationBlock.performDefaults();
114: }
115: }
116:
117: /*
118: * @see org.eclipse.jface.preference.IPreferencePage#performOk()
119: */
120: public boolean performOk() {
121: if (fConfigurationBlock != null
122: && !fConfigurationBlock.performOk()) {
123: return false;
124: }
125: return super .performOk();
126: }
127:
128: /*
129: * @see org.eclipse.jface.preference.IPreferencePage#performApply()
130: */
131: public void performApply() {
132: if (fConfigurationBlock != null) {
133: fConfigurationBlock.performApply();
134: }
135: }
136:
137: /* (non-Javadoc)
138: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
139: */
140: public void setElement(IAdaptable element) {
141: super .setElement(element);
142: setDescription(null); // no description for property page
143: }
144:
145: }
|