Added some configurations constants to show or not class, vars and functions in outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / actions / PHPStartApacheAction.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     Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.actions;
13
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.text.MessageFormat;
17
18 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
19 import net.sourceforge.phpeclipse.views.PHPConsole;
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IStatus;
22 import org.eclipse.core.runtime.Status;
23 import org.eclipse.jface.action.IAction;
24 import org.eclipse.jface.preference.IPreferenceStore;
25 import org.eclipse.jface.viewers.ISelection;
26 import org.eclipse.ui.IWorkbenchPage;
27 import org.eclipse.ui.IWorkbenchWindow;
28 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
29 import org.eclipse.ui.PartInitException;
30 import org.eclipse.ui.PlatformUI;
31 import sun.security.krb5.internal.crypto.e;
32
33 public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate {
34   protected IWorkbenchWindow activeWindow = null;
35
36   public void run(IAction action) {
37     final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore();
38     String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF);
39     // replace backslash with slash in the DocumentRoot under Windows
40     documentRoot = documentRoot.replace('\\', '/');
41     String[] arguments = { documentRoot };
42     MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF));
43     execute(form.format(arguments), "Start Apache: ");
44   }
45
46   public static String execute(String command, String consoleMessage) {
47     //          MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command);
48     try {
49       PHPConsole.write(consoleMessage+command+"\n");
50       Runtime runtime = Runtime.getRuntime();
51
52           // runs the command
53       Process p = runtime.exec(command);
54
55       // gets the input stream to have the post-compile-time information
56       InputStream stream = p.getInputStream();
57
58       // get the string from Stream
59       String consoleOutput = PHPConsole.getStringFromStream(stream);
60
61       // prints out the information
62       PHPConsole.write(consoleOutput);
63       return consoleOutput;
64
65     } catch (IOException e) {
66      
67       System.err.println("Problem");
68       e.printStackTrace();
69
70     }
71     return "";
72   }
73
74   public void selectionChanged(IAction action, ISelection selection) {
75
76   }
77
78   public void init(IWorkbenchWindow window) {
79     this.activeWindow = window;
80   }
81
82   public void dispose() {
83
84   }
85 }