improved syntax highligthing
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPEclipsePreferencePage.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. 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 implementation
10     Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse;
13
14 import java.io.IOException;
15 import java.text.MessageFormat;
16
17 import org.eclipse.jface.preference.BooleanFieldEditor;
18 import org.eclipse.jface.preference.DirectoryFieldEditor;
19 import org.eclipse.jface.preference.FieldEditorPreferencePage;
20 import org.eclipse.jface.preference.IPreferenceStore;
21 import org.eclipse.jface.preference.StringFieldEditor;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.events.SelectionAdapter;
24 import org.eclipse.swt.events.SelectionEvent;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Shell;
27 import org.eclipse.ui.IWorkbench;
28 import org.eclipse.ui.IWorkbenchPreferencePage;
29
30 /**
31  * 
32  * @author khartlage
33  */
34 public class PHPEclipsePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
35
36         public PHPEclipsePreferencePage() {
37                 super(FieldEditorPreferencePage.GRID);
38                 //Initialize the preference store we wish to use
39                 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
40         }
41
42         protected void createFieldEditors() {
43                 Shell shell = getShell();
44                 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
45
46                 StringFieldEditor localhost = new StringFieldEditor(PHPeclipsePlugin.LOCALHOST_PREF, "&Localhost:", 60, getFieldEditorParent());
47
48                 DirectoryFieldEditor documentRoot =
49                         new DirectoryFieldEditor(PHPeclipsePlugin.DOCUMENTROOT_PREF, "&DocumentRoot:", getFieldEditorParent());
50
51                 BooleanFieldEditor useExternalBrowser =
52                         new BooleanFieldEditor(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF, "&Use External Browser", 60, getFieldEditorParent());
53
54                 StringFieldEditor externalBrowser =
55                         new StringFieldEditor(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF, "&External Browser command:", 60, getFieldEditorParent());
56
57                 StringFieldEditor startMySQL =
58                         new StringFieldEditor(PHPeclipsePlugin.MYSQL_PREF, "&MySQL command:", 60, getFieldEditorParent());
59 //              Button button = new Button(shell, SWT.PUSH);
60 //              button.setText("Start MySQL");
61 //              button.addSelectionListener(new SelectionAdapter() {
62 //                      public void widgetSelected(SelectionEvent e) {
63 //                              try {
64 //                                      Runtime runtime = Runtime.getRuntime();
65 //                                      runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
66 //                              } catch (IOException e1) {
67 //                              }
68 //                      }
69 //              });
70
71                 StringFieldEditor startApache =
72                         new StringFieldEditor(PHPeclipsePlugin.APACHE_START_PREF, "Start &Apache command:", 60, getFieldEditorParent());
73 //              Button startButton = new Button(shell, SWT.PUSH);
74 //              startButton.setText("Start Apache");
75 //              startButton.addSelectionListener(new SelectionAdapter() {
76 //                      public void widgetSelected(SelectionEvent e) {
77 //                              String[] arguments = { store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF)};
78 //                              MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF));
79 //
80 //                              try {
81 //                                      Runtime runtime = Runtime.getRuntime();
82 //                                      runtime.exec(form.format(arguments));
83 //                              } catch (IOException e2) {
84 //                              }
85 //                      }
86 //              });
87
88                 StringFieldEditor stopApache =
89                         new StringFieldEditor(PHPeclipsePlugin.APACHE_STOP_PREF, "&Stop Apache command:", 60, getFieldEditorParent());
90     Button stopButton = new Button(shell, SWT.PUSH);
91     stopButton.setText("Stop Apache");
92     stopButton.addSelectionListener(new SelectionAdapter() {
93       public void widgetSelected(SelectionEvent e) {
94         try {
95           Runtime runtime = Runtime.getRuntime();
96           runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
97         } catch (IOException e1) {
98         }
99       }
100     });
101     
102                 StringFieldEditor restartApache =
103                         new StringFieldEditor(PHPeclipsePlugin.APACHE_RESTART_PREF, "&Restart Apache command:", 60, getFieldEditorParent());
104     Button restartButton = new Button(shell, SWT.PUSH);
105     restartButton.setText("Restart Apache");
106     restartButton.addSelectionListener(new SelectionAdapter() {
107       public void widgetSelected(SelectionEvent e) {
108         try {
109           Runtime runtime = Runtime.getRuntime();
110           runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
111         } catch (IOException e1) {
112         }
113       }
114     });
115     
116                 addField(localhost);
117                 addField(documentRoot);
118                 addField(useExternalBrowser);
119                 addField(externalBrowser);
120                 addField(startMySQL);
121                 addField(startApache);
122 //    add(startButton);
123                 addField(stopApache);
124                 addField(restartApache);
125         }
126
127         /**
128          * @see IWorkbenchPreferencePage#init
129          */
130         public void init(IWorkbench workbench) {
131         }
132
133 }