[Esbox-commits] r121 - trunk/org.indt.esbox.core/src/org/indt/esbox/core

raul at garage.maemo.org raul at garage.maemo.org
Mon Oct 15 02:12:41 EEST 2007


Author: raul
Date: 2007-10-15 02:12:41 +0300 (Mon, 15 Oct 2007)
New Revision: 121

Modified:
   trunk/org.indt.esbox.core/src/org/indt/esbox/core/CoreActivator.java
   trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxMakeBuilder.java
   trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxScriptLauncher.java
   trunk/org.indt.esbox.core/src/org/indt/esbox/core/ErrorLogger.java
Log:


Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/CoreActivator.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/CoreActivator.java	2007-10-14 23:12:09 UTC (rev 120)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/CoreActivator.java	2007-10-14 23:12:41 UTC (rev 121)
@@ -24,6 +24,7 @@
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.internal.util.BundleUtility;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.indt.esbox.core.env.ESboxEnvironmentVariableManager;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 

Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxMakeBuilder.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxMakeBuilder.java	2007-10-14 23:12:09 UTC (rev 120)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxMakeBuilder.java	2007-10-14 23:12:41 UTC (rev 121)
@@ -163,7 +163,8 @@
 				
 				// Set the environmennt, some scripts may need the CWD var to be set.
 				
