[Esbox-commits] r865 - in trunk: common/org.maemo.esbox.launch/src/org/maemo/esbox/launch cpp/org.maemo.esbox.cpp.launch/src/org/maemo/esbox/cpp/launch/remote cpp/org.maemo.esbox.cpp.launch.dsf.gdb/src/org/maemo/esbox/cpp/launch/dsf/gdb/launch device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui python/org.maemo.esbox.python.launch/src/org/maemo/esbox/python/launch/remote

lwang at garage.maemo.org lwang at garage.maemo.org
Mon Oct 13 09:29:05 EEST 2008


Author: lwang
Date: 2008-10-13 09:29:04 +0300 (Mon, 13 Oct 2008)
New Revision: 865

Added:
   trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui/RSEConnectionSelectionDialog.java
Modified:
   trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/AbstractLaunchProtocolType.java
   trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/ILaunchProtocolType.java
   trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/LaunchProtocolFactory.java
   trunk/cpp/org.maemo.esbox.cpp.launch.dsf.gdb/src/org/maemo/esbox/cpp/launch/dsf/gdb/launch/RemoteLaunchShortcut.java
   trunk/cpp/org.maemo.esbox.cpp.launch/src/org/maemo/esbox/cpp/launch/remote/ESboxRemoteLaunchShortcut.java
   trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocolType.java
   trunk/python/org.maemo.esbox.python.launch/src/org/maemo/esbox/python/launch/remote/ESboxPythonRemoteRunLaunchShortcut.java
Log:
Added dialog for user to select RSE connection in LaunchShortcut.

Modified: trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/AbstractLaunchProtocolType.java
===================================================================
--- trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/AbstractLaunchProtocolType.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/AbstractLaunchProtocolType.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -12,6 +12,7 @@
 package org.maemo.esbox.launch;
 
 import org.eclipse.core.runtime.*;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.maemo.esbox.internal.launch.Activator;
 
 import java.text.MessageFormat;
@@ -85,4 +86,9 @@
 
 		return false;
 	}
+
+	public void interactiveConfigure(
+			ILaunchConfigurationWorkingCopy configuration) throws CoreException {
+		// do nothing 
+	}
 }

Modified: trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/ILaunchProtocolType.java
===================================================================
--- trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/ILaunchProtocolType.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/ILaunchProtocolType.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -65,4 +65,15 @@
 	 * @return
 	 */
 	public boolean recognize(String idOrName);
+	
+	/**
+	 * Offer UI (e.g. dialog) for user to set LaunchProtocolType specific parameters
+	 * for the given launch configuration. <br>
+	 * This is mainly called by launch shortcut. And caller should ensure this method
+	 * is called in UI thread.
+	 * 
+	 * @param configuration
+	 * @throws CoreException on any error or user cancellation.
+	 */
+	public void interactiveConfigure(ILaunchConfigurationWorkingCopy configuration) throws CoreException;
 }

Modified: trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/LaunchProtocolFactory.java
===================================================================
--- trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/LaunchProtocolFactory.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/common/org.maemo.esbox.launch/src/org/maemo/esbox/launch/LaunchProtocolFactory.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -256,7 +256,6 @@
 	 * 
 	 */
 	public void setDownloadMethod(ILaunchConfigurationWorkingCopy configuration, String idOrName) {
-		// Convert the given ID or name to standard ID
 		ILaunchProtocolType lpt = getLaunchProtocolTypeByID(idOrName);
 
 		if (lpt != null)
@@ -266,4 +265,29 @@
 		
 		configuration.setAttribute(IESboxCDTLaunchConfigurationConstants.ATTR_DOWNLOAD_METHOD, lpt.getID());
 	}
