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
9 IBM Corporation - Initial implementation
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse;
14 import java.io.IOException;
15 import java.text.MessageFormat;
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;
34 public class PHPEclipsePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
36 public PHPEclipsePreferencePage() {
37 super(FieldEditorPreferencePage.GRID);
38 //Initialize the preference store we wish to use
39 setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
42 protected void createFieldEditors() {
43 Shell shell = getShell();
44 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
46 StringFieldEditor localhost = new StringFieldEditor(PHPeclipsePlugin.LOCALHOST_PREF, "&Localhost:", 60, getFieldEditorParent());
48 DirectoryFieldEditor documentRoot =
49 new DirectoryFieldEditor(PHPeclipsePlugin.DOCUMENTROOT_PREF, "&DocumentRoot:", getFieldEditorParent());
51 BooleanFieldEditor useExternalBrowser =
52 new BooleanFieldEditor(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF, "&Use External Browser", 60, getFieldEditorParent());
54 StringFieldEditor externalBrowser =
55 new StringFieldEditor(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF, "&External Browser command:", 60, getFieldEditorParent());
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) {
64 Runtime runtime = Runtime.getRuntime();
65 runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
66 } catch (IOException e1) {
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));
81 Runtime runtime = Runtime.getRuntime();
82 runtime.exec(form.format(arguments));
83 } catch (IOException e2) {
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) {
95 Runtime runtime = Runtime.getRuntime();
96 runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
97 } catch (IOException e1) {
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) {
109 Runtime runtime = Runtime.getRuntime();
110 runtime.exec(store.getString(PHPeclipsePlugin.MYSQL_PREF));
111 } catch (IOException e1) {
117 addField(documentRoot);
118 addField(useExternalBrowser);
119 addField(externalBrowser);
120 addField(startMySQL);
121 addField(startApache);
123 addField(stopApache);
124 addField(restartApache);
128 * @see IWorkbenchPreferencePage#init
130 public void init(IWorkbench workbench) {