From e5fd2c3fdb83fdcd524b2054e743c14a26a6a045 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 6 Oct 2008 20:13:53 +0000 Subject: [PATCH] [196166] [usability][dnd] Changing the sort order of hosts in the SystemView should work by drag & drop --- .../ui/view/SystemDNDTransferRunnable.java | 6 ++- .../ui/view/SystemViewConnectionAdapter.java | 49 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java index b2e0784f19f..6a2dc94fd28 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemDNDTransferRunnable.java @@ -23,6 +23,7 @@ * David McKnight (IBM) - [232889] Dragging and dropping files from a remote unix system to a local project does not work * David McKnight (IBM) - [234721] [dnd] When dragging a file from windows file explorer into RSE, a refresh error is given. * David McKnight (IBM) - [248922] [dnd] Remote to local overwrite copy does not work + * David McKnight (IBM) - [196166] [usability][dnd] Changing the sort order of hosts in the SystemView should work by drag & drop *******************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -797,7 +798,10 @@ public class SystemDNDTransferRunnable extends WorkspaceJob try { TreeViewer viewer = (TreeViewer) _originatingViewer; - viewer.setExpandedState(_target, true); + + if (!(_target instanceof IHost)){ // not sure when we'd want to expand a host + viewer.setExpandedState(_target, true); + } } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java index 9306395e424..d1e6fb98cd6 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java @@ -34,6 +34,7 @@ * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core * David Dykstal (IBM) - [216858] Need the ability to Import/Export RSE connections for sharing * David McKnight (IBM) - [226324] Default user ID from preferences not inherited + * David McKnight (IBM) - [196166] [usability][dnd] Changing the sort order of hosts in the SystemView should work by drag & drop ********************************************************************************/ package org.eclipse.rse.internal.ui.view; @@ -50,6 +51,8 @@ import org.eclipse.rse.core.IRSEUserIdConstants; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemHostPool; +import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.model.ISystemViewInputProvider; import org.eclipse.rse.core.subsystems.IConnectorService; @@ -689,6 +692,36 @@ public class SystemViewConnectionAdapter return true; } + public boolean canDrop(Object element) { + if (element instanceof IHost){ + return true; + } + return false; + } + + public Object doDrop(Object from, Object to, boolean sameSystemType, + boolean sameSystem, int srcType, IProgressMonitor monitor) { + IHost srcHost = (IHost)from; + IHost tgtHost = (IHost)to; + if (srcHost != null && tgtHost != null && srcHost != tgtHost){ + ISystemProfile profile = tgtHost.getSystemProfile(); + ISystemHostPool pool = tgtHost.getHostPool(); + ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry(); + + + int tgtPosition = pool.getHostPosition(tgtHost); + int srcPosition = pool.getHostPosition(srcHost); + + int delta = tgtPosition - srcPosition; + + IHost[] conns = new IHost[1]; + conns[0] = srcHost; + + sr.moveHosts(profile.getName(),conns,delta); + } + return srcHost; + } + /** * Returns the connection (no phyiscal operation required to drag and subsystem (because it's local) */ @@ -697,7 +730,21 @@ public class SystemViewConnectionAdapter return element; } - + + /** + * Make sure that the drop of the specified src object is appropriate on target object + */ + public boolean validateDrop(Object src, Object target, boolean sameSystem) + { + if (src instanceof IHost && target instanceof IHost && src != target){ + // make sure they use the same profile + ISystemProfile p1 = ((IHost)src).getSystemProfile(); + ISystemProfile p2 = ((IHost)target).getSystemProfile(); + return p1 == p2; + } + return false; + } + // ------------------------------------------------------------ // METHODS FOR SAVING AND RESTORING EXPANSION STATE OF VIEWER...