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.layout.RowLayout;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Group;
22 import org.eclipse.swt.widgets.Label;
23 import org.eclipse.ui.IWorkbench;
24 import org.eclipse.ui.IWorkbenchPreferencePage;
26 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
28 private SelectionListener SelectionListener;
29 private ModifyListener ModifyListener;
30 private ModifyListener TextModifyListener;
32 private ArrayList CheckBoxes = new ArrayList();
33 private ArrayList ComboBoxes = new ArrayList();
34 private ArrayList TextBoxes = new ArrayList();
35 private ArrayList RadioButtons = new ArrayList();
37 StringFieldEditor localHostSFE;
38 DirectoryFieldEditor documentRootDFE;
39 BooleanFieldEditor showExternalPreviewBFE;
40 BooleanFieldEditor externalBrowserBFE;
41 StringFieldEditor externalBrowserSFE;
42 StringFieldEditor apacheStartSFE;
43 StringFieldEditor apacheStopSFE;
44 StringFieldEditor apacheRestartSFE;
45 StringFieldEditor mySQLCommandSFE;
46 StringFieldEditor phpRunSFE;
47 RadioGroupFieldEditor chooseParser;
48 StringFieldEditor externalParserSFE;
49 BooleanFieldEditor parseOnSave;
51 public PHPEclipseBasePreferencePage() {
53 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
54 setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
56 public void init(IWorkbench workbench) {
58 protected void performDefaults() {
59 localHostSFE.loadDefault();
60 documentRootDFE.loadDefault();
61 showExternalPreviewBFE.loadDefault();
62 externalBrowserBFE.loadDefault();
63 externalBrowserSFE.loadDefault();
64 apacheStartSFE.loadDefault();
65 apacheStopSFE.loadDefault();
66 apacheRestartSFE.loadDefault();
67 mySQLCommandSFE.loadDefault();
68 phpRunSFE.loadDefault();
69 chooseParser.loadDefault();
70 externalParserSFE.loadDefault();
71 parseOnSave.loadDefault();
72 super.performDefaults();
75 public boolean performOk() {
77 documentRootDFE.store();
78 showExternalPreviewBFE.store();
79 externalBrowserBFE.store();
80 externalBrowserSFE.store();
81 apacheStartSFE.store();
82 apacheStopSFE.store();
83 apacheRestartSFE.store();
84 mySQLCommandSFE.store();
87 externalParserSFE.store();
89 return super.performOk();
92 protected Control createContents(Composite parent) {
93 initializeDialogUnits(parent);
94 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
95 Composite composite = new Composite(parent, SWT.LEFT);
96 composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
97 composite.setLayout(new GridLayout());
99 Composite webSettingsComposite = new Composite(composite, SWT.NONE);
100 webSettingsComposite.setLayout(new GridLayout());
101 webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
103 showExternalPreviewBFE =
104 new BooleanFieldEditor(
105 IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF,
106 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"),
107 webSettingsComposite);
108 showExternalPreviewBFE.setPreferencePage(this);
109 showExternalPreviewBFE.setPreferenceStore(getPreferenceStore());
110 showExternalPreviewBFE.load();
112 Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
113 webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
114 GridLayout gridLayout = new GridLayout();
115 // gridLayout.numColumns = 3;
116 GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
117 webSettingsGroup.setLayoutData(gridData);
118 webSettingsGroup.setLayout(gridLayout);
120 // new Label(webSettingsGroup, SWT.NONE);
122 new BooleanFieldEditor(
123 IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF,
124 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"),
126 externalBrowserBFE.setPreferencePage(this);
127 externalBrowserBFE.setPreferenceStore(getPreferenceStore());
128 externalBrowserBFE.load();
129 new Label(webSettingsGroup, SWT.NONE);
130 new Label(webSettingsGroup, SWT.NONE);
131 // new Label(webSettingsGroup, SWT.NONE);
133 new StringFieldEditor(
134 IPreferenceConstants.EXTERNAL_BROWSER_PREF,
135 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"),
137 externalBrowserSFE.setPreferencePage(this);
138 externalBrowserSFE.setPreferenceStore(getPreferenceStore());
139 externalBrowserSFE.load();
140 new Label(webSettingsGroup, SWT.NONE);
143 new StringFieldEditor(
144 IPreferenceConstants.LOCALHOST_PREF,
145 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"),
147 localHostSFE.setPreferencePage(this);
148 localHostSFE.setPreferenceStore(getPreferenceStore());
150 new Label(webSettingsGroup, SWT.NONE);
153 new DirectoryFieldEditor(
154 IPreferenceConstants.DOCUMENTROOT_PREF,
155 PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"),
157 documentRootDFE.setPreferencePage(this);
158 documentRootDFE.setPreferenceStore(getPreferenceStore());
159 documentRootDFE.load();
161 Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
162 apacheSettingsComposite.setLayout(new GridLayout());
163 apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
164 Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
165 apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
166 apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
167 apacheSettingsGroup.setLayout(new GridLayout());
169 new StringFieldEditor(
170 IPreferenceConstants.APACHE_START_PREF,
171 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"),
172 apacheSettingsGroup);
173 apacheStartSFE.setPreferencePage(this);
174 apacheStartSFE.setPreferenceStore(getPreferenceStore());
175 apacheStartSFE.load();
177 new StringFieldEditor(
178 IPreferenceConstants.APACHE_STOP_PREF,
179 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"),
180 apacheSettingsGroup);
181 apacheStopSFE.setPreferencePage(this);
182 apacheStopSFE.setPreferenceStore(getPreferenceStore());
183 apacheStopSFE.load();
185 new StringFieldEditor(
186 IPreferenceConstants.APACHE_RESTART_PREF,
187 PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"),
188 apacheSettingsGroup);
189 apacheRestartSFE.setPreferencePage(this);
190 apacheRestartSFE.setPreferenceStore(getPreferenceStore());
191 apacheRestartSFE.load();
194 new StringFieldEditor(
195 IPreferenceConstants.PHP_RUN_PREF,
196 PHPPreferencesMessages.getString("PHPBasePreferencePage.console.php"),
197 apacheSettingsGroup);
198 phpRunSFE.setPreferencePage(this);
199 phpRunSFE.setPreferenceStore(getPreferenceStore());
203 Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
204 mySQLSettingsComposite.setLayout(new GridLayout());
205 mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
207 Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
208 mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
209 mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
210 mySQLSettingsGroup.setLayout(new GridLayout());
212 new StringFieldEditor(
213 IPreferenceConstants.MYSQL_PREF,
214 PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"),
216 mySQLCommandSFE.setPreferencePage(this);
217 mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
218 mySQLCommandSFE.load();
220 //Create parser settings composite
221 Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
222 parserSettingsComposite.setLayout(new GridLayout());
223 parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
224 Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
225 parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
226 parserSettingsGroup.setLayout(new GridLayout());
227 parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
230 new RadioGroupFieldEditor(
231 IPreferenceConstants.PHP_PARSER_DEFAULT,
232 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
235 { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
237 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
238 }, parserSettingsGroup);
239 chooseParser.setPreferencePage(this);
240 chooseParser.setPreferenceStore(getPreferenceStore());
242 //create a copmposte just for the StringEditor - makes layout simpler
243 Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE);
245 new StringFieldEditor(
246 IPreferenceConstants.EXTERNAL_PARSER_PREF,
247 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
249 /*parserSettingsGroup*/
251 externalParserSFE.setPreferencePage(this);
252 externalParserSFE.setPreferenceStore(getPreferenceStore());
253 externalParserSFE.load();
256 new BooleanFieldEditor(
257 PHPeclipsePlugin.PHP_PARSE_ON_SAVE,
258 PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"),
259 parserSettingsGroup);
260 parseOnSave.setPreferencePage(this);
261 parseOnSave.setPreferenceStore(getPreferenceStore());