diff options
| author | Markus Keller | 2012-07-03 13:24:38 +0000 |
|---|---|---|
| committer | Markus Keller | 2012-07-03 13:27:24 +0000 |
| commit | d92501b8f2c2708b5f0c5f2dbb8bb2bb9ede1b24 (patch) | |
| tree | bc3f82499724186dd1b5e8ae14ccaa1aae761c9e | |
| parent | 9ee666b9caaca7b99d55e3efc4d6154de7e98693 (diff) | |
| download | egit-d92501b8f2c2708b5f0c5f2dbb8bb2bb9ede1b24.tar.gz egit-d92501b8f2c2708b5f0c5f2dbb8bb2bb9ede1b24.tar.xz egit-d92501b8f2c2708b5f0c5f2dbb8bb2bb9ede1b24.zip | |
Open multiple detail dialogs from MultiPullResultDialog at once
This change enables multi-select in the MultiPullResultDialog and
changes the Details button to work with multi-selections. Together with
<https://git.eclipse.org/r/#/c/6291/>, this offers a better workflow for
users who want to review incoming changes from multiple repositories.
The change in PullResultDialog ensures that simple result dialogs
without updates also store their location (but not their size).
Change-Id: If69fc53801db0742bec4bd50302276567fd6b51a
Signed-off-by: Markus Keller <markus_keller@ch.ibm.com>
| -rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/MultiPullResultDialog.java | 75 | ||||
| -rw-r--r-- | org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullResultDialog.java | 7 |
2 files changed, 68 insertions, 14 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/MultiPullResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/MultiPullResultDialog.java index 1e40f3033a..37fc90f439 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/MultiPullResultDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/MultiPullResultDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 SAP AG and others. + * Copyright (c) 2011, 2012 SAP AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,10 +8,12 @@ * Contributors: * Mathias Kinzler (SAP AG) - initial implementation * Daniel Megert <daniel_megert@ch.ibm.com> - remove unnecessary @SuppressWarnings + * Markus Keller <markus_keller@ch.ibm.com> - Open multiple detail dialogs from MultiPullResultDialog at once *******************************************************************************/ package org.eclipse.egit.ui.internal.pull; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -38,6 +40,8 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; @@ -169,18 +173,17 @@ public class MultiPullResultDialog extends Dialog { Composite main = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().applyTo(main); GridDataFactory.fillDefaults().grab(true, true).applyTo(main); - tv = new TableViewer(main, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER); + tv = new TableViewer(main, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER); tv.setContentProvider(ArrayContentProvider.getInstance()); tv.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event .getSelection(); - boolean enabled = !sel.isEmpty(); - if (enabled) { - Entry<Repository, Object> entry = (Entry<Repository, Object>) sel - .getFirstElement(); - enabled = entry.getValue() instanceof PullResult; + boolean enabled = false; + for (Entry<Repository, Object> entry : (List<Entry<Repository, Object>>) sel + .toList()) { + enabled |= entry.getValue() instanceof PullResult; } getButton(DETAIL_BUTTON).setEnabled(enabled); } @@ -228,13 +231,59 @@ public class MultiPullResultDialog extends Dialog { @Override protected void buttonPressed(int buttonId) { if (buttonId == DETAIL_BUTTON) { + final Shell shell = getShell(); + Rectangle trim = shell.computeTrim(0, 0, 0, 0); + int xOffset = 0; + int xDelta = -trim.x + 3; + int yOffset = 0; + int yDelta = -trim.y - 3; + IStructuredSelection sel = (IStructuredSelection) tv.getSelection(); - Entry<Repository, Object> item = (Entry<Repository, Object>) sel - .getFirstElement(); - if (item.getValue() instanceof PullResult) { - PullResultDialog dialog = new PullResultDialog(getShell(), item - .getKey(), (PullResult) item.getValue()); - dialog.open(); + for (Entry<Repository, Object> item : (List<Entry<Repository, Object>>) sel + .toList()) { + + if (item.getValue() instanceof PullResult) { + final int x = xOffset; + final int y = yOffset; + xOffset += xDelta; + yOffset += yDelta; + + PullResultDialog dialog = new PullResultDialog(shell, + item.getKey(), (PullResult) item.getValue()) { + private Point initialLocation; + + @Override + protected Point getInitialLocation(Point initialSize) { + initialLocation = super + .getInitialLocation(initialSize); + initialLocation.x += x; + initialLocation.y += y; + return initialLocation; + } + + @Override + public boolean close() { + // restore shell location if we moved it: + Shell resultShell = getShell(); + if (resultShell != null + && !resultShell.isDisposed()) { + Point location = resultShell.getLocation(); + if (location.equals(initialLocation)) + 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(); + } + return result; + } + }; + dialog.open(); + } } } super.buttonPressed(buttonId); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullResultDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullResultDialog.java index 038e4ad7a0..ce42b7a780 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullResultDialog.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/pull/PullResultDialog.java @@ -182,6 +182,11 @@ public class PullResultDialog extends Dialog { @Override protected IDialogSettings getDialogBoundsSettings() { - return hasUpdates ? UIUtils.getDialogBoundSettings(getClass()) : null; + return UIUtils.getDialogBoundSettings(getClass()); + } + + @Override + protected int getDialogBoundsStrategy() { + return hasUpdates ? DIALOG_PERSISTLOCATION | DIALOG_PERSISTSIZE : DIALOG_PERSISTLOCATION; } } |
