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.actions;
14 import java.io.BufferedReader;
15 import java.io.IOException;
16 import java.io.InputStreamReader;
17 import java.text.MessageFormat;
19 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.dialogs.MessageDialog;
22 import org.eclipse.jface.preference.IPreferenceStore;
23 import org.eclipse.jface.viewers.ISelection;
24 import org.eclipse.ui.IWorkbenchWindow;
25 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
27 public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate {
28 protected IWorkbenchWindow activeWindow = null;
30 public void run(IAction action) {
31 final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
32 String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
33 // replace backslash with slash in the DocumentRoot under Windows
34 documentRoot = documentRoot.replace('\\', '/');
35 String[] arguments = { documentRoot };
36 MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF));
37 execute(form.format(arguments));
40 public void execute(String command) {
41 // MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command);
43 Runtime runtime = Runtime.getRuntime();
44 // Process process = runtime.exec(new String[] { "c:\\apache\\apache.exe" });
45 Process process = runtime.exec(command);
46 } catch (IOException e) {
47 MessageDialog.openInformation(activeWindow.getShell(), "IOException: ", e.getMessage());
51 public void selectionChanged(IAction action, ISelection selection) {
55 public void init(IWorkbenchWindow window) {
56 this.activeWindow = window;
59 public void dispose() {