X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java new file mode 100644 index 0000000..7f69883 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java @@ -0,0 +1,62 @@ +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse.actions; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.MessageFormat; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { + protected IWorkbenchWindow activeWindow = null; + + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + // replace backslash with slash in the DocumentRoot under Windows + documentRoot = documentRoot.replace('\\', '/'); + String[] arguments = { documentRoot }; + MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF)); + execute(form.format(arguments)); + } + + public void execute(String command) { +// MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); + try { + Runtime runtime = Runtime.getRuntime(); + // Process process = runtime.exec(new String[] { "c:\\apache\\apache.exe" }); + Process process = runtime.exec(command); + } catch (IOException e) { + MessageDialog.openInformation(activeWindow.getShell(), "IOException: ", e.getMessage()); + } + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + + public void init(IWorkbenchWindow window) { + this.activeWindow = window; + } + + public void dispose() { + + } +}