Fix drag&drop in staging view
commit674e990b88c992d517f706314cdc5e780b4c767f
authorThomas Wolf <thomas.wolf@paranor.ch>
Mon, 17 Oct 2016 07:18:15 +0000 (17 09:18 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 18 Oct 2016 22:14:56 +0000 (19 00:14 +0200)
tree2891e87fd2fa266114cd4aac393cdd34048857ec
parentf9bf65864c70e585bf1bcfa0149195714e4441a4
Fix drag&drop in staging view

Drag&drop offers a FileTransfer, but considered only StagingEntries.
If only StagingFolderEntries were selected, the resulting FileTransfer
would be empty, which is not allowed and produces a SWTException,
making the drag&drop fail.

This is especially devastating on GTK, where the FileTransfer sometimes
gets created up front, and thus even drags between our own two viewers
failed frequently. On Mac, the FileTransfer is created lazily when
hovering over an item (such as a Finder window) that accepts such
transfers, and the problem thus went largely unnoticed there.

Fix this by also considering folders and including the staged or
unstaged files contained in those folders when creating a FileTransfer.
Transfer creation may still fail and log an exception if the selection
includes only deleted files. In my tests on GTK, drag&drop of deleted
files between the staged and unstaged viewer worked all the same.

Also reduce code duplication by factoring out the creation of the
staged and unstaged viewers into a common method.

Additionally, ensure that dropping onto the same staged or unstaged
viewer the drag&drop initially started from is a no-op; otherwise this
did inadvertently stage/unstage other files contained in selected
folders.

Bug: 453637
Bug: 505923
Change-Id: I3016da202f7d02365374fd9b90ca3537e277ece1
org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java