1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.internal.ui.preferences;
14 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.jface.preference.PreferencePage;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.ui.IWorkbench;
21 import org.eclipse.ui.IWorkbenchPreferencePage;
22 import org.eclipse.ui.PlatformUI;
25 * Abstract preference page which is used to wrap a
26 * {@link net.sourceforge.phpdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
30 public abstract class AbstractConfigurationBlockPreferencePage extends
31 PreferencePage implements IWorkbenchPreferencePage {
33 private IPreferenceConfigurationBlock fConfigurationBlock;
35 private OverlayPreferenceStore fOverlayStore;
38 * Creates a new preference page.
40 public AbstractConfigurationBlockPreferencePage() {
43 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(),
44 new OverlayPreferenceStore.OverlayKey[] {});
45 fConfigurationBlock = createConfigurationBlock(fOverlayStore);
48 protected abstract IPreferenceConfigurationBlock createConfigurationBlock(
49 OverlayPreferenceStore overlayPreferenceStore);
51 protected abstract String getHelpId();
53 protected abstract void setDescription();
55 protected abstract void setPreferenceStore();
58 * @see IWorkbenchPreferencePage#init()
60 public void init(IWorkbench workbench) {
64 * @see PreferencePage#createControl(Composite)
66 public void createControl(Composite parent) {
67 super.createControl(parent);
68 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
73 * @see PreferencePage#createContents(Composite)
75 protected Control createContents(Composite parent) {
78 fOverlayStore.start();
80 fConfigurationBlock.createControl(parent);
84 Dialog.applyDialogFont(parent);
88 private void initialize() {
89 fConfigurationBlock.initialize();
93 * @see PreferencePage#performOk()
95 public boolean performOk() {
97 fConfigurationBlock.performOk();
99 fOverlayStore.propagate();
101 PHPeclipsePlugin.getDefault().savePluginPreferences();
107 * @see PreferencePage#performDefaults()
109 public void performDefaults() {
111 fOverlayStore.loadDefaults();
112 fConfigurationBlock.performDefaults();
114 super.performDefaults();
118 * @see DialogPage#dispose()
120 public void dispose() {
122 fConfigurationBlock.dispose();
124 if (fOverlayStore != null) {
125 fOverlayStore.stop();
126 fOverlayStore = null;