Permalink
Browse files

Fix dialog activation order with multiple detail dialogs

Multiple detail dialogs are stacked, and the user expects that when he
closes the topmost dialog, then the next in the stack comes to front.

The old implementation didn't work reliably due to bug 388667.

Bug: 389914
Change-Id: I92b02705e00c2f8890dcf788977c6e94b6ebaee3
Signed-off-by: Markus Keller <markus_keller@ch.ibm.com>
  • Loading branch information...
1 parent 94e5f7d commit 334390383c858261dc51d9501c21aa01d2756795 @mkeller mkeller committed Sep 20, 2012
@@ -14,6 +14,7 @@
package org.eclipse.egit.ui.internal.pull;
import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -40,6 +41,7 @@
import org.eclipse.jgit.lib.Repository;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -185,9 +187,8 @@ public void selectionChanged(SelectionChangedEvent event) {
.getSelection();
boolean enabled = false;
for (Entry<Repository, Object> entry : (List<Entry<Repository, Object>>) sel
- .toList()) {
+ .toList())
enabled |= entry.getValue() instanceof PullResult;
- }
getButton(DETAIL_BUTTON).setEnabled(enabled);
}
});
@@ -241,6 +242,7 @@ protected void buttonPressed(int buttonId) {
int yOffset = 0;
int yDelta = -trim.y - 3;
+ final LinkedList<PullResultDialog> dialogs= new LinkedList<PullResultDialog>();
IStructuredSelection sel = (IStructuredSelection) tv.getSelection();
for (Entry<Repository, Object> item : (List<Entry<Repository, Object>>) sel
.toList()) {
@@ -251,7 +253,7 @@ protected void buttonPressed(int buttonId) {
xOffset += xDelta;
yOffset += yDelta;
- PullResultDialog dialog = new PullResultDialog(shell,
+ final PullResultDialog dialog = new PullResultDialog(shell,
item.getKey(), (PullResult) item.getValue()) {
private Point initialLocation;
@@ -271,20 +273,36 @@ public boolean close() {
if (resultShell != null
&& !resultShell.isDisposed()) {
Point location = resultShell.getLocation();
- if (location.equals(initialLocation))
+ if (location.equals(initialLocation)) {
+ resultShell.setVisible(false);
resultShell.setLocation(location.x - x,
location.y - y);
+ }
}
boolean result = super.close();
// activate next result dialog (not the multi-result dialog):
- Shell[] subShells = shell.getShells();
- if (subShells.length > 0) {
- subShells[subShells.length - 1].setActive();
- }
+
+ // TODO: This doesn't work due to https://bugs.eclipse.org/388667 :
+// Shell[] subShells = shell.getShells();
+// if (subShells.length > 0) {
+// subShells[subShells.length - 1].setActive();
+// }
+
+ dialogs.remove(this);
+ if (dialogs.size() > 0)
+ dialogs.getLast().getShell().setActive();
+
return result;
}
};
+ dialog.create();
+ dialog.getShell().addShellListener(new ShellAdapter() {
+ public void shellActivated(org.eclipse.swt.events.ShellEvent e) {
+ dialogs.remove(dialog);
+ dialogs.add(dialog);
+ }
+ });
dialog.open();
}
}

0 comments on commit 3343903

Please sign in to comment.