Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Stocker2014-09-01 14:00:01 +0000
committerMatthias Sohn2014-09-01 22:20:06 +0000
commit21e55832ce795ee2e019a9019edccb46a9281f0f (patch)
tree58c38f279db15edac85c299272bb5ed5c1ff1bb6
parent266edaa36d3406d992eb17db5f180e2a1b1a6e54 (diff)
downloadegit-21e55832ce795ee2e019a9019edccb46a9281f0f.tar.gz
egit-21e55832ce795ee2e019a9019edccb46a9281f0f.tar.xz
egit-21e55832ce795ee2e019a9019edccb46a9281f0f.zip
Provide more context in cherry-pick confirmation dialog
Show info about commits to be cherry-picked in tree. This way the user can more easily recognize if they selected the right commits. Bug: 442865 Change-Id: I01d86c8dcbba24389965d3c73b216685b1660ca3 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java67
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties4
2 files changed, 67 insertions, 4 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
index 917597390e..5366b55408 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/command/CherryPickHandler.java
@@ -15,6 +15,7 @@ package org.eclipse.egit.ui.internal.commit.command;
import java.io.IOException;
import java.text.MessageFormat;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -30,12 +31,24 @@ import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIRepositoryUtils;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.egit.ui.internal.handler.SelectionHandler;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.Window;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
/**
* Handler to cherry pick the commit onto the current branch
@@ -112,10 +125,60 @@ public class CherryPickHandler extends SelectionHandler {
shell.getDisplay().syncExec(new Runnable() {
public void run() {
- confirmed.set(MessageDialog.openConfirm(shell,
- UIText.CherryPickHandler_ConfirmTitle, message));
+ ConfirmCherryPickDialog dialog = new ConfirmCherryPickDialog(
+ shell, message, repository, commits);
+ int result = dialog.open();
+ confirmed.set(result == Window.OK);
}
});
return confirmed.get();
}
+
+ private static class ConfirmCherryPickDialog extends MessageDialog {
+
+ private RepositoryCommit[] commits;
+
+ public ConfirmCherryPickDialog(Shell parentShell,
+ String message, Repository repository, List<RevCommit> revCommits) {
+ super(parentShell, UIText.CherryPickHandler_ConfirmTitle, null,
+ message, MessageDialog.CONFIRM, new String[] {
+ IDialogConstants.OK_LABEL,
+ IDialogConstants.CANCEL_LABEL }, 0);
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+
+ List<RepositoryCommit> repoCommits = new ArrayList<RepositoryCommit>();
+ for (RevCommit commit : revCommits)
+ repoCommits.add(new RepositoryCommit(repository, commit));
+ this.commits = repoCommits.toArray(new RepositoryCommit[0]);
+ }
+
+ @Override
+ protected Control createCustomArea(Composite parent) {
+ Composite area = new Composite(parent, SWT.NONE);
+ area.setLayoutData(GridDataFactory.fillDefaults().grab(true, true)
+ .create());
+ area.setLayout(new FillLayout());
+
+ TreeViewer treeViewer = new TreeViewer(area);
+ treeViewer.setContentProvider(new ContentProvider());
+ treeViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(
+ new WorkbenchLabelProvider()));
+ treeViewer.setInput(commits);
+
+ return area;
+ }
+
+ private static class ContentProvider extends WorkbenchContentProvider {
+
+ public Object[] getElements(final Object element) {
+ return (Object[]) element;
+ }
+
+ public Object[] getChildren(Object element) {
+ if (element instanceof RepositoryCommit)
+ return ((RepositoryCommit) element).getDiffs();
+ return super.getChildren(element);
+ }
+ }
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 4b0157451d..c0993748f9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -171,7 +171,7 @@ GitHistoryPage_CompareWithWorkingTreeMenuMenuLabel=Compare with &Workspace
GitHistoryPage_CreateBranchMenuLabel=Create &Branch...
GitHistoryPage_CreatePatchMenuLabel=Create P&atch...
GitHistoryPage_CreateTagMenuLabel=Create &Tag...
-GitHistoryPage_cherryPickMenuItem=C&herry Pick
+GitHistoryPage_cherryPickMenuItem=C&herry Pick...
GitHistoryPage_compareMode=Compare Mode
GitHistoryPage_showAllBranches=Show All Branches and Tags
GitHistoryPage_squashMenuItem=Squash
@@ -270,7 +270,7 @@ CheckoutDialog_OkCheckoutWithQuestion=&Checkout...
CheckoutHandler_SelectBranchMessage=There is more than one branch for this commit. Please select the branch you want to check out.
CheckoutHandler_SelectBranchTitle=Select a Branch for Checkout
CherryPickHandler_JobName=Cherry Picking {0} Commits
-CherryPickHandler_ConfirmMessage=Are you sure you want to cherry pick {0} commits onto branch ''{1}''?
+CherryPickHandler_ConfirmMessage=Are you sure you want to cherry pick the following {0,choice,1#commit|1<{0} commits} onto branch ''{1}''?
CherryPickHandler_ConfirmTitle=Cherry Pick Commit
CherryPickOperation_InternalError=An internal error occurred
CompareTargetSelectionDialog_CompareButton=&Compare

Back to the top