From 8af84a782b640d49e96288b0aba6185e4bd35901 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Thu, 5 Apr 2007 14:56:22 +0000 Subject: [PATCH] [181069] can't do a query to get context for saving shell states. Need a new API for IRemoteCommandShell to getContextString() so that a query can be avoided at this point. --- .../shells/core/model/RemoteCommandShell.java | 5 +++++ .../core/subsystems/IRemoteCommandShell.java | 9 ++++++++- .../core/subsystems/RemoteCmdSubSystem.java | 8 +++----- .../shells/dstore/DStoreServiceCommandShell.java | 15 +++++++++++++-- .../local/model/LocalServiceCommandShell.java | 6 +++++- .../shells/ssh/SshServiceCommandShell.java | 5 +++++ 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandShell.java index 03f9190194a..d86ba6cef2f 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/model/RemoteCommandShell.java @@ -258,6 +258,11 @@ public abstract class RemoteCommandShell implements IAdaptable, IRemoteCommandSh return _cwd; } + public String getContextString() + { + return _cwd.getAbsolutePath(); + } + /** * Get the current working directory for this command * @return the current working directory diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCommandShell.java index 5aede73fe06..11d5a51a2aa 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/IRemoteCommandShell.java @@ -65,7 +65,14 @@ public interface IRemoteCommandShell */ public Object getContext(); - + /** + * Get the current context for this command shell as a string. Unlike getContext(), this method + * simply returns a string representation of the context (so that no query is required to get the + * working directory). + * @return the context as a string + */ + public String getContextString(); + /** * Return the number of output objects for this command. * @return the number of output objects diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java index 810a327c7d5..e179c0ce3d4 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java @@ -586,12 +586,10 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd IRemoteCommandShell cmd = (IRemoteCommandShell) cmdShells.get(i); if (cmd.isActive()) { - Object context = cmd.getContext(); - if (context instanceof IRemoteFile) + Object context = cmd.getContextString(); + if (context instanceof String) { - IRemoteFile pwdf = (IRemoteFile) context; - String pwd = pwdf.getAbsolutePath(); - shellBuffer.append(pwd); + shellBuffer.append(context); gotShell = true; } else diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java index ed50ff74fb5..de7a8fc2965 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.dstore/src/org/eclipse/rse/internal/subsystems/shells/dstore/DStoreServiceCommandShell.java @@ -24,6 +24,7 @@ import org.eclipse.rse.internal.subsystems.shells.servicesubsystem.OutputRefresh import org.eclipse.rse.services.shells.IHostOutput; import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.services.shells.IHostShellChangeEvent; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; import org.eclipse.rse.subsystems.shells.core.model.RemoteError; import org.eclipse.rse.subsystems.shells.core.model.RemoteOutput; import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; @@ -47,14 +48,24 @@ public class DStoreServiceCommandShell extends ServiceCommandShell { try { - return getFileSubSystem().getRemoteFileObject(workingDir); + IRemoteFileSubSystem ss = getFileSubSystem(); + if (ss.isConnected()) + { + return ss.getRemoteFileObject(workingDir); + } } catch (Exception e) { } } return null; - + } + + public String getContextString() + { + DStoreHostShell shell = (DStoreHostShell)getHostShell(); + DStoreShellOutputReader reader = (DStoreShellOutputReader)shell.getStandardOutputReader(); + return reader.getWorkingDirectory(); } public void shellOutputChanged(IHostShellChangeEvent event) diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/internal/subsystems/shells/local/model/LocalServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/internal/subsystems/shells/local/model/LocalServiceCommandShell.java index 11d8d1f3059..5163429f304 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/internal/subsystems/shells/local/model/LocalServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.local/src/org/eclipse/rse/internal/subsystems/shells/local/model/LocalServiceCommandShell.java @@ -69,7 +69,11 @@ public class LocalServiceCommandShell extends ServiceCommandShell } } return null; - + } + + public String getContextString() + { + return _workingDir; } diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/internal/subsystems/shells/ssh/SshServiceCommandShell.java b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/internal/subsystems/shells/ssh/SshServiceCommandShell.java index 06674c808ff..cc7e089b530 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/internal/subsystems/shells/ssh/SshServiceCommandShell.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.ssh/src/org/eclipse/rse/internal/subsystems/shells/ssh/SshServiceCommandShell.java @@ -77,6 +77,11 @@ public class SshServiceCommandShell extends ServiceCommandShell return null; } + + public String getContextString() + { + return _workingDir; + } public void shellOutputChanged(IHostShellChangeEvent event) {