1 package net.sourceforge.phpeclipse;
3 import java.util.ArrayList;
5 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
7 import org.eclipse.jface.preference.BooleanFieldEditor;
8 import org.eclipse.jface.preference.DirectoryFieldEditor;
9 import org.eclipse.jface.preference.IPreferenceStore;
10 import org.eclipse.jface.preference.PreferencePage;
11 import org.eclipse.jface.preference.RadioGroupFieldEditor;
12 import org.eclipse.jface.preference.StringFieldEditor;
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.events.ModifyListener;
15 import org.eclipse.swt.events.SelectionListener;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Group;
21 import org.eclipse.swt.widgets.Label;
22 import org.eclipse.ui.IWorkbench;
23 import org.eclipse.ui.IWorkbenchPreferencePage;
25 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
27 private SelectionListener SelectionListener;
28 private ModifyListener ModifyListener;
29 private ModifyListener TextModifyListener;
31 private ArrayList CheckBoxes = new ArrayList();
32 private ArrayList ComboBoxes = new ArrayList();
33 private ArrayList TextBoxes = new ArrayList();
34 private ArrayList RadioButtons = new ArrayList();
36 StringFieldEditor localHostSFE;
37 DirectoryFieldEditor documentRootDFE;
38 BooleanFieldEditor showExternalPreviewBFE;
39 BooleanFieldEditor externalBrowserBFE;
40 StringFieldEditor externalBrowserSFE;
41 StringFieldEditor apacheStartSFE;
42 StringFieldEditor apacheStopSFE;
43 StringFieldEditor apacheRestartSFE;
44 StringFieldEditor mySQLCommandSFE;
45 RadioGroupFieldEditor chooseParser;
46 StringFieldEditor externalParserSFE;
47 BooleanFieldEditor parseOnSave;
49 public PHPEclipseBasePreferencePage() {
51 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
52 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
54 public void init(IWorkbench workbench) {
56 protected void performDefaults() {
57 localHostSFE.loadDefault();
58 documentRootDFE.loadDefault();
59 showExternalPreviewBFE.loadDefault();
60 externalBrowserBFE.loadDefault();
61 externalBrowserSFE.loadDefault();
62 apacheStartSFE.loadDefault();
63 apacheStopSFE.loadDefault();
64 apacheRestartSFE.loadDefault();
65 mySQLCommandSFE.loadDefault();
66 chooseParser.loadDefault();
67 externalParserSFE.loadDefault();
68 parseOnSave.loadDefault();
69 super.performDefaults();
72 public boolean performOk() {
74 documentRootDFE.store();
75 showExternalPreviewBFE.store();
76 externalBrowserBFE.store();
77 externalBrowserSFE.store();
78 apacheStartSFE.store();
79 apacheStopSFE.store();
80 apacheRestartSFE.store();
81 mySQLCommandSFE.store();
83 externalParserSFE.store();
85 return super.performOk();
88 protected Control createContents(Composite parent) {
89 initializeDialogUnits(parent);
90 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
91 Composite composite = new Composite(parent, SWT.LEFT);
92 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
93 composite.setLayout(new GridLayout());
95 Composite webSettingsComposite = new Composite(composite, SWT.NONE);
96 webSettingsComposite.setLayout(new GridLayout());
97 webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
98 Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
99 webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
100 webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
101 webSettingsGroup.setLayout(new GridLayout());
103 new StringFieldEditor(
104 IPreferenceConstants.LOCALHOST_PREF,
105 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"),
107 localHostSFE.setPreferencePage(this);
108 localHostSFE.setPreferenceStore(getPreferenceStore());
111 new DirectoryFieldEditor(
112 IPreferenceConstants.DOCUMENTROOT_PREF,
113 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"),
115 documentRootDFE.setPreferencePage(this);
116 documentRootDFE.setPreferenceStore(getPreferenceStore());
117 documentRootDFE.load();
119 new Label(webSettingsGroup, SWT.NONE);
120 showExternalPreviewBFE =
121 new BooleanFieldEditor(
122 IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF,
123 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"),
125 showExternalPreviewBFE.setPreferencePage(this);
126 showExternalPreviewBFE.setPreferenceStore(getPreferenceStore());
127 showExternalPreviewBFE.load();
128 new Label(webSettingsGroup, SWT.NONE);
130 new BooleanFieldEditor(
131 IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF,
132 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"),
134 externalBrowserBFE.setPreferencePage(this);
135 externalBrowserBFE.setPreferenceStore(getPreferenceStore());
136 externalBrowserBFE.load();
137 new Label(webSettingsGroup, SWT.NONE);
139 new StringFieldEditor(
140 IPreferenceConstants.EXTERNAL_BROWSER_PREF,
141 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"),
143 externalBrowserSFE.setPreferencePage(this);
144 externalBrowserSFE.setPreferenceStore(getPreferenceStore());
145 externalBrowserSFE.load();
148 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
149 apacheSettingsComposite.setLayout(new GridLayout());
150 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
151 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
152 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
153 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
154 apacheSettingsGroup.setLayout(new GridLayout());
156 new StringFieldEditor(
157 IPreferenceConstants.APACHE_START_PREF,
158 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"),
159 apacheSettingsGroup);
160 apacheStartSFE.setPreferencePage(this);
161 apacheStartSFE.setPreferenceStore(getPreferenceStore());
162 apacheStartSFE.load();
164 new StringFieldEditor(
165 IPreferenceConstants.APACHE_STOP_PREF,
166 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"),
167 apacheSettingsGroup);
168 apacheStopSFE.setPreferencePage(this);
169 apacheStopSFE.setPreferenceStore(getPreferenceStore());
170 apacheStopSFE.load();
172 new StringFieldEditor(
173 IPreferenceConstants.APACHE_RESTART_PREF,
174 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"),
175 apacheSettingsGroup);
176 apacheRestartSFE.setPreferencePage(this);
177 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
178 apacheRestartSFE.load();
181 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
182 mySQLSettingsComposite.setLayout(new GridLayout());
183 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
185 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
186 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
187 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
188 mySQLSettingsGroup.setLayout(new GridLayout());
190 new StringFieldEditor(
191 IPreferenceConstants.MYSQL_PREF,
192 PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"),
194 mySQLCommandSFE.setPreferencePage(this);
195 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
196 mySQLCommandSFE.load();
198 //Create parser settings composite
199 Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
200 parserSettingsComposite.setLayout(new GridLayout());
201 parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
202 Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
203 parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
204 parserSettingsGroup.setLayout(new GridLayout());
205 parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
208 new RadioGroupFieldEditor(
209 IPreferenceConstants.PHP_PARSER_DEFAULT,
210 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
213 { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
215 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
216 }, parserSettingsGroup);
217 chooseParser.setPreferencePage(this);
218 chooseParser.setPreferenceStore(getPreferenceStore());
220 //create a copmposte just for the StringEditor - makes layout simpler
221 Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE);
223 new StringFieldEditor(
224 IPreferenceConstants.EXTERNAL_PARSER_PREF,
225 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
227 /*parserSettingsGroup*/
229 externalParserSFE.setPreferencePage(this);
230 externalParserSFE.setPreferenceStore(getPreferenceStore());
231 externalParserSFE.load();
234 new BooleanFieldEditor(
235 PHPeclipsePlugin.PHP_PARSE_ON_SAVE,
236 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"),
237 parserSettingsGroup);
238 parseOnSave.setPreferencePage(this);
239 parseOnSave.setPreferenceStore(getPreferenceStore());