Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2017-01-11 11:54:12 +0000
committerThomas Wolf2017-01-11 13:04:23 +0000
commitfff3ed5f6dcb7aa62f22e98bcd509840ced523a2 (patch)
treef4cee25ec256a2edb7072b6b9f8dcb8036940990
parent83c4fcf3650985c1c596c206cf4a513b90e4af08 (diff)
downloadegit-fff3ed5f6dcb7aa62f22e98bcd509840ced523a2.tar.gz
egit-fff3ed5f6dcb7aa62f22e98bcd509840ced523a2.tar.xz
egit-fff3ed5f6dcb7aa62f22e98bcd509840ced523a2.zip
Fix remembering the last selection in StagingView
The staging view would not properly react to selection changes while it was inactive. The problem was that the PartListener actually did not track the selection; it only remembered the current selection of the new active part, but would miss subsequent selection changes. Bug: 349763 Change-Id: I13d6219677aaf167fd4e2a9c4b94aaf59a92a022 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java37
1 files changed, 14 insertions, 23 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 ad4fdd03bf..8ca1b1f144 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
@@ -283,6 +283,9 @@ public class StagingView extends ViewPart
private boolean isViewHidden;
+ /** Tracks the last selection while the view is not active. */
+ private StructuredSelection lastSelection;
+
private ISelectionListener selectionChangedListener;
private IPartListener2 partListener;
@@ -475,7 +478,6 @@ public class StagingView extends ViewPart
}
private final class PartListener implements IPartListener2 {
- StructuredSelection lastSelection;
@Override
public void partVisible(IWorkbenchPartReference partRef) {
@@ -499,28 +501,10 @@ public class StagingView extends ViewPart
@Override
public void partActivated(IWorkbenchPartReference partRef) {
- if (isMe(partRef)) {
- if (lastSelection != null) {
- // view activated: synchronize with last active part
- // selection
- reactOnSelection(lastSelection);
- lastSelection = null;
- }
- return;
- }
- IWorkbenchPart part = partRef.getPart(false);
- StructuredSelection sel = getSelectionOfPart(part);
- if (isViewHidden) {
- // remember last selection in the part so that we can
- // synchronize on it as soon as we will be visible
- lastSelection = sel;
- } else {
+ if (lastSelection != null && isMe(partRef)) {
+ reactOnSelection(lastSelection);
lastSelection = null;
- if (sel != null) {
- reactOnSelection(sel);
- }
}
-
}
private void updateHiddenState(IWorkbenchPartReference partRef,
@@ -2999,9 +2983,16 @@ public class StagingView extends ViewPart
}
private void reactOnSelection(StructuredSelection selection) {
- if (selection.size() != 1 || !shouldUpdateSelection()) {
+ if (selection.size() != 1 || isDisposed()) {
return;
}
+ if (!shouldUpdateSelection()) {
+ // Remember it all the same to be able to update the view when it
+ // becomes active again
+ lastSelection = reactOnSelection ? selection : null;
+ return;
+ }
+ lastSelection = null;
Object firstElement = selection.getFirstElement();
if (firstElement instanceof RepositoryTreeNode) {
RepositoryTreeNode repoNode = (RepositoryTreeNode) firstElement;
@@ -3954,7 +3945,7 @@ public class StagingView extends ViewPart
getDialogSettings().put(STORE_SORT_STATE, sortAction.isChecked());
currentRepository = null;
-
+ lastSelection = null;
disposed = true;
}

Back to the top