001: /*******************************************************************************
002: * Copyright (c) 2000, 2005 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.resources.IProject;
013:
014: import org.eclipse.swt.widgets.Composite;
015: import org.eclipse.swt.widgets.Control;
016:
017: import org.eclipse.ui.IWorkbenchPreferencePage;
018: import org.eclipse.ui.PlatformUI;
019: import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
020:
021: import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
022: import org.eclipse.jdt.internal.ui.JavaPlugin;
023:
024: /*
025: * The page to configure the naming style options.
026: */
027: public class CodeStylePreferencePage extends PropertyAndPreferencePage
028: implements IWorkbenchPreferencePage {
029:
030: public static final String PREF_ID = "org.eclipse.jdt.ui.preferences.CodeStylePreferencePage"; //$NON-NLS-1$
031: public static final String PROP_ID = "org.eclipse.jdt.ui.propertyPages.CodeStylePreferencePage"; //$NON-NLS-1$
032:
033: private NameConventionConfigurationBlock fConfigurationBlock;
034:
035: public CodeStylePreferencePage() {
036: setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
037: //setDescription(PreferencesMessages.getString("CodeStylePreferencePage.description")); //$NON-NLS-1$
038:
039: // only used when page is shown programatically
040: setTitle(PreferencesMessages.CodeStylePreferencePage_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 NameConventionConfigurationBlock(
049: getNewStatusChangedListener(), getProject(), container);
050:
051: super .createControl(parent);
052: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
053: IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
054: }
055:
056: protected Control createPreferenceContent(Composite composite) {
057: return fConfigurationBlock.createContents(composite);
058: }
059:
060: protected boolean hasProjectSpecificOptions(IProject project) {
061: return fConfigurationBlock.hasProjectSpecificOptions(project);
062: }
063:
064: /* (non-Javadoc)
065: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
066: */
067: protected String getPreferencePageID() {
068: return PREF_ID;
069: }
070:
071: /* (non-Javadoc)
072: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
073: */
074: protected String getPropertyPageID() {
075: return PROP_ID;
076: }
077:
078: /* (non-Javadoc)
079: * @see org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
080: */
081: protected void enableProjectSpecificSettings(
082: boolean useProjectSpecificSettings) {
083: super .enableProjectSpecificSettings(useProjectSpecificSettings);
084: if (fConfigurationBlock != null) {
085: fConfigurationBlock
086: .useProjectSpecificSettings(useProjectSpecificSettings);
087: }
088: }
089:
090: /* (non-Javadoc)
091: * @see org.eclipse.jface.dialogs.DialogPage#dispose()
092: */
093: public void dispose() {
094: if (fConfigurationBlock != null) {
095: fConfigurationBlock.dispose();
096: }
097: super .dispose();
098: }
099:
100: /*
101: * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
102: */
103: protected void performDefaults() {
104: super .performDefaults();
105: if (fConfigurationBlock != null) {
106: fConfigurationBlock.performDefaults();
107: }
108: }
109:
110: /*
111: * @see org.eclipse.jface.preference.IPreferencePage#performOk()
112: */
113: public boolean performOk() {
114: if (fConfigurationBlock != null
115: && !fConfigurationBlock.performOk()) {
116: return false;
117: }
118: return super .performOk();
119: }
120:
121: /*
122: * @see org.eclipse.jface.preference.IPreferencePage#performApply()
123: */
124: public void performApply() {
125: if (fConfigurationBlock != null) {
126: fConfigurationBlock.performApply();
127: }
128: }
129:
130: }
|