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 StringFieldEditor phpRunSFE;
46 RadioGroupFieldEditor chooseParser;
47 StringFieldEditor externalParserSFE;
48 BooleanFieldEditor parseOnSave;
50 public PHPEclipseBasePreferencePage() {
52 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
53 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
55 public void init(IWorkbench workbench) {
57 protected void performDefaults() {
58 localHostSFE.loadDefault();
59 documentRootDFE.loadDefault();
60 showExternalPreviewBFE.loadDefault();
61 externalBrowserBFE.loadDefault();
62 externalBrowserSFE.loadDefault();
63 apacheStartSFE.loadDefault();
64 apacheStopSFE.loadDefault();
65 apacheRestartSFE.loadDefault();
66 mySQLCommandSFE.loadDefault();
67 phpRunSFE.loadDefault();
68 chooseParser.loadDefault();
69 externalParserSFE.loadDefault();
70 parseOnSave.loadDefault();
71 super.performDefaults();
74 public boolean performOk() {
76 documentRootDFE.store();
77 showExternalPreviewBFE.store();
78 externalBrowserBFE.store();
79 externalBrowserSFE.store();
80 apacheStartSFE.store();
81 apacheStopSFE.store();
82 apacheRestartSFE.store();
83 mySQLCommandSFE.store();
86 externalParserSFE.store();
88 return super.performOk();
91 protected Control createContents(Composite parent) {
92 initializeDialogUnits(parent);
93 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
94 Composite composite = new Composite(parent, SWT.LEFT);
95 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
96 composite.setLayout(new GridLayout());
98 Composite webSettingsComposite = new Composite(composite, SWT.NONE);
99 webSettingsComposite.setLayout(new GridLayout());
100 webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
101 Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
102 webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
103 webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
104 webSettingsGroup.setLayout(new GridLayout());
106 new StringFieldEditor(
107 IPreferenceConstants.LOCALHOST_PREF,
108 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"),
110 localHostSFE.setPreferencePage(this);
111 localHostSFE.setPreferenceStore(getPreferenceStore());
114 new DirectoryFieldEditor(
115 IPreferenceConstants.DOCUMENTROOT_PREF,
116 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"),
118 documentRootDFE.setPreferencePage(this);
119 documentRootDFE.setPreferenceStore(getPreferenceStore());
120 documentRootDFE.load();
122 new Label(webSettingsGroup, SWT.NONE);
123 showExternalPreviewBFE =
124 new BooleanFieldEditor(
125 IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF,
126 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"),
128 showExternalPreviewBFE.setPreferencePage(this);
129 showExternalPreviewBFE.setPreferenceStore(getPreferenceStore());
130 showExternalPreviewBFE.load();
131 new Label(webSettingsGroup, SWT.NONE);
133 new BooleanFieldEditor(
134 IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF,
135 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"),
137 externalBrowserBFE.setPreferencePage(this);
138 externalBrowserBFE.setPreferenceStore(getPreferenceStore());
139 externalBrowserBFE.load();
140 new Label(webSettingsGroup, SWT.NONE);
142 new StringFieldEditor(
143 IPreferenceConstants.EXTERNAL_BROWSER_PREF,
144 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"),
146 externalBrowserSFE.setPreferencePage(this);
147 externalBrowserSFE.setPreferenceStore(getPreferenceStore());
148 externalBrowserSFE.load();
151 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
152 apacheSettingsComposite.setLayout(new GridLayout());
153 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
154 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
155 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
156 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
157 apacheSettingsGroup.setLayout(new GridLayout());
159 new StringFieldEditor(
160 IPreferenceConstants.APACHE_START_PREF,
161 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"),
162 apacheSettingsGroup);
163 apacheStartSFE.setPreferencePage(this);
164 apacheStartSFE.setPreferenceStore(getPreferenceStore());
165 apacheStartSFE.load();
167 new StringFieldEditor(
168 IPreferenceConstants.APACHE_STOP_PREF,
169 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"),
170 apacheSettingsGroup);
171 apacheStopSFE.setPreferencePage(this);
172 apacheStopSFE.setPreferenceStore(getPreferenceStore());
173 apacheStopSFE.load();
175 new StringFieldEditor(
176 IPreferenceConstants.APACHE_RESTART_PREF,
177 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"),
178 apacheSettingsGroup);
179 apacheRestartSFE.setPreferencePage(this);
180 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
181 apacheRestartSFE.load();
184 new StringFieldEditor(
185 IPreferenceConstants.PHP_RUN_PREF,
186 PHPPreferencesMessages.getString("PHPBasePreferencePage.console.php"),
187 apacheSettingsGroup);
188 phpRunSFE.setPreferencePage(this);
189 phpRunSFE.setPreferenceStore(getPreferenceStore());
193 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
194 mySQLSettingsComposite.setLayout(new GridLayout());
195 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
197 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
198 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
199 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
200 mySQLSettingsGroup.setLayout(new GridLayout());
202 new StringFieldEditor(
203 IPreferenceConstants.MYSQL_PREF,
204 PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"),
206 mySQLCommandSFE.setPreferencePage(this);
207 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
208 mySQLCommandSFE.load();
210 //Create parser settings composite
211 Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
212 parserSettingsComposite.setLayout(new GridLayout());
213 parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
214 Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
215 parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
216 parserSettingsGroup.setLayout(new GridLayout());
217 parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
220 new RadioGroupFieldEditor(
221 IPreferenceConstants.PHP_PARSER_DEFAULT,
222 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
225 { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
227 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
228 }, parserSettingsGroup);
229 chooseParser.setPreferencePage(this);
230 chooseParser.setPreferenceStore(getPreferenceStore());
232 //create a copmposte just for the StringEditor - makes layout simpler
233 Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE);
235 new StringFieldEditor(
236 IPreferenceConstants.EXTERNAL_PARSER_PREF,
237 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
239 /*parserSettingsGroup*/
241 externalParserSFE.setPreferencePage(this);
242 externalParserSFE.setPreferenceStore(getPreferenceStore());
243 externalParserSFE.load();
246 new BooleanFieldEditor(
247 PHPeclipsePlugin.PHP_PARSE_ON_SAVE,
248 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"),
249 parserSettingsGroup);
250 parseOnSave.setPreferencePage(this);
251 parseOnSave.setPreferenceStore(getPreferenceStore());