diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java index 5cf066ac8c9..6bc040edc9f 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java @@ -28,6 +28,7 @@ * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [220123] [api][dstore] Configurable timeout on irresponsiveness * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception *******************************************************************************/ package org.eclipse.rse.connectorservice.dstore; @@ -44,6 +45,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.dstore.core.client.ClientConnection; import org.eclipse.dstore.core.client.ConnectionStatus; import org.eclipse.dstore.core.java.IRemoteClassInstance; @@ -1070,7 +1072,7 @@ public class DStoreConnectorService extends StandardConnectorService implements { acquireCredentials(true); } - catch (InterruptedException e) + catch (OperationCanceledException e) { connectException = e; } @@ -1078,7 +1080,7 @@ public class DStoreConnectorService extends StandardConnectorService implements }); // Check if the user cancelled the prompt - if (connectException instanceof InterruptedException) + if (connectException instanceof OperationCanceledException) { throw connectException; } @@ -1215,7 +1217,7 @@ public class DStoreConnectorService extends StandardConnectorService implements { acquireCredentials(true); } - catch (InterruptedException e) + catch (OperationCanceledException e) { connectException = e; } @@ -1223,7 +1225,7 @@ public class DStoreConnectorService extends StandardConnectorService implements }); // Check if the user cancelled the prompt - if (connectException instanceof InterruptedException) + if (connectException instanceof OperationCanceledException) { throw connectException; } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java index cc3d8594d8f..ad1aa8bd967 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java @@ -13,10 +13,12 @@ * David Dykstal (IBM) - 142806: refactoring persistence framework * Martin Oberhuber (Wind River) - [185750] Remove IConnectorService.getHostType() * David Dykstal (IBM) - [210474] Deny save password function missing + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.IRSEPersistableContainer; @@ -446,7 +448,7 @@ public abstract class AbstractDelegatingConnectorService implements IDelegatingC * @see org.eclipse.rse.core.subsystems.IConnectorService#acquireCredentials(boolean) */ public void acquireCredentials(boolean forcePrompt) - throws InterruptedException { + throws OperationCanceledException { IConnectorService conServ = getRealConnectorService(); if (conServ != null) { diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java index fa5a8ea9c61..3e37951bc7f 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/AuthenticatingConnectorService.java @@ -10,12 +10,14 @@ * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * David Dykstal (IBM) - [210474] Deny save password function missing + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.PasswordPersistenceManager; @@ -185,7 +187,7 @@ public abstract class AuthenticatingConnectorService extends AbstractConnectorSe * @param reacquire if true will cause the credentials to be reobtained if necessary. * @see org.eclipse.rse.core.subsystems.IConnectorService#acquireCredentials(boolean) */ - public final void acquireCredentials(boolean reacquire) throws InterruptedException { + public final void acquireCredentials(boolean reacquire) throws OperationCanceledException { credentialsProvider.acquireCredentials(reacquire); } diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java index 765977de6c6..24d31ba7ee3 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/BasicConnectorService.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2007 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2008 IBM 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 @@ -12,9 +12,11 @@ * * Contributors: * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.core.model.IHost; /** @@ -85,7 +87,7 @@ public abstract class BasicConnectorService extends AbstractConnectorService { * This implmentation does nothing. * @see org.eclipse.rse.core.subsystems.IConnectorService#acquireCredentials(boolean) */ - public void acquireCredentials(boolean refresh) throws InterruptedException { + public void acquireCredentials(boolean refresh) throws OperationCanceledException { } /** diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java index ce6ceb30f1f..6acfa22c2bb 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IConnectorService.java @@ -17,11 +17,13 @@ * Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect() * Martin Oberhuber (Wind River) - [cleanup] Add API "since" Javadoc tags * David Dykstal (IBM) - [210474] Deny save password function missing + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.IRSEModelObject; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; @@ -87,7 +89,8 @@ public interface IConnectorService extends IRSEModelObject { * @param monitor a monitor for tracking the progress and canceling a connect * operation. * @throws Exception an exception of there is a failure to connect. - * Typically, this will be a {@link SystemMessageException}. + * Typically, this will be a {@link SystemMessageException}. + * If the connect was canceled by the user this will be an {@link OperationCanceledException} */ public void connect(IProgressMonitor monitor) throws Exception; @@ -127,7 +130,7 @@ public interface IConnectorService extends IRSEModelObject { /** * Sets the host used by this connector service. - * @param host + * @param host the host to be used for this connector service */ public void setHost(IHost host); @@ -274,12 +277,12 @@ public interface IConnectorService extends IRSEModelObject { * Implementations may retain a remembered credentials or * use this acquire the credentials using some implementation defined means. *

