Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Georgi2014-05-16 15:57:28 +0000
committerMatthias Sohn2014-05-16 23:12:29 +0000
commit10589b6a8061333103076d8d46d99a30ec3a369c (patch)
treea576e581e1cc018bafc977142c995c6fa3ce995d
parent3545a102de6e8672fb0798d468b5103c35d3bdac (diff)
downloadegit-10589b6a8061333103076d8d46d99a30ec3a369c.tar.gz
egit-10589b6a8061333103076d8d46d99a30ec3a369c.tar.xz
egit-10589b6a8061333103076d8d46d99a30ec3a369c.zip
Do not let PushToGerrit block the UI
Change-Id: Ia05bfc3f2d37a60ed43765b005ccf9e58e477f53 Signed-off-by: Christian Georgi <christian.georgi@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java28
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritWizard.java17
2 files changed, 23 insertions, 22 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
index 03465320bf..a835d79a59 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritPage.java
@@ -11,6 +11,7 @@
package org.eclipse.egit.ui.internal.push;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,6 +39,7 @@ import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
@@ -212,7 +214,7 @@ class PushToGerritPage extends WizardPage {
}
}
- void doPush(IProgressMonitor monitor) {
+ void doPush() {
try {
URIish uri = new URIish(uriCombo.getText());
Ref currentHead = repository.getRef(Constants.HEAD);
@@ -223,21 +225,35 @@ class PushToGerritPage extends WizardPage {
PushOperationSpecification spec = new PushOperationSpecification();
spec.addURIRefUpdates(uri, Arrays.asList(update));
- PushOperationUI op = new PushOperationUI(repository, spec, false);
+ final PushOperationUI op = new PushOperationUI(repository, spec,
+ false);
op.setCredentialsProvider(new EGitCredentialsProvider());
- PushOperationResult result = op.execute(monitor);
+ final PushOperationResult[] result = new PushOperationResult[1];
+ getContainer().run(true, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ result[0] = op.execute(monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
PushResultDialog dlg = new PushResultDialog(getShell(), repository,
- result, op.getDestinationString());
+ result[0], op.getDestinationString());
dlg.showConfigureButton(false);
dlg.open();
storeLastUsedUri(uriCombo.getText());
storeLastUsedBranch(branchText.getText());
- } catch (CoreException e) {
- Activator.handleError(e.getMessage(), e, true);
} catch (URISyntaxException e) {
Activator.handleError(e.getMessage(), e, true);
} catch (IOException e) {
Activator.handleError(e.getMessage(), e, true);
+ } catch (InvocationTargetException e) {
+ Throwable cause = e.getCause();
+ Activator.handleError(cause.getMessage(), cause, true);
+ } catch (InterruptedException e) {
+ // cancellation
}
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritWizard.java
index 75682ae946..574caff4ba 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushToGerritWizard.java
@@ -10,12 +10,8 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.push;
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jgit.lib.Repository;
@@ -47,18 +43,7 @@ public class PushToGerritWizard extends Wizard {
@Override
public boolean performFinish() {
- try {
- getContainer().run(false, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- page.doPush(monitor);
- }
- });
- } catch (InvocationTargetException e) {
- return false;
- } catch (InterruptedException e) {
- return false;
- }
+ page.doPush();
return true;
}
}

Back to the top