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