1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-24 08:44:01 +02:00

[142065] fix drag and drop on Mac OS X

This commit is contained in:
David Dykstal 2007-06-01 20:52:22 +00:00
parent 5b5fe2b659
commit f5d49003ce

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [142065] fix drag and drop on Mac OS X
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.ui.view; package org.eclipse.rse.internal.ui.view;
@ -61,6 +62,7 @@ public class SystemViewDataDragAdapter extends DragSourceAdapter
ISelectionProvider _selectionProvider; ISelectionProvider _selectionProvider;
private ISelection _selection = null; // set this on dragStart, set to null on dragFinished
public static final char CONNECTION_DELIMITER = ':'; public static final char CONNECTION_DELIMITER = ':';
public static final char RESOURCE_SEPARATOR = '|'; public static final char RESOURCE_SEPARATOR = '|';
@ -75,6 +77,7 @@ public class SystemViewDataDragAdapter extends DragSourceAdapter
public void dragFinished(DragSourceEvent event) public void dragFinished(DragSourceEvent event)
{ {
_selection = null; // drag has finished, forget the selection
if (event.doit == false) if (event.doit == false)
{ {
return; return;
@ -117,10 +120,14 @@ public class SystemViewDataDragAdapter extends DragSourceAdapter
public void dragStart(DragSourceEvent event) public void dragStart(DragSourceEvent event)
{ {
ISelection selection = _selectionProvider.getSelection(); /*
if (selection instanceof IStructuredSelection) * Remember the selection at drag start. This is the only point at which the selection is valid
* during the drag operations on all platforms.
*/
_selection = _selectionProvider.getSelection();
if (_selection instanceof IStructuredSelection)
{ {
IStructuredSelection ss = (IStructuredSelection) selection; IStructuredSelection ss = (IStructuredSelection) _selection;
Iterator iterator = ss.iterator(); Iterator iterator = ss.iterator();
while (iterator.hasNext()) while (iterator.hasNext())
{ {
@ -182,10 +189,17 @@ public class SystemViewDataDragAdapter extends DragSourceAdapter
*/ */
public void dragSetData(DragSourceEvent event) public void dragSetData(DragSourceEvent event)
{ {
ISelection selection = _selectionProvider.getSelection();
if (selection instanceof IStructuredSelection) /*
* We cannot request the selection from the selection provider at this point since
* on some platforms (particularly Mac OS X) the selection is forgotten by the underlying
* OS control immediately after the drag is started. This call is invoked at the end
* of the drag operation but just before the corresponding drop call in the drop adapter.
* Thus, we must remember the selection at drag start.
*/
if (_selection instanceof IStructuredSelection)
{ {
IStructuredSelection ss = (IStructuredSelection) selection; IStructuredSelection ss = (IStructuredSelection) _selection;
if (PluginTransfer.getInstance().isSupportedType(event.dataType)) if (PluginTransfer.getInstance().isSupportedType(event.dataType))
{ {
@ -309,7 +323,7 @@ public class SystemViewDataDragAdapter extends DragSourceAdapter
editable.addAsListener(); editable.addAsListener();
editable.setLocalResourceProperties(); editable.setLocalResourceProperties();
IFile theFile = (IFile)editable.getLocalResource(); IFile theFile = editable.getLocalResource();
IEditorDescriptor preferredEditor = editRegistry.getDefaultEditor(theFile.getName()); // may be null IEditorDescriptor preferredEditor = editRegistry.getDefaultEditor(theFile.getName()); // may be null
if (preferredEditor == null) if (preferredEditor == null)