Add the option to locally autorebase without the remote call first

Change-Id: I9d214f1bbd74d6a3b2d25f9d24ae5fcbcd41b27e
Signed-off-by: Patrick-Jeffrey Pollo Guilbert <patrick.pollo.guilbert@ericsson.com>
diff --git a/org.eclipse.egerrit.dashboard.ui/OSGI-INF/l10n/bundle.properties b/org.eclipse.egerrit.dashboard.ui/OSGI-INF/l10n/bundle.properties
index c2d502d..8a0d9f2 100644
--- a/org.eclipse.egerrit.dashboard.ui/OSGI-INF/l10n/bundle.properties
+++ b/org.eclipse.egerrit.dashboard.ui/OSGI-INF/l10n/bundle.properties
@@ -83,7 +83,7 @@
 command.tooltipCheckout = Checkout the branch associated with the latest patch-set of this review
 command.name.cherryPick = Cherry Pick...
 command.tooltipCherryPick = Cherry Pick the selected commit onto the current local branch
-command.name.rebase = Rebase...
+command.name.rebase = Rebase
 command.tooltipRebase = Rebase the selected commit
 command.name.reply = Reply...
 command.name.reply.toplevel = Reply
diff --git a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/commands/table/RebaseHandler.java b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/commands/table/RebaseHandler.java
index 381d1ac..7ecc4c3 100644
--- a/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/commands/table/RebaseHandler.java
+++ b/org.eclipse.egerrit.dashboard.ui/src/org/eclipse/egerrit/internal/dashboard/ui/commands/table/RebaseHandler.java
@@ -11,12 +11,10 @@
 

 package org.eclipse.egerrit.internal.dashboard.ui.commands.table;

 

-import java.lang.reflect.InvocationTargetException;

 import java.util.Map;

 

 import org.eclipse.core.commands.ExecutionEvent;

 import org.eclipse.core.commands.ExecutionException;

-import org.eclipse.egerrit.internal.core.EGerritCorePlugin;

 import org.eclipse.egerrit.internal.process.RebaseProcess;

 import org.eclipse.egerrit.internal.ui.utils.Messages;

 import org.eclipse.osgi.util.NLS;

@@ -32,13 +30,9 @@
 	public Object execute(ExecutionEvent event) throws ExecutionException {

 		// Execute the rebase if we have the information

 		if (getChangeInfo() != null && getGerritClient() != null) {

-			RebaseProcess rebaseProcess = new RebaseProcess();

-			try {

-				rebaseProcess.handleRebase(HandlerUtil.getActiveShell(event), getChangeInfo(), getLatestRevision(),

-						getGerritClient());

-			} catch (InvocationTargetException e) {

-				EGerritCorePlugin.logError(e.getMessage());

-			}

+			RebaseProcess rebaseProcess = new RebaseProcess(false, HandlerUtil.getActiveShell(event), getChangeInfo(),

+					getLatestRevision(), getGerritClient());

+			rebaseProcess.run();

 		}

 		return null;

 	}

diff --git a/org.eclipse.egerrit.ui.rcptt.tests/HelperScripts.ctx b/org.eclipse.egerrit.ui.rcptt.tests/HelperScripts.ctx
index 61121e4..3802838 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/HelperScripts.ctx
+++ b/org.eclipse.egerrit.ui.rcptt.tests/HelperScripts.ctx
@@ -5,8 +5,8 @@
 Element-Type: context
 Element-Version: 2.0
 Id: _jPStUFRJEeaXLqlXvYQIgg
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 3/27/17 9:32 PM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/24/17 4:06 PM
 
 ------=_.ecl.context-718f04b4-ed39-33e3-af62-0995e4561998
 Content-Type: text/ecl
@@ -46,14 +46,17 @@
 			}
 		}
 	} -catch {
-		//Nothing to do
+		// Nothing to do
 	}
 }
 
-//Initialte a local rebase by clicking rebase in the review editor and answer to prompts
+// Initialte a local rebase by clicking rebase in the review editor and answer to prompts
 proc "initiate-local-rebase" [val editor -input] {
 	with [$editor] {
-		get-button Rebase | click
+		with [get-button "Rebase..."] {
+			click
+			get-menu "Rebase (remotely)" | click
+		}
 	}
 	with [get-window "Code Review - Rebase Change"] {
 		get-button OK | click
diff --git a/org.eclipse.egerrit.ui.rcptt.tests/dashboard/ContextMenu.test b/org.eclipse.egerrit.ui.rcptt.tests/dashboard/ContextMenu.test
index 6c40017..4de79a3 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/dashboard/ContextMenu.test
+++ b/org.eclipse.egerrit.ui.rcptt.tests/dashboard/ContextMenu.test
@@ -5,8 +5,8 @@
 Element-Version: 3.0
 External-Reference: 
 Id: _MvE9AHkaEea0t7_C5oFwIQ
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 3/17/17 1:02 PM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/31/17 3:05 PM
 Testcase-Type: ecl
 
 ------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
@@ -32,7 +32,7 @@
 	}
 }
 
