improved code formatter
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPEclipseBasePreferencePage.java
1 package net.sourceforge.phpeclipse;
2
3 import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages;
4
5 import org.eclipse.jface.preference.BooleanFieldEditor;
6 import org.eclipse.jface.preference.DirectoryFieldEditor;
7 import org.eclipse.jface.preference.FileFieldEditor;
8 import org.eclipse.jface.preference.IPreferenceStore;
9 import org.eclipse.jface.preference.PreferencePage;
10 import org.eclipse.jface.preference.StringFieldEditor;
11 import org.eclipse.swt.SWT;
12 import org.eclipse.swt.layout.GridData;
13 import org.eclipse.swt.layout.GridLayout;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Group;
17 import org.eclipse.swt.widgets.Label;
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.IWorkbenchPreferencePage;
20
21 public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
22
23 //  private SelectionListener SelectionListener;
24 //  private ModifyListener ModifyListener;
25 //  private ModifyListener TextModifyListener;
26 //
27 //  private ArrayList CheckBoxes = new ArrayList();
28 //  private ArrayList ComboBoxes = new ArrayList();
29 //  private ArrayList TextBoxes = new ArrayList();
30 //  private ArrayList RadioButtons = new ArrayList();
31
32   StringFieldEditor localHostSFE;
33   DirectoryFieldEditor documentRootDFE;
34 //  BooleanFieldEditor showExternalPreviewBFE;
35   BooleanFieldEditor externalBrowserBFE;
36   StringFieldEditor externalBrowserSFE;
37   StringFieldEditor apacheStartSFE;
38   StringFieldEditor apacheStopSFE;
39   StringFieldEditor apacheRestartSFE;
40   StringFieldEditor mySQLCommandSFE;
41   FileFieldEditor apacheRunFFE;
42   FileFieldEditor mysqlRunFFE;
43   FileFieldEditor phpRunFFE;
44 //  RadioGroupFieldEditor chooseParser;
45 //  StringFieldEditor externalParserSFE;
46 //  BooleanFieldEditor parseOnSave;
47   BooleanFieldEditor apacheStartBFE;
48   BooleanFieldEditor apacheStopBFE;
49   BooleanFieldEditor apacheRestartBFE;
50   BooleanFieldEditor mysqlStartBFE;
51
52   public PHPEclipseBasePreferencePage() {
53     super();
54     setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
55     setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$
56   }
57   public void init(IWorkbench workbench) {
58   }
59   protected void performDefaults() {
60     localHostSFE.loadDefault();
61     documentRootDFE.loadDefault();
62 //    showExternalPreviewBFE.loadDefault();
63     externalBrowserBFE.loadDefault();
64     externalBrowserSFE.loadDefault();
65     apacheStartSFE.loadDefault();
66     apacheStopSFE.loadDefault();
67     apacheRestartSFE.loadDefault();
68     mySQLCommandSFE.loadDefault();
69     phpRunFFE.loadDefault();
70     apacheRunFFE.loadDefault();
71     mysqlRunFFE.loadDefault();
72 //    chooseParser.loadDefault();
73 //    externalParserSFE.loadDefault();
74 //    parseOnSave.loadDefault();
75     apacheStartBFE.loadDefault();
76     apacheStopBFE.loadDefault();
77     apacheRestartBFE.loadDefault();
78     mysqlStartBFE.loadDefault();
79     super.performDefaults();
80   }
81
82   public boolean performOk() {
83     localHostSFE.store();
84     documentRootDFE.store();
85 //    showExternalPreviewBFE.store();
86     externalBrowserBFE.store();
87     externalBrowserSFE.store();
88     apacheStartSFE.store();
89     apacheStopSFE.store();
90     apacheRestartSFE.store();
91     mySQLCommandSFE.store();
92     phpRunFFE.store();
93     apacheRunFFE.store();
94     mysqlRunFFE.store();
95 //    chooseParser.store();
96 //    externalParserSFE.store();
97 //    parseOnSave.store();
98     apacheStartBFE.store();
99     apacheStopBFE.store();
100     apacheRestartBFE.store();
101     mysqlStartBFE.store();
102     return super.performOk();
103   }
104
105   protected Control createContents(Composite parent) {
106     initializeDialogUnits(parent);
107     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
108     Composite composite = new Composite(parent, SWT.LEFT);
109     composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
110     composite.setLayout(new GridLayout());
111     //Create Websettings
112     //    Composite webSettingsComposite = new Composite(composite, SWT.NONE);
113     //    webSettingsComposite.setLayout(new GridLayout());
114     //    webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
115
116 //    showExternalPreviewBFE =
117 //      new BooleanFieldEditor(
118 //        IPreferenceConstants.SHOW_EXTERNAL_PREVIEW_PREF,
119 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.showexternalpreview"),
120 //        composite);
121 //    showExternalPreviewBFE.setPreferencePage(this);
122 //    showExternalPreviewBFE.setPreferenceStore(getPreferenceStore());
123 //    showExternalPreviewBFE.load();
124
125     //    Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
126     //    webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
127     //    GridLayout gridLayout = new GridLayout();
128     //    //  gridLayout.numColumns = 3;
129     //    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
130     //    webSettingsGroup.setLayoutData(gridData);
131     //    webSettingsGroup.setLayout(gridLayout);
132
133     Composite webSettingsComposite = new Composite(composite, SWT.NULL);
134     webSettingsComposite.setLayout(new GridLayout());
135     webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
136     Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE);
137     webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup"));
138     webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
139     webSettingsGroup.setLayout(new GridLayout());
140
141     // new Label(webSettingsGroup, SWT.NONE);
142     externalBrowserBFE =
143       new BooleanFieldEditor(
144         IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF,
145         PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"),
146         webSettingsGroup);
147     externalBrowserBFE.setPreferencePage(this);
148     externalBrowserBFE.setPreferenceStore(getPreferenceStore());
149     externalBrowserBFE.load();
150     new Label(webSettingsGroup, SWT.NONE);
151     new Label(webSettingsGroup, SWT.NONE);
152     //  new Label(webSettingsGroup, SWT.NONE);
153     externalBrowserSFE =
154       new StringFieldEditor(
155         IPreferenceConstants.EXTERNAL_BROWSER_PREF,
156         PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"),
157         webSettingsGroup);
158     externalBrowserSFE.setPreferencePage(this);
159     externalBrowserSFE.setPreferenceStore(getPreferenceStore());
160     externalBrowserSFE.load();
161     new Label(webSettingsGroup, SWT.NONE);
162
163     localHostSFE =
164       new StringFieldEditor(
165         IPreferenceConstants.LOCALHOST_PREF,
166         PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"),
167         webSettingsGroup);
168     localHostSFE.setPreferencePage(this);
169     localHostSFE.setPreferenceStore(getPreferenceStore());
170     localHostSFE.load();
171     new Label(webSettingsGroup, SWT.NONE);
172
173     documentRootDFE =
174       new DirectoryFieldEditor(
175         IPreferenceConstants.DOCUMENTROOT_PREF,
176         PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"),
177         webSettingsGroup);
178     documentRootDFE.setPreferencePage(this);
179     documentRootDFE.setPreferenceStore(getPreferenceStore());
180     documentRootDFE.load();
181     //Create apache
182     Composite apacheSettingsComposite = new Composite(composite, SWT.NULL);
183     apacheSettingsComposite.setLayout(new GridLayout());
184     apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
185     Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE);
186     apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup"));
187     apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
188     apacheSettingsGroup.setLayout(new GridLayout());
189
190     apacheStartBFE =
191       new BooleanFieldEditor(
192         PHPeclipsePlugin.APACHE_START_BACKGROUND,
193         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start_background"),
194         apacheSettingsGroup);
195                 apacheStartBFE.setPreferencePage(this);
196                 apacheStartBFE.setPreferenceStore(getPreferenceStore());
197                 apacheStartBFE.load();
198                 
199     new Label(apacheSettingsGroup, SWT.NONE);
200     new Label(apacheSettingsGroup, SWT.NONE);
201     apacheStartSFE =
202       new StringFieldEditor(
203         IPreferenceConstants.APACHE_START_PREF,
204         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"),
205         apacheSettingsGroup);
206     apacheStartSFE.setPreferencePage(this);
207     apacheStartSFE.setPreferenceStore(getPreferenceStore());
208     apacheStartSFE.load();
209     new Label(apacheSettingsGroup, SWT.NONE);
210
211     apacheStopBFE =
212       new BooleanFieldEditor(
213         PHPeclipsePlugin.APACHE_STOP_BACKGROUND,
214         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop_background"),
215         apacheSettingsGroup);
216                 apacheStopBFE.setPreferencePage(this);
217                 apacheStopBFE.setPreferenceStore(getPreferenceStore());
218                 apacheStopBFE.load();
219     new Label(apacheSettingsGroup, SWT.NONE);
220     new Label(apacheSettingsGroup, SWT.NONE);
221     apacheStopSFE =
222       new StringFieldEditor(
223         IPreferenceConstants.APACHE_STOP_PREF,
224         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"),
225         apacheSettingsGroup);
226     apacheStopSFE.setPreferencePage(this);
227     apacheStopSFE.setPreferenceStore(getPreferenceStore());
228     apacheStopSFE.load();
229     new Label(apacheSettingsGroup, SWT.NONE);
230
231     apacheRestartBFE =
232       new BooleanFieldEditor(
233         PHPeclipsePlugin.APACHE_RESTART_BACKGROUND,
234         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart_background"),
235         apacheSettingsGroup);
236                 apacheRestartBFE.setPreferencePage(this);
237                 apacheRestartBFE.setPreferenceStore(getPreferenceStore());
238                 apacheRestartBFE.load();
239     new Label(apacheSettingsGroup, SWT.NONE);
240     new Label(apacheSettingsGroup, SWT.NONE);
241     apacheRestartSFE =
242       new StringFieldEditor(
243         IPreferenceConstants.APACHE_RESTART_PREF,
244         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"),
245         apacheSettingsGroup);
246     apacheRestartSFE.setPreferencePage(this);
247     apacheRestartSFE.setPreferenceStore(getPreferenceStore());
248     apacheRestartSFE.load();
249     new Label(apacheSettingsGroup, SWT.NONE);
250
251     apacheRunFFE =
252       new FileFieldEditor(
253         IPreferenceConstants.APACHE_RUN_PREF,
254         PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.run"),
255         apacheSettingsGroup);
256     apacheRunFFE.setPreferencePage(this);
257     apacheRunFFE.setPreferenceStore(getPreferenceStore());
258     apacheRunFFE.load();
259
260     phpRunFFE =
261       new FileFieldEditor(
262         IPreferenceConstants.PHP_RUN_PREF,
263         PHPPreferencesMessages.getString("PHPBasePreferencePage.console.php"),
264         apacheSettingsGroup);
265     phpRunFFE.setPreferencePage(this);
266     phpRunFFE.setPreferenceStore(getPreferenceStore());
267     phpRunFFE.load();
268
269     //Create mySQL
270     Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL);
271     mySQLSettingsComposite.setLayout(new GridLayout());
272     mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
273
274     Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE);
275     mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup"));
276     mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
277     mySQLSettingsGroup.setLayout(new GridLayout());
278
279     mysqlStartBFE =
280       new BooleanFieldEditor(
281         PHPeclipsePlugin.MYSQL_START_BACKGROUND,
282         PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.start_background"),
283         mySQLSettingsGroup);
284                 mysqlStartBFE.setPreferencePage(this);
285                 mysqlStartBFE.setPreferenceStore(getPreferenceStore());
286                 mysqlStartBFE.load();
287     new Label(mySQLSettingsGroup, SWT.NONE);
288     new Label(mySQLSettingsGroup, SWT.NONE);
289
290     mySQLCommandSFE =
291       new StringFieldEditor(
292         IPreferenceConstants.MYSQL_PREF,
293         PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"),
294         mySQLSettingsGroup);
295     mySQLCommandSFE.setPreferencePage(this);
296     mySQLCommandSFE.setPreferenceStore(getPreferenceStore());
297     mySQLCommandSFE.load();
298     new Label(mySQLSettingsGroup, SWT.NONE);
299
300     mysqlRunFFE =
301       new FileFieldEditor(
302         IPreferenceConstants.MYSQL_RUN_PREF,
303         PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.run"),
304         mySQLSettingsGroup);
305     mysqlRunFFE.setPreferencePage(this);
306     mysqlRunFFE.setPreferenceStore(getPreferenceStore());
307     mysqlRunFFE.load();
308
309 //    //Create parser settings composite
310 //    Composite parserSettingsComposite = new Composite(composite, SWT.NONE);
311 //    parserSettingsComposite.setLayout(new GridLayout());
312 //    parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
313 //    Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE);
314 //    parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers"));
315 //    parserSettingsGroup.setLayout(new GridLayout());
316 //    parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
317
318 //    chooseParser =
319 //      new RadioGroupFieldEditor(
320 //        IPreferenceConstants.PHP_PARSER_DEFAULT,
321 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"),
322 //        1,
323 //        new String[][] {
324 //          { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER },
325 //          {
326 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER }
327 //    }, parserSettingsGroup);
328 //    chooseParser.setPreferencePage(this);
329 //    chooseParser.setPreferenceStore(getPreferenceStore());
330 //    chooseParser.load();
331 //    //create a copmposte just for the StringEditor - makes layout simpler
332 //    Composite externalParserCompo = new Composite(parserSettingsGroup, SWT.NONE);
333 //    externalParserSFE =
334 //      new StringFieldEditor(
335 //        IPreferenceConstants.EXTERNAL_PARSER_PREF,
336 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.extcommand"),
337 //        externalParserCompo
338 //    /*parserSettingsGroup*/
339 //    );
340 //    externalParserSFE.setPreferencePage(this);
341 //    externalParserSFE.setPreferenceStore(getPreferenceStore());
342 //    externalParserSFE.load();
343 //
344 //    parseOnSave =
345 //      new BooleanFieldEditor(
346 //        PHPeclipsePlugin.PHP_PARSE_ON_SAVE,
347 //        PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.pos"),
348 //        parserSettingsGroup);
349 //    parseOnSave.setPreferencePage(this);
350 //    parseOnSave.setPreferenceStore(getPreferenceStore());
351 //    parseOnSave.load();
352
353     return composite;
354   }
355 }