[Esbox-commits] r403 - in trunk: org.indt.esbox.python.launch/META-INF org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind org.indt.esbox.ui/META-INF org.indt.esbox.ui/src/org/indt/esbox/ui org.indt.esbox.ui/src/org/indt/esbox/ui/dialogs org.indt.esbox.ui/src/org/indt/esbox/ui/views org.indt.esbox.ui/src/org/indt/esbox/ui/wizards

raul at garage.maemo.org raul at garage.maemo.org
Wed Feb 13 22:34:03 EET 2008


Author: raul
Date: 2008-02-13 22:33:58 +0200 (Wed, 13 Feb 2008)
New Revision: 403

Added:
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/dialogs/PasswordInputDialog.java
Removed:
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/connection/
Modified:
   trunk/org.indt.esbox.python.launch/META-INF/MANIFEST.MF
   trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java
   trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java
   trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
   trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
   trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java
Log:
Profile tools OK.

Modified: trunk/org.indt.esbox.python.launch/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.python.launch/META-INF/MANIFEST.MF	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.python.launch/META-INF/MANIFEST.MF	2008-02-13 20:33:58 UTC (rev 403)
@@ -17,5 +17,6 @@
  org.indt.esbox.core,
  org.eclipse.ui.ide,
  org.eclipse.cdt.core,
- org.indt.esbox.python.debug
+ org.indt.esbox.python.debug,
+ org.indt.esbox.ui
 Eclipse-LazyStart: true

Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/oprofile/OProfilePythonConfigurationDelegate.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -10,11 +10,27 @@
  *******************************************************************************/
 package org.indt.esbox.python.launch.oprofile;
 
+import java.util.List;
+
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ui.PartInitException;
+import org.indt.esbox.core.ESboxException;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.core.tool.ESboxToolEngine;
+import org.indt.esbox.core.tool.ITool;
+import org.indt.esbox.core.tool.IToolListener;
+import org.indt.esbox.core.tool.ToolRunnerInfo;
+import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
+import org.indt.esbox.python.launch.PythonLaunchActivator;
 import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