+	
+	/**
+	 * Ask user to configure the specified download method (namely launch protocol) in the
+	 * given launch configuration. <br>
+	 * This is mainly called by launch shortcut. And caller should ensure this method
+	 * is called in UI thread.
+	 * 
+	 * @param configuration
+	 * @param downloadMethodID 
+	 * 		- this can be ID or name of a launch protocol. Note both ID and name of a 
+	 * 		  launch protocol are unique.
+	 * @throws CoreException - thrown on error or user cancellation.
+	 * 
+	 */
+	public void interactiveConfigure(ILaunchConfigurationWorkingCopy configuration, String downloadMethodID) throws CoreException {
+
+		setDownloadMethod(configuration, downloadMethodID);
+		
+		// Now do protocol type specific configuration.
+		//
+		ILaunchProtocolType lpt = getLaunchProtocolTypeByID(downloadMethodID);
+
+		if (lpt != null)
+			lpt.interactiveConfigure(configuration);
+	}
 }

Modified: trunk/cpp/org.maemo.esbox.cpp.launch/src/org/maemo/esbox/cpp/launch/remote/ESboxRemoteLaunchShortcut.java
===================================================================
--- trunk/cpp/org.maemo.esbox.cpp.launch/src/org/maemo/esbox/cpp/launch/remote/ESboxRemoteLaunchShortcut.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/cpp/org.maemo.esbox.cpp.launch/src/org/maemo/esbox/cpp/launch/remote/ESboxRemoteLaunchShortcut.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -48,7 +48,7 @@
 		CppLaunchConfigurationData.setDefaults(config, IESboxCDTLaunchConfigurationConstants.CONFIG_TYPE_MAEMOREMOTE);
 		
 		if (fDownloadMethod != null)
-			LaunchProtocolFactory.getInstance().setDownloadMethod(config, fDownloadMethod);
+			LaunchProtocolFactory.getInstance().interactiveConfigure(config, fDownloadMethod);
 	}
 
 	@Override

Modified: trunk/cpp/org.maemo.esbox.cpp.launch.dsf.gdb/src/org/maemo/esbox/cpp/launch/dsf/gdb/launch/RemoteLaunchShortcut.java
===================================================================
--- trunk/cpp/org.maemo.esbox.cpp.launch.dsf.gdb/src/org/maemo/esbox/cpp/launch/dsf/gdb/launch/RemoteLaunchShortcut.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/cpp/org.maemo.esbox.cpp.launch.dsf.gdb/src/org/maemo/esbox/cpp/launch/dsf/gdb/launch/RemoteLaunchShortcut.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -53,7 +53,7 @@
 		DsfLaunchConfigurationData.setDefaults(config, IESboxCDTLaunchConfigurationConstants.CONFIG_TYPE_MAEMOREMOTE_DSF);
 
 		if (fDownloadMethod != null)
-			LaunchProtocolFactory.getInstance().setDownloadMethod(config, fDownloadMethod);
+			LaunchProtocolFactory.getInstance().interactiveConfigure(config, fDownloadMethod);
 	}
 
 }

Modified: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocolType.java
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocolType.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/RSELaunchProtocolType.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -14,15 +14,20 @@
 import java.text.MessageFormat;
 
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jface.window.Window;
 import org.eclipse.rse.core.RSECorePlugin;
 import org.eclipse.rse.core.model.IHost;
 import org.eclipse.rse.core.model.SystemStartHere;
 import org.maemo.esbox.core.JobUtils;
+import org.maemo.esbox.core.Policy;
+import org.maemo.esbox.core.JobUtils.IJob;
 import org.maemo.esbox.device.launch.SSHLaunchProtocolType;
+import org.maemo.esbox.device.launch.rse.ui.RSEConnectionSelectionDialog;
 import org.maemo.esbox.internal.device.launch.rse.Activator;
 import org.maemo.esbox.launch.AbstractLaunchProtocolType;
 import org.maemo.esbox.launch.ILaunchProtocol;
@@ -146,20 +151,21 @@
 		// Note we use JobUtils below to make sure the wait won't block UI thread.
 		//
 		//	................... LWang. 10/08/08