- * Throws InterruptedException if acquisition of the + * Throws {@link OperationCanceledException} if acquisition of the * credentials is canceled or is being suppressed. * @param refresh if true will force the connector service to discard * any remembered value and reacquire the credentials. */ - public void acquireCredentials(boolean refresh) throws InterruptedException; + public void acquireCredentials(boolean refresh) throws OperationCanceledException; /** * @return true if the acquisition of credentials is being suppressed. @@ -391,8 +394,7 @@ public interface IConnectorService extends IRSEModelObject { * If set to true, it will clear any saved passwords for this system and not allow any further * passwords to be stored. * This property of a system is persistent from session to session, but is not sharable. - * @param deny - * If true, forget any saved passwords and do not allow any others to be saved. + * @param deny If true, forget any saved passwords and do not allow any others to be saved. * If false, allow passwords to be saved in the keychain. * @return the number of saved passwords removed by this operation. * This will always be zero if "deny" is false. diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java index c0d541294a6..ebe8e0ffba3 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ICredentialsProvider.java @@ -1,14 +1,16 @@ /******************************************************************************** - * Copyright (c) 2007 IBM Corporation. All rights reserved. + * Copyright (c) 2007, 2008 IBM 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 * * Initial Contributors: * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.rse.services.clientserver.messages.SystemMessage; /** @@ -37,12 +39,12 @@ public interface ICredentialsProvider { * @param reacquire true if the provider should refresh any remembered * credentials. Typically used to force the showing of a dialog containing * remembered credentials. - * @throws InterruptedException if the acquisition of credentials is + * @throws OperationCanceledException if the acquisition of credentials is * canceled by the user, if the provider is in suppressed state, * a resource (such as the workbench) not being available, * or interrupted by some other means. */ - void acquireCredentials(boolean reacquire) throws InterruptedException; + void acquireCredentials(boolean reacquire) throws OperationCanceledException; /** * The connector service using this provider may find the credentials provided @@ -51,11 +53,11 @@ public interface ICredentialsProvider { * an expired password. * @param message the message indicating the nature of the damage that must * be repaired. For example, indicating expiration of a password. - * @throws InterruptedException if the repair is canceled for some reason. This could + * @throws OperationCanceledException if the repair is canceled for some reason. This could * include the inability of a credentials provider to open a dialog or a dialog being * canceled. */ - void repairCredentials(SystemMessage message)throws InterruptedException; + void repairCredentials(SystemMessage message)throws OperationCanceledException; /** * Clears the credentials known by this credentials provider. This will diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystem.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystem.java index cb9a8b9f23f..e18281cc53c 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystem.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/ISubSystem.java @@ -18,11 +18,13 @@ * David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect() * David Dykstal (IBM) - [217556] remove service subsystem types * Martin Oberhuber (Wind River) - [cleanup] Add API "since" Javadoc tags + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.rse.core.filters.ISystemFilter; import org.eclipse.rse.core.filters.ISystemFilterPoolReferenceManager; @@ -390,9 +392,10 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * * @param monitor the progress monitor. Must not be null. * @param forcePrompt forces the prompt dialog to be displayed - * even if the password is currently in memory. + * even if the password is currently in memory. * @throws Exception an exception if there is a failure to connect. - * Typically, this will be a {@link SystemMessageException}. + * Typically, this will be a {@link SystemMessageException}. + * An {@link OperationCanceledException} will be thrown if the user cancels the connect. */ public void connect(IProgressMonitor monitor, boolean forcePrompt) throws Exception; @@ -413,7 +416,8 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I * @param callback to call after connect is complete. * May be null. * @throws Exception an exception if there is a failure to connect. - * Typically, this will be a {@link SystemMessageException}. + * Typically, this will be a {@link SystemMessageException}. + * An {@link OperationCanceledException} will be thrown if the user cancels the connect. */ public void connect(boolean forcePrompt, IRSECallback callback) throws Exception; diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java index fd95414dd44..b521f8e3065 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/widgets/SystemQualifiedRemoteFolderCombo.java @@ -19,6 +19,7 @@ * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.files.ui.widgets; @@ -26,6 +27,7 @@ import java.util.Hashtable; import java.util.ResourceBundle; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; @@ -620,7 +622,7 @@ public class SystemQualifiedRemoteFolderCombo extends Composite } else { ss.connect(false, null); } - } catch (InterruptedException exc) + } catch (OperationCanceledException exc) { String msgTxt = NLS.bind(CommonMessages.MSG_CONNECT_CANCELED, conn.getHostName()); throw new Exception(msgTxt); diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java index 040274f65b1..5f95da7cf27 100644 --- a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/SubSystem.java @@ -34,6 +34,7 @@ * David Dykstal (IBM) - [217556] remove service subsystem types * David McKnight (IBM) - [220309] [nls] Some GenericMessages and SubSystemResources should move from UI to Core * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared + * David Dykstal (IBM) - [225089][ssh][shells][api] Canceling connection leads to exception ********************************************************************************/ package org.eclipse.rse.core.subsystems; @@ -51,6 +52,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; @@ -527,7 +529,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider throw (SystemMessageException) e; } else - if (e instanceof InterruptedException) + if (e instanceof OperationCanceledException) { String msgTxt = NLS.bind(CommonMessages.MSG_CONNECT_CANCELED, getHost().getAliasName()); SystemMessage msg = new SimpleSystemMessage(RSECorePlugin.PLUGIN_ID, @@ -1334,6 +1336,11 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider monitor.done(); return Status.OK_STATUS; } + catch(OperationCanceledException exc) + { + monitor.done(); + return Status.CANCEL_STATUS; + } catch(java.lang.InterruptedException exc) { monitor.done(); @@ -1711,7 +1718,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider } } - protected boolean implicitConnect(boolean isConnectOperation, IProgressMonitor mon, String msg, int totalWorkUnits) throws SystemMessageException, InvocationTargetException, InterruptedException + protected boolean implicitConnect(boolean isConnectOperation, IProgressMonitor mon, String msg, int totalWorkUnits) throws SystemMessageException, InvocationTargetException, OperationCanceledException { boolean didConnection = false; if ( doConnection && !isConnected())// caller wants to do connection first as part operation @@ -2311,17 +2318,20 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider } }); try { - if (exception[0]!=null) - throw exception[0]; - getConnectorService().connect(monitor); - if (isConnected()) { - final SubSystem ss = this; - //Notify connect status change - Display.getDefault().asyncExec(new Runnable() { - public void run() { - RSECorePlugin.getTheSystemRegistry().connectedStatusChange(ss, true, false); - } - }); + Exception e = exception[0]; + if (e == null) { + getConnectorService().connect(monitor); + if (isConnected()) { + final SubSystem ss = this; + //Notify connect status change + Display.getDefault().asyncExec(new Runnable() { + public void run() { + RSECorePlugin.getTheSystemRegistry().connectedStatusChange(ss, true, false); + } + }); + } + } else { + throw e; } } finally { monitor.done(); @@ -2414,7 +2424,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider doConnection = true; ok = true; } - catch (InterruptedException exc) // user cancelled + catch (OperationCanceledException exc) // user cancelled { throw exc; } @@ -2562,7 +2572,7 @@ implements IAdaptable, ISubSystem, ISystemFilterPoolReferenceManagerProvider *

* Your connect method in your IConnectorService class must follow these IRunnableWithProgress rules: *