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