Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / preferences / CodeTemplatePreferencePage.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.preferences;
12
13 import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
14 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
15 import net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener;
16 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
17
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.jface.dialogs.Dialog;
20 import org.eclipse.jface.preference.PreferencePage;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Control;
23 import org.eclipse.ui.IWorkbench;
24 import org.eclipse.ui.IWorkbenchPreferencePage;
25 import org.eclipse.ui.PlatformUI;
26
27 /*
28  * The page to configure the code formatter options.
29  */
30 public class CodeTemplatePreferencePage extends PreferencePage implements
31                 IWorkbenchPreferencePage, IStatusChangeListener {
32
33         private CodeTemplateBlock fCodeTemplateConfigurationBlock;
34
35         public CodeTemplatePreferencePage() {
36                 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
37                 // setDescription(PreferencesMessages.getString("CodeTemplatesPreferencePage.description"));
38                 // //$NON-NLS-1$
39
40                 // only used when page is shown programatically
41                 setTitle(PreferencesMessages
42                                 .getString("CodeTemplatesPreferencePage.title")); //$NON-NLS-1$
43
44                 fCodeTemplateConfigurationBlock = new CodeTemplateBlock();
45         }
46
47         /*
48          * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
49          */
50         public void init(IWorkbench workbench) {
51         }
52
53         /*
54          * @see PreferencePage#createControl(Composite)
55          */
56         public void createControl(Composite parent) {
57                 super.createControl(parent);
58                 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
59                                 IJavaHelpContextIds.CODE_MANIPULATION_PREFERENCE_PAGE);
60         }
61
62         /*
63          * @see PreferencePage#createContents(Composite)
64          */
65         protected Control createContents(Composite parent) {
66                 Control composite = fCodeTemplateConfigurationBlock
67                                 .createContents(parent);
68                 Dialog.applyDialogFont(composite);
69                 return composite;
70         }
71
72         /*
73          * @see IPreferencePage#performOk()
74          */
75         public boolean performOk() {
76                 if (!fCodeTemplateConfigurationBlock.performOk(true)) {
77                         return false;
78                 }
79                 return super.performOk();
80         }
81
82         /*
83          * @see PreferencePage#performDefaults()
84          */
85         protected void performDefaults() {
86                 fCodeTemplateConfigurationBlock.performDefaults();
87                 super.performDefaults();
88         }
89
90         /*
91          * (non-Javadoc)
92          * 
93          * @see net.sourceforge.phpdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
94          */
95         public void statusChanged(IStatus status) {
96                 setValid(!status.matches(IStatus.ERROR));
97                 StatusUtil.applyToStatusLine(this, status);
98         }
99
100         /*
101          * (non-Javadoc)
102          * 
103          * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
104          */
105         public boolean performCancel() {
106                 fCodeTemplateConfigurationBlock.performCancel();
107
108                 return super.performCancel();
109         }
110
111 }