Added syntax highlighting for variables in double quoted strings
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPStartXAMPPAction.java
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
7
8 Contributors:
9                 IBM Corporation - Initial implementation
10                 www.phpeclipse.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.actions;
13
14 import java.io.File;
15
16 import net.sourceforge.phpdt.externaltools.launchConfigurations.ExternalToolsUtil;
17 import net.sourceforge.phpeclipse.PHPConsole;
18 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
19
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.preference.IPreferenceStore;
22 import org.eclipse.jface.viewers.ISelection;
23 import org.eclipse.ui.IWorkbenchWindow;
24 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
25
26 public class PHPStartXAMPPAction implements IWorkbenchWindowActionDelegate {
27   protected IWorkbenchWindow activeWindow = null;
28
29   public void run(IAction action) {
30     final IPreferenceStore store =
31       PHPeclipsePlugin.getDefault().getPreferenceStore();
32     String executable = store.getString(PHPeclipsePlugin.XAMPP_START_PREF);
33     String workingDirectory = null;
34     if (executable!=null && executable.length()>0) {
35       int index = executable.lastIndexOf(File.separatorChar);
36       if (index>0) {
37         workingDirectory = executable.substring(0, index);
38       }
39     }
40     execute(
41       "xampp_start",
42       executable,
43       workingDirectory,
44       true);
45   }
46
47   /**
48          * Executes an external progam and saves the LaunchConfiguration under external tools 
49          * @param command external tools command name
50          * @param executable executable path i.e.c:\apache\apache.exe
51          * @param background run this configuration in background mode
52          */
53   public static void execute(
54     String command,
55     String executable,
56     String workingDirectory,
57     boolean background) {
58     PHPConsole console = new PHPConsole();
59     String consoleMessage;
60     if (background) {
61       consoleMessage =
62         "run in background mode-"
63           + command
64           + ": "
65           + executable;
66     } else {
67       consoleMessage =
68         "run in foreground mode-"
69           + command
70           + ": "
71           + executable;
72     }
73     console.println(consoleMessage);
74
75     ExternalToolsUtil.execute(command, executable, workingDirectory, null, background);
76   }
77   
78   public void selectionChanged(IAction action, ISelection selection) {
79
80   }
81
82   public void init(IWorkbenchWindow window) {
83     this.activeWindow = window;
84   }
85
86   public void dispose() {
87
88   }
89
90 }