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;
15 import net.sourceforge.phpeclipse.ui.WebUI;
17 import org.eclipse.jface.dialogs.Dialog;
18 import org.eclipse.jface.preference.PreferencePage;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.PlatformUI;
26 * Abstract preference page which is used to wrap a
27 * {@link net.sourceforge.phpdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
31 public abstract class AbstractConfigurationBlockPreferencePage extends
32 PreferencePage implements IWorkbenchPreferencePage {
34 private IPreferenceConfigurationBlock fConfigurationBlock;
36 private OverlayPreferenceStore fOverlayStore;
39 * Creates a new preference page.
41 public AbstractConfigurationBlockPreferencePage() {
44 fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(),
45 new OverlayPreferenceStore.OverlayKey[] {});
46 fConfigurationBlock = createConfigurationBlock(fOverlayStore);
49 protected abstract IPreferenceConfigurationBlock createConfigurationBlock(
50 OverlayPreferenceStore overlayPreferenceStore);
52 protected abstract String getHelpId();
54 protected abstract void setDescription();
56 protected abstract void setPreferenceStore();
59 * @see IWorkbenchPreferencePage#init()
61 public void init(IWorkbench workbench) {
65 * @see PreferencePage#createControl(Composite)
67 public void createControl(Composite parent) {
68 super.createControl(parent);
69 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
74 * @see PreferencePage#createContents(Composite)
76 protected Control createContents(Composite parent) {
79 fOverlayStore.start();
81 fConfigurationBlock.createControl(parent);
85 Dialog.applyDialogFont(parent);
89 private void initialize() {
90 fConfigurationBlock.initialize();
94 * @see PreferencePage#performOk()
96 public boolean performOk() {
98 fConfigurationBlock.performOk();
100 fOverlayStore.propagate();
102 WebUI.getDefault().savePluginPreferences();
108 * @see PreferencePage#performDefaults()
110 public void performDefaults() {
112 fOverlayStore.loadDefaults();
113 fConfigurationBlock.performDefaults();
115 super.performDefaults();
119 * @see DialogPage#dispose()
121 public void dispose() {
123 fConfigurationBlock.dispose();
125 if (fOverlayStore != null) {
126 fOverlayStore.stop();
127 fOverlayStore = null;