-		Thread thread = new Thread("Initializing RSE ...") {
-			@Override
-			public void run() {
-				try {
-					RSECorePlugin.waitForInitCompletion();
-				} catch (InterruptedException e) {
-					Activator.getDefault().getLog().log(new Status(IStatus.ERROR, 
-							Activator.getUniqueIdentifier(), 
-							"Wating for RSE initialization was interrupted."));
-				}
-			}
-		};
-		thread.start();
-		return JobUtils.waitForThread(thread, 10000,	null);
+		JobUtils.waitForRunnable(
+			new IJob() {
+				public IStatus run(IProgressMonitor monitor) {
+					try {
+						return RSECorePlugin.waitForInitCompletion();
+					} catch (InterruptedException e) {
+						return(new Status(IStatus.ERROR, 
+								Activator.getUniqueIdentifier(), 
+								"Waiting for RSE initialization was interrupted."));
+					}
+			}}, 
+			null, 
+			"Initializing RSE connections...");
+		
+		return true;
 	}
 
 	// This is called when the LaunchProtocolType extension is loaded.
@@ -199,4 +205,19 @@
 
 		return idOrName.contains("RSE");
 	}
+
+	@Override
+	public void interactiveConfigure(
+			ILaunchConfigurationWorkingCopy configuration) throws CoreException {
+
+		RSEConnectionSelectionDialog dialog = new RSEConnectionSelectionDialog(null);
+		if (dialog.open() == Window.OK) {
+			Object[] result = dialog.getResult();
+			if(result.length > 0) {
+				setRSEConnection(configuration, (String)result[0]);
+			}
+		}
+		else 
+			throw new CoreException(Policy.getCancelStatus(Activator.getDefault()));
+	}
 }

