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