+import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
+import org.indt.esbox.ui.UIActivator;
 
 /**
  *
@@ -27,8 +43,7 @@
 	 */
 	@Override
 	protected String getPluginID() {
-		// TODO Auto-generated method stub
-		return null;
+		return PythonLaunchActivator.PLUGIN_ID;
 	}
 
 	/* (non-Javadoc)
@@ -37,8 +52,61 @@
 	@Override
 	public void launch(ILaunchConfiguration configuration, String mode,
 			ILaunch launch, IProgressMonitor monitor) throws CoreException {
-		// TODO Auto-generated method stub
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+		
+		monitor.beginTask("Launching the application on Device", 10);
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}
+		
+		IPath exePath = verifyProgramPath(configuration);
+		
+		ITool valgrind = ESboxToolEngine.getInstance().getTool("Valgrind")[0];		
+		ToolRunnerInfo valgrindInfo = null;
+		
+		try {
+			valgrindInfo = valgrind.getProvider().getRunner().createToolRunnerInfo();
+		} catch (ESboxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		boolean isRunStandalone = configuration.getAttribute(ESboxPythonLaunchConstants.ATTR_RUN_STANDALONE, ESboxPythonLaunchConstants.RUN_STANDALONE_DEFAULT);		
+			
+		String args[] = new String[] { "-q --tool=memcheck --leak-check=yes", isRunStandalone ? "run-standalone.sh " : "" , exePath.toOSString() };
+		
+		List<String> cmdArray = valgrindInfo.getCommandLine();
+		for (int i = 0; i < args.length; i++) {
+			cmdArray.add(args[i]);
+		}
+		
+		PythonLaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+			public void run() {
+				try {
+					ValgrindToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.valgrindView"));
+				} catch (PartInitException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		});
+		
+		ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
+		Process process = launcher.execute(valgrindInfo);
+		try {
+			valgrind.getProvider().getRunner().trackProcess(process);
+		} catch (ESboxException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+		monitor.worked(3);
+		DebugPlugin.newProcess(launch, process, renderProcessLabel(exePath.toOSString()));
 
+
 	}
 
 }

Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/remote/ESboxPythonRemoteConfigurationDelegate.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -32,7 +32,7 @@
 import org.indt.esbox.core.CoreActivator;
 import org.indt.esbox.core.ESboxPreferenceConstants;
 import org.indt.esbox.core.ErrorLogger;
-import org.indt.esbox.core.scratchbox.SbrshCommandLauncher;
+import org.indt.esbox.core.scratchbox.ESboxCommonCommandLauncher;
 import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
 import org.indt.esbox.python.debug.debugger.ESboxPythonDebugger;
 import org.indt.esbox.python.debug.debugger.ESboxPythonRemoteDebugger;
@@ -93,7 +93,7 @@
 			
 			// The launcher for running commands inside the Scratchbox
 			// environment
-			ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
+			ScratchboxCommandLauncher launcher = new ESboxCommonCommandLauncher();
 			File wd = getWorkingDirectory(configuration);
 			if (wd == null) {
 				wd = new File(System.getProperty("user.home", ".")); //$NON-NLS-1$ //$NON-NLS-2$

Modified: trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java
===================================================================
--- trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.python.launch/src/org/indt/esbox/python/launch/valgrind/ValgrindPythonConfigurationDelegate.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -19,14 +19,18 @@
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.ui.PartInitException;
 import org.indt.esbox.core.ESboxException;
 import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
 import org.indt.esbox.core.tool.ESboxToolEngine;
 import org.indt.esbox.core.tool.ITool;
+import org.indt.esbox.core.tool.IToolListener;
 import org.indt.esbox.core.tool.ToolRunnerInfo;
+import org.indt.esbox.core.tool.valgrind.ValgrindToolRunner;
 import org.indt.esbox.python.launch.PythonLaunchActivator;
 import org.indt.esbox.python.launch.internal.core.AbstractConfigurationDelegate;
 import org.indt.esbox.python.launch.internal.core.ESboxPythonLaunchConstants;
+import org.indt.esbox.ui.UIActivator;
 
 /**
  *
@@ -80,6 +84,17 @@
 			cmdArray.add(args[i]);
 		}
 		
+		PythonLaunchActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+			public void run() {
+				try {
+					ValgrindToolRunner.getInstance().addListener((IToolListener)UIActivator.getDefault().getView("org.indt.esbox.ui.views.valgrindView"));
+				} catch (PartInitException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		});
+		
 		ScratchboxCommandLauncher launcher = new ScratchboxCommandLauncher();
 		Process process = launcher.execute(valgrindInfo);
 		try {

Modified: trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.ui/META-INF/MANIFEST.MF	2008-02-13 20:33:58 UTC (rev 403)
@@ -19,11 +19,22 @@
  org.eclipse.ui.editors,
  org.eclipse.ui.ide,
  org.indt.esbox.core,
- com.jcraft.jsch,
  org.eclipse.ltk.core.refactoring
 Eclipse-LazyStart: true
 Export-Package: org.indt.esbox.ui,
- org.indt.esbox.ui.actions,
- org.indt.esbox.ui.connection,
- org.indt.esbox.ui.wizards
+ org.indt.esbox.ui.actions;
+  uses:="org.eclipse.jface.viewers,
+   org.eclipse.core.resources,
+   org.eclipse.jface.action,
+   org.eclipse.ui",
+ org.indt.esbox.ui.dialogs,
+ org.indt.esbox.ui.wizards;
+  uses:="org.eclipse.ui.wizards.newresource,
+   org.indt.esbox.ui,
+   org.eclipse.core.resources,
+   org.eclipse.jface.wizard,
+   org.eclipse.cdt.ui.templateengine,
+   org.eclipse.core.runtime,
+   org.eclipse.swt.widgets,
+   org.eclipse.cdt.ui.wizards"
 Bundle-Localization: plugin

Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/UIActivator.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -59,7 +59,6 @@
 	public void start(BundleContext context) throws Exception {
 		super.start(context);
 		plugin = this;
-		subscribeDefaultListeners();
 	}
 
 	/*
@@ -153,13 +152,11 @@
 		return (Template[]) templatesList.toArray(new Template[templatesList.size()]);
 	}
 	
-	private void subscribeDefaultListeners() throws PartInitException {
-		IWorkbench workbench = PlatformUI.getWorkbench();
+	public IViewPart getView(String viewID) throws PartInitException {		
+		IWorkbench workbench = this.getWorkbench();
 		IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-		IViewPart valgrindView = workbenchWindow.getActivePage().showView("org.indt.esbox.ui.views.valgrindView");
-		ValgrindToolRunner.getInstance().addListener((IToolListener)valgrindView);
-		
-		// add listeners to oprofile
+		IViewPart view = workbenchWindow.getActivePage().showView(viewID);
+		return view;
 	}
 	
 }

Added: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/dialogs/PasswordInputDialog.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/dialogs/PasswordInputDialog.java	                        (rev 0)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/dialogs/PasswordInputDialog.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2007 INdT.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Raul Herbster (raul at embedded.ufcg.edu.br) (UFCG) - initial API and implementation
+ *    
+ *******************************************************************************/
+
+package org.indt.esbox.ui.dialogs;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.indt.esbox.ui.UIActivator;
+
+/**
+ * 
+ */
+public class PasswordInputDialog extends Dialog {
+
+	protected Image keyLockImage;
+	
+	/**
+     * The title of the dialog.
+     */
+    protected String title;
+
+    /**
+     * The message to display, or <code>null</code> if none.
+     */
+    protected String message;
+    
+    /**
+     * The input value; the empty string by default.
+     */
+    protected String value = "";
+    
+    /**
+     * Ok button widget.
+     */
+    protected Button okButton;
+
+    /**
+     * Input text widget.
+     */
+    protected Text passwordField;
+    
+    /**
+     * Error message label widget.
+     */
+    private Text errorMessageText;
+    
+    /**
+     * Construtor.
+     * @param shell the shell.
+     * @param dialogTitle the title of the dialog.
+     * @param dialogMessage the message of the dialog.
+     */
+	public PasswordInputDialog(Shell shell, String dialogTitle,
+            String dialogMessage) {
+		super(shell);		
+		this.title = dialogTitle;		
+        this.message = dialogMessage;        
+	}
+	
+	 /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+     */
+    protected void configureShell(Shell shell) {
+        super.configureShell(shell);
+        if (title != null)
+            shell.setText(title);
+    }
+	
+	 /*
+     * (non-Javadoc) Method declared on Dialog.
+     */
+    protected void buttonPressed(int buttonId) {
+        if (buttonId == IDialogConstants.OK_ID) {
+            value = passwordField.getText();
+        } else {
+            value = null;
+        }
+        super.buttonPressed(buttonId);
+    }
+   
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+     */
+    protected void createButtonsForButtonBar(Composite parent) {
+        // create OK and Cancel buttons by default
+        okButton = createButton(parent, IDialogConstants.OK_ID,
+                IDialogConstants.OK_LABEL, true);
+        createButton(parent, IDialogConstants.CANCEL_ID,
+                IDialogConstants.CANCEL_LABEL, false);        
+    }
+    
+    /*
+     * (non-Javadoc) Method declared on Dialog.
+     */
+    protected Control createDialogArea(Composite parent) {
+    	Composite top = new Composite(parent, SWT.NONE);
+		GridLayout layout = new GridLayout();
+		layout.numColumns = 2;
+		
+		top.setLayout(layout);
+		top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+	
+		Composite imageComposite = new Composite(top, SWT.NONE);
+		layout = new GridLayout();
+		imageComposite.setLayout(layout);
+		imageComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+
+		Composite main = new Composite(top, SWT.NONE);
+		layout = new GridLayout();
+		layout.numColumns = 3;
+		main.setLayout(layout);
+		main.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+		
+		Label imageLabel = new Label(imageComposite, SWT.NONE);
+		keyLockImage = UIActivator.getImageDescriptor("./icons/keylock.gif").createImage();		
+		imageLabel.setImage(keyLockImage);
+		GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+		imageLabel.setLayoutData(data);
+        
+        // create message
+        if (message != null) {
+        	Label messageLabel = new Label(main, SWT.WRAP);
+			messageLabel.setText(message);
+			data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+			data.horizontalSpan = 3;
+			data.widthHint = 150;
+			messageLabel.setLayoutData(data);
+        }       
+                
+        Label separator = new Label(main,SWT.NONE);
+        data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+		data.horizontalSpan = 3;
+        separator.setText("");
+        separator.setLayoutData(data);
+        
+		createPasswordFields(main);    
+		
+		errorMessageText = new Text(main, SWT.READ_ONLY);
+        errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
+                | GridData.HORIZONTAL_ALIGN_FILL));
+        errorMessageText.setBackground(errorMessageText.getDisplay()
+                .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+
+        applyDialogFont(main);
+        
+        return main;
+    }
+    
+    /**
+	 * Creates the three widgets that represent the password entry area. 
+	 * @param parent  the parent of the widgets
+	 */
+	protected void createPasswordFields(Composite parent) {
+		new Label(parent, SWT.NONE).setText("Password: "); //$NON-NLS-1$
+		
+		passwordField = new Text(parent, SWT.BORDER | SWT.PASSWORD);
+		GridData data = new GridData(GridData.FILL_HORIZONTAL);		
+		data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+		passwordField.setLayoutData(data);
+	}	
+
+    /**
+     * Return the password inserted by the user.
+     * @return the password inserted by the user.
+     */
+    public String getPassword() {
+    	return value;
+    }
+    
+    /**
+     * Sets or clears the error message.
+     * If not <code>null</code>, the OK button is disabled.
+     * 
+     * @param errorMessage
+     *            the error message, or <code>null</code> to clear
+     */
+    public void setErrorMessage(String errorMessage) {
+        errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
+        okButton.setEnabled(errorMessage == null);
+        errorMessageText.getParent().update();
+    }
+}

Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/views/OProfileView.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -247,7 +247,6 @@
 				}
 			}			
 		}		