-				Properties props = new Properties();				
+				Properties props = launcher.getEnvironment();
+				props.putAll(info.getEnvironment());				
 				
 				Preferences preferences = CoreActivator.getDefault().getPluginPreferences();
 				String prefix = preferences.getString(ESboxPreferenceConstants.SBOX_SANDBOX.toString());

Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxScriptLauncher.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxScriptLauncher.java	2007-10-14 23:12:09 UTC (rev 120)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/ESboxScriptLauncher.java	2007-10-14 23:12:41 UTC (rev 121)
@@ -40,23 +40,39 @@
  */
 public class ESboxScriptLauncher {
 
+	// different wait methods for running autogen and configure
+	public final static int no_wait = 0;
+	public final static int wait_no_monitor = 1;
+	public final static int wait_with_monitor = 2;
+	
+	private static ESboxScriptLauncher singleton = null;	
+	private boolean xServerStarted;
+	private boolean maemoStarted;
+	
+	
 	/**
 	 * Constructor
 	 */
-	public ESboxScriptLauncher() {
+	private ESboxScriptLauncher() {
+		setMaemoStarted(false);		
+		setXServerStarted(false);		
 	}
+	
+	public static synchronized ESboxScriptLauncher getInstance() {
+		if (singleton == null)
+			singleton = new ESboxScriptLauncher();
+		return singleton;			
+	}
 
-	// different wait methods for running autogen and configure
-	public final static int no_wait = 0;
-	public final static int wait_no_monitor = 1;
-	public final static int wait_with_monitor = 2;
-
 	/**
 	 * Method that start X-environment for Scratchbox
 	 * @throws InterruptedException
 	 */
-	public void startX() throws InterruptedException {
+	public void startX() throws Exception {
 
+		if (isXServerStarted())
+			throw new ScratchboxException("X Server is already running");
+		
 		Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
 
 		// standard command launcher from CDT
@@ -94,13 +110,21 @@
 			// print all errors to console
 			new StreamMonitor(process.getErrorStream(), false, null);
 		}
+		setXServerStarted(true);
 	}
 
 	/**
 	 * Method that stop X-environment for Scratchbox
+	 * @throws ScratchboxException 
 	 */
-	public void stopX() {
+	public void stopX() throws ScratchboxException {
 
+		if (isMaemoStarted())
+			throw new ScratchboxException("Maemo is still running. Stop Maemo first");
+		
+		if (!isXServerStarted())
+			throw new ScratchboxException("X Server was not started. Start X Server first");
+		
 		// get preferences from SbCorePlugin
 		Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
 
@@ -135,9 +159,11 @@
 			// print all errors to console
 			new StreamMonitor(p.getErrorStream(), false, null);
 		}
+		
+		setXServerStarted(false);
 	}
 	
-	public static void killProcess(String processName) {
+	public void killProcess(String processName) {
 
 		// standard command launcher from CDT
 		CommandLauncher launcher = new CommandLauncher();
@@ -172,7 +198,7 @@
 	 * Method that run command autogen.sh and its location came from Parameter
 	 * "path"
 	 */
-	public static void runAutogen(IPath path) {
+	public void runAutogen(IPath path) {
 		runAutogen(path, no_wait, null);
 	}
 
@@ -184,7 +210,7 @@
 	 * @param wait
 	 * @param project
 	 */
-	public static void runAutogen(IPath path, int wait, IProject project) {
+	public void runAutogen(IPath path, int wait, IProject project) {
 		runScript(path, "autogen.sh", "Running automake script (autogen.sh)",
 				"Error running script autogen.sh", wait, project);
 
@@ -195,7 +221,7 @@
 	 * 
 	 * @param path
 	 */
-	public static void runConfigure(IPath path) {
+	public void runConfigure(IPath path) {
 		runConfigure(path, no_wait, null);
 	}
 
@@ -207,7 +233,7 @@
 	 * @param wait
 	 * @param project
 	 */
-	public static void runConfigure(IPath path, int wait, IProject project) {
+	public void runConfigure(IPath path, int wait, IProject project) {
 		runScript(path, "configure", "Running automake script (configure)",
 				"Error running script configure", wait, project);
 
@@ -223,7 +249,7 @@
 	 * @param wait
 	 * @param project
 	 */
-	public static void runScript(IPath path, String scriptname, String comment,
+	public void runScript(IPath path, String scriptname, String comment,
 			String errormessage, int wait, IProject project) {
 		String prefix = path.toOSString();
 		String separator = File.separator;
@@ -243,7 +269,7 @@
 	}
 
 	// LJA: This way this is now very useful piece of code
-	public static void runScriptWithArgsAndEnv(IPath path, String scriptname,
+	public void runScriptWithArgsAndEnv(IPath path, String scriptname,
 			String comment, String errormessage, String[] saEnv,
 			String[] saArgs, int wait, IProject project) {
 	
@@ -300,7 +326,7 @@
 	 * Method that run command make deb and its location came from 
 	 * Parameter "path" and if wait on true let's wait for process
 	 */
-	public static void makeDeb(IPath path, boolean wait) {
+	public void makeDeb(IPath path, boolean wait) {
 
 		String prefix = path.toOSString();
 		String separator = File.separator;
@@ -350,7 +376,7 @@
 		}
 	}
 
-	private static void verifyFiles(String[] files) throws ScratchboxException {
+	private void verifyFiles(String[] files) throws ScratchboxException {
 		for (int i = 0; i < files.length; i++) {
 			String fileName = files[i];
 			File file = new File(fileName);
@@ -360,7 +386,7 @@
 		}
 	}
 
-	public static void MakeDeb(IPath path) {
+	public void makeDebianPackage(IPath path) {
 		makeDeb(path, false);
 	}
 
@@ -369,7 +395,7 @@
 	 * to scratchbox console. Parameter string command is that command that
 	 * is executed.
 	 */
-	public static void runCommand(String path, String command) {
+	public void runCommand(String path, String command) {
 
 		// initialize variables
 		IPath wd = new Path(".");
@@ -401,9 +427,25 @@
 	 * finds executable name from path and delivers it forward
 	 * @param prefGazpachoBinPath
 	 */
-	public static void runCommand(String path) {
+	public void runCommand(String path) {
 		String command = path.substring(path.lastIndexOf('/'));
 		path = path.substring(0, path.lastIndexOf('/'));
 		runCommand(path, command);
 	}
+	
+	public boolean isMaemoStarted() {
+		return maemoStarted;
+	}
+	
+	public boolean isXServerStarted() {
+		return xServerStarted;
+	}
+	
+	public void setMaemoStarted(boolean isMaemoStarted) {
+		maemoStarted = isMaemoStarted;
+	}
+	
+	public void setXServerStarted(boolean isXServerStarted) {
+		xServerStarted = isXServerStarted;
+	}
 }

Modified: trunk/org.indt.esbox.core/src/org/indt/esbox/core/ErrorLogger.java
===================================================================
--- trunk/org.indt.esbox.core/src/org/indt/esbox/core/ErrorLogger.java	2007-10-14 23:12:09 UTC (rev 120)
+++ trunk/org.indt.esbox.core/src/org/indt/esbox/core/ErrorLogger.java	2007-10-14 23:12:41 UTC (rev 121)
@@ -14,6 +14,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 
 /**
@@ -34,9 +35,14 @@
 		IStatus status = new Status(IStatus.ERROR, pluginID, 0, exception
 				.getMessage(), exception);
 
-		Shell shell = getPlugin().getWorkbench().getActiveWorkbenchWindow()
-				.getShell();
+		System.out.println();
 		
+		IWorkbenchWindow window = getPlugin().getWorkbench().getActiveWorkbenchWindow();
+		Shell shell = null;
+		
+		if (window != null)
+			shell = window.getShell();
+		
 		ErrorDialog.openError(shell, "Error", mainMessage, status);
 
 	}



More information about the Esbox-commits mailing list