1 /***********************************************************************************************************************************
2 * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made
3 * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
4 * http://www.eclipse.org/legal/cpl-v10.html
6 * Contributors: IBM Corporation - Initial implementation www.phpeclipse.de
7 **********************************************************************************************************************************/
8 package net.sourceforge.phpdt.externaltools.actions;
10 import java.text.MessageFormat;
12 import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsUtil;
13 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
14 import net.sourceforge.phpeclipse.ui.WebUI;
16 import org.eclipse.jface.action.IAction;
17 import org.eclipse.jface.preference.IPreferenceStore;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.ui.IWorkbenchWindow;
20 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
22 public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate {
23 protected IWorkbenchWindow activeWindow = null;
25 public void run(IAction action) {
26 final IPreferenceStore store = ExternalToolsPlugin.getDefault().getPreferenceStore();
27 String documentRoot = store.getString(WebUI.PHP_DOCUMENTROOT_PREF);
28 // replace backslash with slash in the DocumentRoot under Windows
29 documentRoot = documentRoot.replace('\\', '/');
30 String[] arguments = { documentRoot };
31 MessageFormat form = new MessageFormat(store.getString(ExternalToolsPlugin.APACHE_START_PREF));
32 execute("apache_start", store.getString(ExternalToolsPlugin.APACHE_RUN_PREF), form.format(arguments), store
33 .getBoolean(ExternalToolsPlugin.APACHE_START_BACKGROUND));
37 * Executes an external progam and saves the LaunchConfiguration under external tools
40 * external tools command name
42 * executable path i.e.c:\apache\apache.exe
44 * arguments for this configuration
46 * run this configuration in background mode
48 public static void execute(String command, String executable, String arguments, boolean background) {
49 // PHPConsole console = new PHPConsole();
50 // String consoleMessage;
52 // consoleMessage = "run in background mode-" + command + ": " + executable + " " + arguments;
54 // consoleMessage = "run in foreground mode-" + command + ": " + executable + " " + arguments;
56 // console.println(consoleMessage);
58 ExternalToolsUtil.execute(command, executable, arguments, background);
61 public void selectionChanged(IAction action, ISelection selection) {
65 public void init(IWorkbenchWindow window) {
66 this.activeWindow = window;
69 public void dispose() {