Added: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui/RSEConnectionSelectionDialog.java
===================================================================
--- trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui/RSEConnectionSelectionDialog.java	                        (rev 0)
+++ trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui/RSEConnectionSelectionDialog.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ling Wang (Nokia) - initial version. Oct, 2008
+ *******************************************************************************/
+package org.maemo.esbox.device.launch.rse.ui;
+
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.rse.core.model.IHost;
+import org.eclipse.rse.core.model.SystemStartHere;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ListDialog;
+import org.maemo.esbox.launch.IESboxLaunchHelpContextID;
+
+/**
+ * Dialog asking user to choose the RSE connection to use for RSE-based download.
+ * The dialog has two parts. One part lists the options for user to select.
+ * The other part displays description for the current selected option. 
+ * 
+ * @author LWang.
+ */
+public class RSEConnectionSelectionDialog extends ListDialog {
+
+		// Ask user to choose download method.
+		String[] fConnnectionNames;
+		
+		// Must match the order of the above array element.
+		String[] fConnectionDesc;
+
+		/**
+		 * The list of input for the dialog
+		 */
+		private Text fDescriptionText = null;
+		
+		ILabelProvider provider = new LabelProvider() {
+			/**
+			 * The <code>LabelProvider</code> implementation of this 
+			 * <code>ILabelProvider</code> method returns the element's <code>toString</code>
+			 * string. Subclasses may override.
+			 */
+			public String getText(Object element) {
+				if (element == null) {
+					return ""; //$NON-NLS-1$
+				} else if (element instanceof String) {
+					return (String)element;
+				}
+				return element.toString();
+			}
+		};
+
+		/**
+		 * Constructor
+		 * @param input
+		 * @param resource
+		 * @param mode
+		 */
+		public RSEConnectionSelectionDialog(Shell shell) {
+			super(shell);
+			
+			IHost[] hosts = SystemStartHere.getConnections();
+
+			fConnnectionNames = new String[hosts.length];
+			fConnectionDesc = new String[hosts.length];
+			
+			for (int i=0; i < hosts.length; i++) {
+				fConnnectionNames[i] = hosts[i].getAliasName();
+				fConnectionDesc[i] = hosts[i].getDescription();
+			}
+			
+			setShellStyle(getShellStyle() | SWT.RESIZE);
+			setTitle("RSE Connection Selection");
+			setAddCancelButton(true);
+			setMessage("Please choose which RSE connection to use:");
+			setLabelProvider(provider);
+			setContentProvider(new ArrayContentProvider());
+			
+			setInput(fConnnectionNames);
+		}
+
+		/**
+		 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
+		 */
+		protected Control createContents(Composite parent) {
+			Composite comp = (Composite) super.createContents(parent);
+			PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IESboxLaunchHelpContextID.DOWNLOAD_METHOD_SELECTION_DIALOG);
+			return comp;
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
+		 */
+		protected Point getInitialSize() {
+			return new Point(450, 550);
+		}
+		
+		/**
+		 * @see org.eclipse.ui.dialogs.ListDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+		 */
+		protected void createButtonsForButtonBar(Composite parent) {
+			super.createButtonsForButtonBar(parent);
+			getOkButton().setEnabled(false);
+			getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
+				public void selectionChanged(SelectionChangedEvent event) {
+					getOkButton().setEnabled(!event.getSelection().isEmpty());
+				}	
+			});
+		}
+		
+		/**
+		 * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+		 */
+		protected Control createDialogArea(Composite container) {
+			Composite comp = (Composite) super.createDialogArea(container);
+			
+	    	Group group = new Group(comp, SWT.NONE);
+	    	group.setLayout(new GridLayout(1, false));
+	    	group.setText("Description");
+			GridData gd = new GridData(GridData.FILL_BOTH);
+			gd.heightHint = 120;
+			group.setLayoutData(gd);
+			
+			fDescriptionText = new Text(group, SWT.WRAP | SWT.READ_ONLY);
+			gd = new GridData(GridData.FILL_BOTH);
+			fDescriptionText.setLayoutData(gd);
+			fDescriptionText.setBackground(group.getBackground());
+			getTableViewer().getTable().addSelectionListener(new SelectionListener() {
+				public void widgetDefaultSelected(SelectionEvent e) {}
+				public void widgetSelected(SelectionEvent e) {
+					Object o = e.item.getData();
+					if(o instanceof String) {
+						int idx = 0;
+						while (idx < fConnnectionNames.length) {
+							if (fConnnectionNames[idx].equals(o))
+								break;
+							idx++;
+						}
+						String txt = fConnectionDesc[idx];
+						fDescriptionText.setText(txt); 
+					}
+				}
+			});
+			return comp;
+		}
+	}


Property changes on: trunk/device/org.maemo.esbox.device.launch.rse/src/org/maemo/esbox/device/launch/rse/ui/RSEConnectionSelectionDialog.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/python/org.maemo.esbox.python.launch/src/org/maemo/esbox/python/launch/remote/ESboxPythonRemoteRunLaunchShortcut.java
===================================================================
--- trunk/python/org.maemo.esbox.python.launch/src/org/maemo/esbox/python/launch/remote/ESboxPythonRemoteRunLaunchShortcut.java	2008-10-12 05:07:18 UTC (rev 864)
+++ trunk/python/org.maemo.esbox.python.launch/src/org/maemo/esbox/python/launch/remote/ESboxPythonRemoteRunLaunchShortcut.java	2008-10-13 06:29:04 UTC (rev 865)
@@ -43,7 +43,7 @@
 		PythonLaunchConfigurationData.setDefaults(config, IESboxPythonLaunchConstants.CONFIG_TYPE_MAEMOREMOTE);
 		
 		if (fDownloadMethod != null) {
-			LaunchProtocolFactory.getInstance().setDownloadMethod(config, fDownloadMethod);
+			LaunchProtocolFactory.getInstance().interactiveConfigure(config, fDownloadMethod);
 			
 			// in SSH mode, directory structure is different, so don't set up a working directory
 			if (LaunchProtocolFactory.getInstance().isSSHProtocol(fDownloadMethod)) {



More information about the Esbox-commits mailing list