1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 06:55:23 +02:00

[196166] [usability][dnd] Changing the sort order of hosts in the SystemView should work by drag & drop

This commit is contained in:
David McKnight 2008-10-06 20:13:53 +00:00
parent 0454c84448
commit e5fd2c3fdb
2 changed files with 53 additions and 2 deletions

View file

@ -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)
{

View file

@ -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...