Organized imports.
[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
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.preference.IPreferenceStore;
17 import org.eclipse.jface.viewers.ISelection;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
20
21 public class PHPStartXAMPPAction implements IWorkbenchWindowActionDelegate {
22   protected IWorkbenchWindow activeWindow = null;
23
24   public void run(IAction action) {
25     final IPreferenceStore store = ExternalToolsPlugin.getDefault().getPreferenceStore();
26     String executable = store.getString(ExternalToolsPlugin.XAMPP_START_PREF);
27     String workingDirectory = null;
28     if (executable != null && executable.length() > 0) {
29       int index = executable.lastIndexOf(File.separatorChar);
30       if (index > 0) {
31         workingDirectory = executable.substring(0, index);
32       }
33     }
34     execute("xampp_start", executable, workingDirectory, true);
35   }
36
37   /**
38    * Executes an external progam and saves the LaunchConfiguration under external tools
39    * 
40    * @param command
41    *          external tools command name
42    * @param executable
43    *          executable path i.e.c:\apache\apache.exe
44    * @param background
45    *          run this configuration in background mode
46    */
47   public static void execute(String command, String executable, String workingDirectory, boolean background) {
48 //    PHPConsole console = new PHPConsole();
49 //    String consoleMessage;
50 //    if (background) {
51 //      consoleMessage = "run in background mode-" + command + ": " + executable;
52 //    } else {
53 //      consoleMessage = "run in foreground mode-" + command + ": " + executable;
54 //    }
55 //    console.println(consoleMessage);
56
57     ExternalToolsUtil.execute(command, executable, workingDirectory, null, background);
58   }
59
60   public void selectionChanged(IAction action, ISelection selection) {
61
62   }
63
64   public void init(IWorkbenchWindow window) {
65     this.activeWindow = window;
66   }
67
68   public void dispose() {
69
70   }
71
72 }