-		table.pack();
 	}
 	
 	public List<String> getTokens(String line) {
@@ -297,12 +296,16 @@
 	}
 
 	public void toolExecuted(ToolEvent event) {
-		Process process = (Process)event.getSource();
-		try {
-			fillTable(process.getInputStream());
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}		
+		final Process process = (Process)event.getSource();
+		UIActivator.getDefault().getWorkbench().getDisplay().syncExec(new Runnable() {
+			public void run() {
+				try {
+					fillTable(process.getInputStream());
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		});		
 	}
 }
\ No newline at end of file

Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizard.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -11,16 +11,21 @@
 
 package org.indt.esbox.ui.wizards;
 
-import java.io.IOException;
+import java.io.File;
 
+import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.Wizard;
+import org.indt.esbox.core.CoreActivator;
+import org.indt.esbox.core.ESboxPreferenceConstants;
 import org.indt.esbox.core.ESboxScriptLauncher;
-import org.indt.esbox.core.ErrorLogger;
 import org.indt.esbox.core.StreamMonitor;
-import org.indt.esbox.core.scratchbox.ScratchboxException;
-import org.indt.esbox.ui.UIActivator;
-import org.indt.esbox.ui.connection.ExecConnection;
-import org.indt.esbox.ui.connection.Sftp;
+import org.indt.esbox.core.scratchbox.ESboxCommonCommandLauncher;
+import org.indt.esbox.core.scratchbox.ScratchboxCommandLauncher;
+import org.indt.esbox.ui.dialogs.PasswordInputDialog;
 
 public class DeployDebianPackageWizard extends Wizard {
 
@@ -48,7 +53,11 @@
 			createDebianPackage();
 		}
 		if (deployPage.isInstallPackage()) {
-			copyPackage();
+			try {
+				copyPackage();
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
 			installDebianPackage();
 		}
 		
@@ -59,74 +68,53 @@
 		ESboxScriptLauncher.getInstance().makeDebianPackage(deployPage.getProject().getLocation());
 	}
 	
-//	private void copyPackage() throws InterruptedException {
-//		String packageLocation = deployPage.getPackageLocation();
-//		String packageName = (new Path(packageLocation)).lastSegment();
-//		String localMountPoint = deployPage.getLocalPoint();
-//		copyFile(packageLocation,localMountPoint + File.separatorChar + packageName);
-//	}
-//	
-//	private void installDebianPackage() {
-//		String packageLocation = deployPage.getPackageLocation();
-//		String packageName = (new Path(packageLocation)).lastSegment();
-//		String remoteMountPoint = deployPage.getInstallLocation();
-//		IPath dpkgCommand = new Path("dpkg");
-//		String args[] = new String[] { "-i", remoteMountPoint + File.separator + packageName };
-//		ScratchboxCommandLauncher launcher = new SbrshCommandLauncher();
-//		
-//		Process process = launcher.execute(dpkgCommand, args, new String[] { }, new Path("."));
-//		try {
-//			process.waitFor();
-//		} catch (InterruptedException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//	}
-//	
-//	private void copyFile(String src, String dst) throws InterruptedException {
-//		CommandLauncher launcher = new CommandLauncher();
-//		Process process = launcher.execute(new Path("cp"), new String[] {src, dst} , new String[] {} , new Path("."));
-//		
-//		process.waitFor();
-//	}
+	private void copyPackage() throws InterruptedException {
+		String packageLocation = deployPage.getPackageLocation();
+		String packageName = (new Path(packageLocation)).lastSegment();
+		String localMountPoint = deployPage.getLocalPoint();
+		copyFile(packageLocation,localMountPoint + File.separatorChar + packageName);
+	}
 	
-	private void installDebianPackage() {
-		ExecConnection execConnection = ExecConnection.getInstance();
-		execConnection.setCommand("dpkg -i " + getPackageRemoteLocation());
-		try {
-			execConnection.start();
+	private void installDebianPackage() {		
+		String packageLocation = deployPage.getPackageLocation();
+		String packageName = (new Path(packageLocation)).lastSegment();
+		String remoteMountPoint = deployPage.getInstallLocation();
+		String password = promptPassword();
+		
+		if (password != null) {			
+			Preferences prefs = CoreActivator.getDefault().getPluginPreferences();
+			IPath command = new Path(prefs.getString(ESboxPreferenceConstants.SBRSH_EXEC_FILE_LOCATION.toString()));
+			
+			IPath dpkgCommand = new Path("echo \"" + password + "\" | sudo -S ");
+			String args[] = new String[] { command.toOSString(), "dpkg", "-i", remoteMountPoint + File.separator + packageName };
+			ScratchboxCommandLauncher launcher = new ESboxCommonCommandLauncher();
+			
+			Process process = launcher.execute(dpkgCommand, args, new String[] { }, new Path("."));
 			// print all output to console
-			new StreamMonitor(execConnection.getInputStream(), true, new String(
-					"Installing .deb package"));
-			new StreamMonitor(execConnection.getErrInputStream(), true, new String(
-					"Installing .deb package"));
-		} catch (Exception e) {
-			ErrorLogger errorLogger = UIActivator.getDefault().getErrorLogger();
-			errorLogger.logAndShowError("Connection error", e);
+			new StreamMonitor(process.getInputStream(), true, "Installing .deb package");
+			// print all errors to console
+			new StreamMonitor(process.getErrorStream(), true, "Installing .deb package");
+			try {
+				process.waitFor();
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
 		}
-		execConnection.stop();
 	}
 	
-	private String getPackageRemoteLocation() {
-		String packageName = deployPage.getPackageLocation();
-		packageName = packageName.substring(packageName.lastIndexOf("/") + 1);
-		return deployPage.getInstallLocation() + "/" + packageName;
-	}
-
-	private void copyPackage() {
-		try {		
-			//open a sftp channel
-			Sftp sftp = new Sftp();
-			//start this channel
-			sftp.start();			
-			//get all the files and copy them to the remote directory
-			sftp.put(deployPage.getPackageLocation(),deployPage.getInstallLocation());			
-			sftp.stop();	
-		} catch (Exception e) {
-			e.printStackTrace();			
-			return;
-		} 
+	private void copyFile(String src, String dst) throws InterruptedException {
+		CommandLauncher launcher = new CommandLauncher();
+		Process process = launcher.execute(new Path("cp"), new String[] {src, dst} , new String[] {} , new Path("."));
 		
+		process.waitFor();
 	}
-
+	
+	private String promptPassword() {
+		PasswordInputDialog dialog = new PasswordInputDialog(getShell(),"Password","Insert root password to execute commands with superuser privileges");
+		if (dialog.open() == Window.OK)
+			return dialog.getPassword();
+		else
+			return null;
+	}
 }

Modified: trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java
===================================================================
--- trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java	2008-02-13 20:28:18 UTC (rev 402)
+++ trunk/org.indt.esbox.ui/src/org/indt/esbox/ui/wizards/DeployDebianPackageWizardPage.java	2008-02-13 20:33:58 UTC (rev 403)
@@ -12,8 +12,6 @@
 
 package org.indt.esbox.ui.wizards;
 
-import java.io.File;
-
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IAdaptable;
@@ -28,7 +26,6 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Label;



More information about the Esbox-commits mailing list