From 4fef3aa04c4ad19e7168aee14c9d4aba93737e93 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Wed, 30 May 2007 16:08:46 +0000 Subject: [PATCH] [189272] exception when canceling ssh connect --- .../rse/ui/messages/SystemMessageDialog.java | 7 ++++--- .../rse/ui/operations/SystemFetchOperation.java | 14 +++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java index 8e47f534d60..47704566528 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem * Martin Oberhuber (Wind River) - [187115] force SystemMessageDialog always into Display thread + * Martin Oberhuber (Wind River) - [189272] exception when canceling ssh connect ********************************************************************************/ package org.eclipse.rse.ui.messages; @@ -629,7 +630,7 @@ public class SystemMessageDialog extends ErrorDialog implements Listener { /** * For ease of use for simple messages which are the result of an exception */ - public static void displayErrorMessage(Shell shell, SystemMessage msg, Exception exc) + public static void displayErrorMessage(Shell shell, SystemMessage msg, Throwable exc) { SystemMessageDialog msgDlg = new SystemMessageDialog(shell, msg); msgDlg.setException(exc); @@ -723,7 +724,7 @@ public class SystemMessageDialog extends ErrorDialog implements Listener { /** * For displaying a generic error message when an unexpected exception happens. */ - public static void displayExceptionMessage(Shell shell, Exception exc) + public static void displayExceptionMessage(Shell shell, Throwable exc) { SystemMessage msg = getExceptionMessage(shell, exc); if ((shell == null) && (Display.getCurrent()!=null)) @@ -738,7 +739,7 @@ public class SystemMessageDialog extends ErrorDialog implements Listener { * When an exception occurs and you want to turn it into a SystemMessage, * call this... */ - public static SystemMessage getExceptionMessage(Shell shell, Exception exc) + public static SystemMessage getExceptionMessage(Shell shell, Throwable exc) { SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_EXCEPTION_OCCURRED); msg.makeSubstitution(exc); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/operations/SystemFetchOperation.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/operations/SystemFetchOperation.java index 4212dba43c3..2b1b25aceda 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/operations/SystemFetchOperation.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/operations/SystemFetchOperation.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry + * Martin Oberhuber (Wind River) - [189272] exception when canceling ssh connect ********************************************************************************/ package org.eclipse.rse.ui.operations; @@ -21,6 +22,7 @@ import java.net.URL; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; @@ -220,6 +222,12 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW protected void showOperationErrorMessage(Shell shell, Throwable exc, SubSystem ss) { + if (exc instanceof InvocationTargetException) { + exc = ((InvocationTargetException)exc).getTargetException(); + } + if (exc instanceof OperationCanceledException) { + return; //don't log or display user cancellation + } SystemMessage sysMsg = null; if (exc instanceof SystemMessageException) { @@ -234,11 +242,7 @@ public class SystemFetchOperation extends JobChangeAdapter implements IRunnableW sysMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED); sysMsg.makeSubstitution(excMsg); - - SystemMessageDialog msgDlg = new SystemMessageDialog(shell, sysMsg); - msgDlg.setException(exc); - msgDlg.open(); - //RSEUIPlugin.logError("Operation failed",exc); now done successfully in msgDlg.open() + SystemMessageDialog.displayErrorMessage(shell, sysMsg, exc); } }