-assert-context-menu -contains "Rebase..."
+assert-context-menu -contains "Rebase"
 assert-context-menu -contains "Download"
 assert-context-menu -contains "Download/Checkout..."
 assert-context-menu -contains "Download/Cherry Pick..."
diff --git a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/AutoRebaseFailureNoRepo.test b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/AutoRebaseFailureNoRepo.test
index 45241df..050a2b2 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/AutoRebaseFailureNoRepo.test
+++ b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/AutoRebaseFailureNoRepo.test
@@ -5,8 +5,8 @@
 Element-Version: 3.0
 External-Reference: 
 Id: _VmzIsA_VEeeBuMHyGXWtrw
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 3/23/17 3:18 PM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/24/17 4:03 PM
 Testcase-Type: ecl
 
 ------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
@@ -20,7 +20,6 @@
 	/* Create a first review with a unique content (timestamp) */
 	let [val review1 [create-review -server $serverURL -filename "Project/src/file.txt" -fileContent [get-time
 		| format-time -format "hh:mm:ss:SS"]]] {
-
 		/* Create a conflicting review by creating a new review, and then submitting the first review */
 		let [val review2 [create-review -server $serverURL -filename "Project/src/file.txt" -fileContent [get-time
 			| format-time -format "hh:mm:ss:SS"]]] {
@@ -42,10 +41,13 @@
 
 			with [get-editor] {
 				/* If the repository isn't imported, the automatic rebase dialog should not be displayed */
-				assert-that-button -button Rebase -is enabled
+				assert-that-button -button "Rebase..." -is enabled
 
 				/* Verify that the automatic rebase doesn't start if a non-empty string is entered */
-				get-button Rebase | click
+				with [get-button "Rebase..."] {
+					click
+					get-menu "Rebase (remotely)" | click
+				}
 				with [get-window "Code Review - Rebase Change"] {
 					get-editbox | set-text 1111111111111111
 					get-button OK | click
@@ -58,7 +60,10 @@
 				}
 
 				/* Verify that the automatic rebase can't start if no local repo is found on the workspace */
-				get-button Rebase | click
+				with [get-button "Rebase..."] {
+					click
+					get-menu "Rebase (remotely)" | click
+				}
 				with [get-window "Code Review - Rebase Change"] {
 					get-button OK | click
 					wait -ms $defaultWaitTime
diff --git a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/CheckButtons.test b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/CheckButtons.test
index e589a80..431c4e5 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/CheckButtons.test
+++ b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/CheckButtons.test
@@ -6,8 +6,8 @@
 Element-Version: 3.0
 External-Reference: 
 Id: _rBTYcFRGEeaXLqlXvYQIgg
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 12/9/16 8:51 AM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/24/17 4:04 PM
 Testcase-Type: ecl
 
 ------=_.description-216f885c-d591-38ce-8ea2-e4f8cb4d6ffa
@@ -26,7 +26,7 @@
 with [get-editor] {
 	assert-that-button Refresh -is enabled
 	assert-that-button Submit -is disabled
-	assert-that-button Rebase -is enabled
+	assert-that-button "Rebase..." -is enabled
 	assert-that-button "Cherry-Pick" -is enabled
 	assert-that-button "Reply..." -is enabled
 }
diff --git a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RebaseButton.test b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RebaseButton.test
index 0c5bf6f..52575ef 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RebaseButton.test
+++ b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RebaseButton.test
@@ -6,8 +6,8 @@
 Element-Version: 3.0
 External-Reference: 
 Id: _05iHkLi8Eea2OeMIfPIKmw
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 12/8/16 10:16 AM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/24/17 4:04 PM
 Testcase-Type: ecl
 
 ------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
@@ -22,7 +22,7 @@
 /* Select the editor */
 with [get-editor] {
 	/* Check that the latest patch set can be rebased */
-	assert-that-button -button Rebase -is enabled
+	assert-that-button -button "Rebase..." -is enabled
 	
 	/* Select the first patch set and check that this one is not rebaseable */
 	with [get-button -after [get-label "Patch Sets.*"]] {
@@ -30,7 +30,7 @@
 		get-menu "1.*" | click
 		wait -ms $defaultWaitTime
 	}
-	assert-that-button -button Rebase -is disabled
+	assert-that-button -button "Rebase..." -is disabled
 
 	/* Go back to latest patch set and check that it can be rebased */
 	with [get-button -after [get-label "Patch Sets.*"]] {
@@ -38,6 +38,6 @@
 		get-menu "2.*" | click
 		wait -ms $defaultWaitTime
 	}
-	assert-that-button -button Rebase -is enabled
+	assert-that-button -button "Rebase..." -is enabled
 }
 ------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac--
diff --git a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RefreshRelatedEditors.test b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RefreshRelatedEditors.test
index 21776e2..9ff2e44 100644
--- a/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RefreshRelatedEditors.test
+++ b/org.eclipse.egerrit.ui.rcptt.tests/reviewEditor/RefreshRelatedEditors.test
@@ -5,8 +5,8 @@
 Element-Version: 3.0
 External-Reference: 
 Id: _647qsLvcEeawKoti9_0qpQ
-Runtime-Version: 2.1.0.201605312320
-Save-Time: 3/23/17 2:02 PM
+Runtime-Version: 2.1.0.201606221726
+Save-Time: 3/24/17 4:42 PM
 Testcase-Type: ecl
 
 ------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
@@ -21,7 +21,10 @@
 		let [val secondReview [create-review -server $serverURL -filename "src/RCPTTRebase.java"]] {
 			runQueryAndOpenEditor $secondReview
 
-			get-button Rebase | click
+			with [get-button "Rebase..."] {
+				click
+				get-menu "Rebase (remotely)" | click
+			}
 			/* Rebase on top of the first change */
 			with [get-window "Code Review - Rebase Change"] {
 				get-editbox -after [get-label "Change parent revision (leave empty to rebase on targeted branch)"]
diff --git a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/process/RebaseProcess.java b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/process/RebaseProcess.java
index d153f39..33d51f3 100644
--- a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/process/RebaseProcess.java
+++ b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/process/RebaseProcess.java
@@ -11,7 +11,6 @@
 
 package org.eclipse.egerrit.internal.process;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.concurrent.CompletableFuture;
 
 import org.eclipse.egerrit.internal.core.EGerritCorePlugin;
@@ -29,6 +28,7 @@
 import org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry;
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.ecore.util.EContentAdapter;
+import org.eclipse.jface.action.Action;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -44,96 +44,144 @@
 /**
  * This class handle all aspect of the Rebase operation
  */
-public class RebaseProcess {
+public class RebaseProcess extends Action {
+
+	private Boolean rebaseLocally = false;;
+
+	private Shell shell;
+
+	private ChangeInfo changeInfo;
+
+	private RevisionInfo toRebase;
+
+	private GerritClient gerritClient;
 
 	/**
 	 * The constructor.
 	 */
-	public RebaseProcess() {
+	public RebaseProcess(Boolean rebaseLocally, Shell shell, ChangeInfo changeInfo, RevisionInfo toRebase,
+			GerritClient gerritClient) {
+		this.rebaseLocally = rebaseLocally;
+		this.shell = shell;
+		this.changeInfo = changeInfo;
+		this.toRebase = toRebase;
+		this.gerritClient = gerritClient;
+
+		if (rebaseLocally) {
+			this.setText(Messages.RebaseProcess_RebaseLocally);
+		} else {
+			this.setText(Messages.RebaseProcess_RebaseRemotely);
+		}
 	}
 
-	public void handleRebase(Shell shell, ChangeInfo changeInfo, RevisionInfo toRebase, GerritClient gerritClient)
-			throws InvocationTargetException {
-		InputDialog inputDialog = new InputDialog(shell, Messages.RebaseProcess_title,
-				Messages.RebaseProcess_changeParent, "", null) { //$NON-NLS-1$
+	@Override
+	public void run() {
+		if (rebaseLocally) {
+			Repository repo;
+			repo = new FindLocalRepository(gerritClient, toRebase.getChangeInfo().getProject()).getRepository();
+			if (repo != null) {
+				AutoRebaseProcess process = new AutoRebaseProcess(gerritClient, repo, toRebase);
+				process.schedule();
+			} else {
+				showNoRepoDialog(true);
+			}
+		} else {
+			InputDialog inputDialog = new InputDialog(shell, Messages.RebaseProcess_title,
+					Messages.RebaseProcess_changeParent, "", null) { //$NON-NLS-1$
 
-			@Override
-			protected void createButtonsForButtonBar(Composite parent) {
-				super.createButtonsForButtonBar(parent);
-				getText().addModifyListener(new ModifyListener() {
-					@Override
-					public void modifyText(ModifyEvent e) {
-						if (!toRebase.isRebaseable()) {
-							if (!getText().getText().isEmpty()) {
-								getOkButton().setEnabled(true);
-							} else {
-								getOkButton().setEnabled(false);
-								getOkButton().getParent().setToolTipText(
-										toRebase.isRebaseable() ? "" : Messages.RebaseProcess_changeIsAlreadyUpToDate); //$NON-NLS-1$
+				@Override
+				protected void createButtonsForButtonBar(Composite parent) {
+					super.createButtonsForButtonBar(parent);
+					getText().addModifyListener(new ModifyListener() {
+						@Override
+						public void modifyText(ModifyEvent e) {
+							if (!toRebase.isRebaseable()) {
+								if (!getText().getText().isEmpty()) {
+									getOkButton().setEnabled(true);
+								} else {
+									getOkButton().setEnabled(false);
+									getOkButton().getParent().setToolTipText(toRebase.isRebaseable()
+											? "" //$NON-NLS-1$
+											: Messages.RebaseProcess_changeIsAlreadyUpToDate);
+								}
 							}
 						}
+					});
+					getOkButton().setEnabled(toRebase.isRebaseable());
+					getOkButton().getParent().setToolTipText(
+							toRebase.isRebaseable() ? "" : Messages.RebaseProcess_changeIsAlreadyUpToDate); //$NON-NLS-1$
+					return;
+				}
+			};
+
+			if (inputDialog.open() != Window.OK) {
+				return;
+			}
+			RebaseRevisionCommand rebaseCmd = gerritClient.rebase(changeInfo.getId(), toRebase.getId());
+			RebaseInput rebaseInput = new RebaseInput();
+			rebaseInput.setBase(inputDialog.getValue().trim().length() == 0 ? null : inputDialog.getValue().trim());
+
+			rebaseCmd.setCommandInput(rebaseInput);
+
+			CompletableFuture.runAsync(() -> {
+				/* Add listener for when the loadBasicInformation method will have finished updating the related changes */
+				changeInfo.eAdapters().add(new EContentAdapter() {
+					@Override
+					public void notifyChanged(Notification msg) {
+						if (msg.getFeature() == null) {
+							return;
+						}
+						if (msg.getFeature().equals(ModelPackage.Literals.CHANGE_INFO__RELATED_CHANGES)
+								&& msg.getEventType() == Notification.SET) {
+							new RefreshRelatedEditors(changeInfo, gerritClient).schedule();
+							/* We remove the adapter once the refresh has been started because it now has enough information to correctly
+							 * refresh related opened editors */
+							changeInfo.eAdapters().remove(this);
+						}
 					}
 				});
-				getOkButton().setEnabled(toRebase.isRebaseable());
-				getOkButton().getParent()
-						.setToolTipText(toRebase.isRebaseable() ? "" : Messages.RebaseProcess_changeIsAlreadyUpToDate); //$NON-NLS-1$
-				return;
-			}
-		};
+				try {
+					rebaseCmd.call();
+				} catch (EGerritException e) {
+					if (e.getCode() == EGerritException.SHOWABLE_MESSAGE) {
 
-		if (inputDialog.open() != Window.OK) {
-			return;
-		}
-		RebaseRevisionCommand rebaseCmd = gerritClient.rebase(changeInfo.getId(), toRebase.getId());
-		RebaseInput rebaseInput = new RebaseInput();
-		rebaseInput.setBase(inputDialog.getValue().trim().length() == 0 ? null : inputDialog.getValue().trim());
-
-		rebaseCmd.setCommandInput(rebaseInput);
-
-		CompletableFuture.runAsync(() -> {
-			/* Add listener for when the loadBasicInformation method will have finished updating the related changes */
-			changeInfo.eAdapters().add(new EContentAdapter() {
-				@Override
-				public void notifyChanged(Notification msg) {
-					if (msg.getFeature() == null) {
-						return;
-					}
-					if (msg.getFeature().equals(ModelPackage.Literals.CHANGE_INFO__RELATED_CHANGES)
-							&& msg.getEventType() == Notification.SET) {
-						new RefreshRelatedEditors(changeInfo, gerritClient).schedule();
-						/* We remove the adapter once the refresh has been started because it now has enough information to correctly
-						 * refresh related opened editors */
-						changeInfo.eAdapters().remove(this);
-					}
-				}
-			});
-			try {
-				rebaseCmd.call();
-			} catch (EGerritException e) {
-				if (e.getCode() == EGerritException.SHOWABLE_MESSAGE) {
-
-					/* Ask for the the automatic rebase process if no choice was entered by the user
-					 * else just show the error message. */
-					if (inputDialog.getValue().trim().length() > 0) {
-
-						Display.getDefault().syncExec(new Runnable() {
-
-							@Override
-							public void run() {
-								MessageDialog.open(MessageDialog.INFORMATION, null, Messages.RebaseProcess_failed,
-										Messages.RebaseProcess_notPerform, SWT.NONE);
-							}
-						});
+						/* Ask for the the automatic rebase process if no choice was entered by the user
+						 * else just show the error message. */
+						if (inputDialog.getValue().trim().length() > 0) {
+							Display.getDefault().syncExec(new Runnable() {
+								@Override
+								public void run() {
+									MessageDialog.open(MessageDialog.INFORMATION, null, Messages.RebaseProcess_failed,
+											Messages.RebaseProcess_notPerform, SWT.NONE);
+								}
+							});
+						} else {
+							suggestLocalRebase(toRebase, gerritClient);
+						}
 					} else {
-						suggestLocalRebase(toRebase, gerritClient);
+						EGerritCorePlugin.logError(gerritClient.getRepository().formatGerritVersion() + e.getMessage());
 					}
+				}
+			}).thenRun(() -> {
+				QueryHelpers.loadBasicInformation(gerritClient, changeInfo, true);
+				changeInfo.setUserSelectedRevision(changeInfo.getRevision());
+			});
+
+		}
+	}
+
+	private void showNoRepoDialog(Boolean isLocal) {
+		Display.getDefault().syncExec(new Runnable() {
+			@Override
+			public void run() {
+				if (isLocal) {
+					MessageDialog.open(MessageDialog.INFORMATION, null, Messages.RebaseProcess_TitleRebaseFailedNoRepo,
+							Messages.RebaseProcess_LocalNoRepo, SWT.NONE);
 				} else {
-					EGerritCorePlugin.logError(gerritClient.getRepository().formatGerritVersion() + e.getMessage());
+					MessageDialog.open(MessageDialog.INFORMATION, null, Messages.RebaseProcess_TitleRebaseFailedNoRepo,
+							Messages.RebaseProcess_CouldNotPerformRemoteRebaseNoRepo, SWT.NONE);
 				}
 			}
-		}).thenRun(() -> {
-			QueryHelpers.loadBasicInformation(gerritClient, changeInfo, true);
-			changeInfo.setUserSelectedRevision(changeInfo.getRevision());
 		});
 	}
 
@@ -156,14 +204,7 @@
 				process.schedule();
 			}
 		} else {
-			Display.getDefault().syncExec(new Runnable() {
-				@Override
-				public void run() {
-					MessageDialog.open(MessageDialog.INFORMATION, null, Messages.RebaseProcess_TitleRebaseFailedNoRepo,
-							Messages.RebaseProcess_CouldNotPerformRemoteRebaseNoRepo,
-							SWT.NONE);
-				}
-			});
+			showNoRepoDialog(false);
 		}
 	}
 
diff --git a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/editors/ChangeDetailEditor.java b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/editors/ChangeDetailEditor.java
index 12eeb57..9144fa4 100644
--- a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/editors/ChangeDetailEditor.java
+++ b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/editors/ChangeDetailEditor.java
@@ -14,7 +14,6 @@
 

 package org.eclipse.egerrit.internal.ui.editors;

 

-import java.lang.reflect.InvocationTargetException;

 import java.util.Iterator;

 import java.util.Map;

 import java.util.Map.Entry;

@@ -595,7 +594,7 @@
 

 		Button rebaseButton = new Button(c, SWT.PUSH);

 		rebaseButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

-		rebaseButton.setText(ActionConstants.REBASE.getLiteral());

+		rebaseButton.setText(ActionConstants.REBASE.getLiteral() + "..."); //$NON-NLS-1$

 

 		//Bind the rebase button

 		{

@@ -607,19 +606,7 @@
 			bindingContext.bindValue(WidgetProperties.enabled().observe(rebaseButton), observeRebasable,

 					new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);

 		}

-		rebaseButton.addSelectionListener(new SelectionAdapter() {

-

-			@Override

-			public void widgetSelected(SelectionEvent e) {

-				RebaseProcess rebaseProcess = new RebaseProcess();

-				try {

-					rebaseProcess.handleRebase(rebaseButton.getShell(), fChangeInfo,

-							fChangeInfo.getUserSelectedRevision(), fGerritClient);

-				} catch (InvocationTargetException e1) {

-					EGerritCorePlugin.logError(e1.getMessage());

-				}

-			}

-		});

+		rebaseButton.addSelectionListener(rebaseButtonListener(rebaseButton.getShell()));

 

 		Button download = new Button(c, SWT.PUSH);

 		download.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

@@ -679,7 +666,6 @@
 		bindingContext.bindValue(WidgetProperties.enabled().observe(draftButton), observeDeleteable,

 				new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null);

 		draftButton.addSelectionListener(new SelectionAdapter() {

-

 			@Override

 			public void widgetSelected(SelectionEvent e) {

 				org.eclipse.swt.widgets.Menu menu = new org.eclipse.swt.widgets.Menu(draftButton.getShell(),

@@ -745,13 +731,31 @@
 

 				menu.setVisible(true);

 			}

-

 		});

 

 		c.setSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));

 		return c;

 	}

 

+	private SelectionListener rebaseButtonListener(Composite parent) {

+		return new SelectionListener() {

+			@Override

+			public void widgetSelected(SelectionEvent e) {

+				MenuManager mgr = new MenuManager();

+				mgr.add(new RebaseProcess(false, parent.getShell(), fChangeInfo, fChangeInfo.getUserSelectedRevision(),

+						fGerritClient));

+				mgr.add(new RebaseProcess(true, parent.getShell(), fChangeInfo, fChangeInfo.getUserSelectedRevision(),

+						fGerritClient));

+				mgr.createContextMenu(parent).setVisible(true);

+			}

+

+			@Override

+			public void widgetDefaultSelected(SelectionEvent e) {

+				//Nothing to do

+			}

+		};

+	}

+

 	private void buildReplyDynamicMenu(Map<String, Integer> adjustedAllowedButton, MenuManager mgr) {

 		mgr.add(new ReplyHandler(fChangeInfo, fGerritClient, ActionConstants.REPLY.getLiteral())); //Add the Reply option

 

diff --git a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/Messages.java b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/Messages.java
index 2e097ef..5db8faa 100644
--- a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/Messages.java
+++ b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/Messages.java
@@ -536,8 +536,14 @@
 
 	public static String RebaseProcess_FetchAppropriateBranches;
 
+	public static String RebaseProcess_LocalNoRepo;
+
 	public static String RebaseProcess_RebaseCheckedOut;
 
+	public static String RebaseProcess_RebaseLocally;
+
+	public static String RebaseProcess_RebaseRemotely;
+
 	public static String RebaseProcess_StashLocalChanges;
 
 	public static String RebaseProcess_TitleRebaseFailedNoRepo;
diff --git a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/messages.properties b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/messages.properties
index 5c5dca4..405ad42 100644
--- a/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/messages.properties
+++ b/org.eclipse.egerrit.ui/src/org/eclipse/egerrit/internal/ui/utils/messages.properties
@@ -264,7 +264,10 @@
 RebaseProcess_CouldNotPerformRemoteRebaseNoRepo=Gerrit could not perform the rebase automatically on the remote server.\n\nIf you want to try the egerrit automatic local rebase feature, you must first import the git repository associated with the change in your workspace.
 RebaseProcess_CreateAndCheckout=Create and checkout a local branch based on the changeset
 RebaseProcess_FetchAppropriateBranches=Fetch the appropriate branches
+RebaseProcess_LocalNoRepo=No local repository was found.\n\nPlease import the repository associated with the change and try again.
 RebaseProcess_RebaseCheckedOut=Rebase the checked out branch on top of the other branch
+RebaseProcess_RebaseLocally=Rebase (locally)
+RebaseProcess_RebaseRemotely=Rebase (remotely)
 RebaseProcess_StashLocalChanges=Stash your local changes
 RebaseProcess_TitleRebaseFailedNoRepo=Rebase failed (no local repository)
 RebaseProcess_ToStash=\ to stash)