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.help.WorkbenchHelp;
27 * Abstract preference page which is used to wrap a
28 * {@link net.sourceforge.phpdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
32 public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
35 private IPreferenceConfigurationBlock fConfigurationBlock;
36 private OverlayPreferenceStore fOverlayStore;
40 * Creates a new preference page.
42 public AbstractConfigurationBlockPreferencePage() {
45 fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
46 fConfigurationBlock= createConfigurationBlock(fOverlayStore);
49 protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
50 protected abstract String getHelpId();
51 protected abstract void setDescription();
52 protected abstract void setPreferenceStore();
55 * @see IWorkbenchPreferencePage#init()
57 public void init(IWorkbench workbench) {
61 * @see PreferencePage#createControl(Composite)
63 public void createControl(Composite parent) {
64 super.createControl(parent);
65 WorkbenchHelp.setHelp(getControl(), getHelpId());
69 * @see PreferencePage#createContents(Composite)
71 protected Control createContents(Composite parent) {
74 fOverlayStore.start();
76 fConfigurationBlock.createControl(parent);
80 Dialog.applyDialogFont(parent);
84 private void initialize() {
85 fConfigurationBlock.initialize();
89 * @see PreferencePage#performOk()
91 public boolean performOk() {
93 fConfigurationBlock.performOk();
95 fOverlayStore.propagate();
97 PHPeclipsePlugin.getDefault().savePluginPreferences();
103 * @see PreferencePage#performDefaults()
105 public void performDefaults() {
107 fOverlayStore.loadDefaults();
108 fConfigurationBlock.performDefaults();
110 super.performDefaults();
114 * @see DialogPage#dispose()
116 public void dispose() {
118 fConfigurationBlock.dispose();
120 if (fOverlayStore != null) {
121 fOverlayStore.stop();