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.text.MessageFormat;
16 import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsUtil;
17 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
18 import net.sourceforge.phpeclipse.ui.WebUI;
19 import net.sourceforge.phpeclipse.views.PHPConsole;
21 import org.eclipse.jface.action.IAction;
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 =
32 PHPeclipsePlugin.getDefault().getPreferenceStore();
33 String documentRoot = store.getString(WebUI.PHP_DOCUMENTROOT_PREF);
34 // replace backslash with slash in the DocumentRoot under Windows
35 documentRoot = documentRoot.replace('\\', '/');
36 String[] arguments = { documentRoot };
38 new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF));
41 store.getString(PHPeclipsePlugin.APACHE_RUN_PREF),
42 form.format(arguments),
43 store.getBoolean(PHPeclipsePlugin.APACHE_START_BACKGROUND));
47 * Executes an external progam and saves the LaunchConfiguration under external tools
48 * @param command external tools command name
49 * @param executable executable path i.e.c:\apache\apache.exe
50 * @param arguments arguments for this configuration
51 * @param background run this configuration in background mode
53 public static void execute(
58 PHPConsole console = PHPConsole.getInstance();
59 String consoleMessage;
62 "run in background mode-"
70 "run in foreground mode-"
77 console.write(consoleMessage + "\n");
79 ExternalToolsUtil.execute(command, executable, arguments, background);
82 public void selectionChanged(IAction action, ISelection selection) {
86 public void init(IWorkbenchWindow window) {
87 this.activeWindow = window;
90 public void dispose() {