From 8ccaf101ec6587530f53771921f22dd25da526b2 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 22 May 2007 20:46:24 +0000 Subject: [PATCH] [187737] need to account for hosts in copy and paste actions --- .../actions/SystemCopyToClipboardAction.java | 76 ++++++++++++------- .../rse/ui/internal/model/SystemRegistry.java | 12 +++ 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemCopyToClipboardAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemCopyToClipboardAction.java index f2dc1381c24..1b0c29b240e 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemCopyToClipboardAction.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/actions/SystemCopyToClipboardAction.java @@ -174,33 +174,48 @@ public class SystemCopyToClipboardAction extends SystemBaseAction implements IV if (adapter.canDrag(dragObject)) { - // get the subsystem id - ISubSystem subSystem = adapter.getSubSystem(dragObject); - String subSystemId = registry.getAbsoluteNameForSubSystem(subSystem); - - dataStream.append(subSystemId); - dataStream.append(":"); //$NON-NLS-1$ - - String objectId = adapter.getAbsoluteName(dragObject); - dataStream.append(objectId); - - if (iterator.hasNext()) - { - dataStream.append(SystemViewDataDropAdapter.RESOURCE_SEPARATOR); - } - - if (_doResourceTransfer) - { - IResource resource = getResource((IAdaptable)dragObject); - if (resource != null) + ISubSystem subSystem = null; + if (dragObject instanceof ISubSystem) + { + subSystem = (ISubSystem)dragObject; + String subSystemId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForSubSystem(subSystem); + dataStream.append(subSystemId); + } + else if (dragObject instanceof IHost) + { + IHost connection = (IHost)dragObject; + String connectionId = RSECorePlugin.getTheSystemRegistry().getAbsoluteNameForConnection(connection); + dataStream.append(connectionId); + } + else + { + // get the subsystem id + subSystem = adapter.getSubSystem(dragObject); + String subSystemId = registry.getAbsoluteNameForSubSystem(subSystem); + + dataStream.append(subSystemId); + dataStream.append(":"); //$NON-NLS-1$ + + String objectId = adapter.getAbsoluteName(dragObject); + dataStream.append(objectId); + + if (iterator.hasNext()) { - resources.add(resource); - - String fileName = resource.getLocation().toOSString(); - fileNames.add(fileName); - } - } - + dataStream.append(SystemViewDataDropAdapter.RESOURCE_SEPARATOR); + } + + if (_doResourceTransfer) + { + IResource resource = getResource((IAdaptable)dragObject); + if (resource != null) + { + resources.add(resource); + + String fileName = resource.getLocation().toOSString(); + fileNames.add(fileName); + } + } + } } } } @@ -234,7 +249,14 @@ public class SystemCopyToClipboardAction extends SystemBaseAction implements IV ft[i] = (String) fileNames.get(i); } - _clipboard.setContents(new Object[] { data, ft, textStream.toString() }, new Transfer[] { PluginTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance()}); + if (ft.length > 0) + { + _clipboard.setContents(new Object[] { data, ft, textStream.toString() }, new Transfer[] { PluginTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance()}); + } + else + { + _clipboard.setContents(new Object[] { data, textStream.toString() }, new Transfer[] { PluginTransfer.getInstance(), TextTransfer.getInstance()}); + } } } diff --git a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/internal/model/SystemRegistry.java b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/internal/model/SystemRegistry.java index b100b5210de..42bd38c4d41 100644 --- a/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/internal/model/SystemRegistry.java +++ b/rse/plugins/org.eclipse.rse.ui/model/org/eclipse/rse/ui/internal/model/SystemRegistry.java @@ -1985,6 +1985,18 @@ public class SystemRegistry implements ISystemRegistry, ISystemRegistryUI, ISyst { // first extract subsystem id int connectionDelim = str.indexOf(":"); //$NON-NLS-1$ + if (connectionDelim == -1) // not subsystem, therefore likely to be a connection + { + int profileDelim = str.indexOf("."); //$NON-NLS-1$ + if (profileDelim != -1) + { + String profileId = str.substring(0, profileDelim); + String connectionId = str.substring(profileDelim + 1, str.length()); + ISystemProfile profile = registry.getSystemProfile(profileId); + return registry.getHost(profile, connectionId); + } + } + int subsystemDelim = str.indexOf(":", connectionDelim + 1); //$NON-NLS-1$ String subSystemId = str.substring(0, subsystemDelim);