aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2012-03-07 11:45:55 (EST)
committerRobin Stocker2012-03-07 11:45:55 (EST)
commit664c43eeb32d5e29e1d848eb6f7a260c4005edfa (patch)
treef80e3ce2a0da90cdae8a3444f2cc310ffa00f4db
parenta2dd680c29fecbbd7697d10119a7b6b19e92273d (diff)
downloadegit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.zip
egit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.tar.gz
egit-664c43eeb32d5e29e1d848eb6f7a260c4005edfa.tar.bz2
[stagingView] Don't accept arbitrary dropsrefs/changes/89/5289/1
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.java16
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 0055b27..6f00daf 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) {