diff options
| author | Robin Stocker | 2012-03-07 16:45:55 +0000 |
|---|---|---|
| committer | Robin Stocker | 2012-03-07 16:45:55 +0000 |
| commit | 664c43eeb32d5e29e1d848eb6f7a260c4005edfa (patch) | |
| tree | f80e3ce2a0da90cdae8a3444f2cc310ffa00f4db | |
| parent | a2dd680c29fecbbd7697d10119a7b6b19e92273d (diff) | |
| download | egit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.tar.gz egit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.tar.xz egit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.zip | |
[stagingView] Don't accept arbitrary drops
Previously, the staging view would stage the selected files, even when
an unrelated drop happened (by mistake), e.g. from a file from the
Package Explorer. The same with unstaging.
By checking that the event data is actually a StagingEntry (i.e. the
drag was started from the staging view), we ensure that no accidental
drops can cause staging.
Change-Id: Ida2f9fdb9653b015a0ce3d410b789cf65915de38
Signed-off-by: Robin Stocker <robin@nibor.org>
| -rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java index 0055b27808..6f00daf02e 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java @@ -376,9 +376,11 @@ public class StagingView extends ViewPart { new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DropTargetAdapter() { public void drop(DropTargetEvent event) { - final IStructuredSelection selection = (IStructuredSelection) stagedTableViewer - .getSelection(); - unstage(selection); + if (event.data instanceof IStructuredSelection) { + final IStructuredSelection selection = (IStructuredSelection) event.data; + if (selection.getFirstElement() instanceof StagingEntry) + unstage(selection); + } } public void dragOver(DropTargetEvent event) { @@ -459,9 +461,11 @@ public class StagingView extends ViewPart { new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DropTargetAdapter() { public void drop(DropTargetEvent event) { - final IStructuredSelection selection = (IStructuredSelection) unstagedTableViewer - .getSelection(); - stage(selection); + if (event.data instanceof IStructuredSelection) { + final IStructuredSelection selection = (IStructuredSelection) event.data; + if (selection.getFirstElement() instanceof StagingEntry) + stage(selection); + } } public void dragOver(DropTargetEvent event) { |
