Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-05-24 18:49:12 +0000
committerMatthias Sohn2016-05-25 08:38:11 +0000
commitd58c936fa4cc6e1d412a419aa9f931dbd645f7f2 (patch)
tree5f4feea151ab2e23cc98dd68bf70d929ff278f44
parent253cfab6051fc7837a2212f88c98b91702a98f0d (diff)
downloadegit-d58c936fa4cc6e1d412a419aa9f931dbd645f7f2.tar.gz
egit-d58c936fa4cc6e1d412a419aa9f931dbd645f7f2.tar.xz
egit-d58c936fa4cc6e1d412a419aa9f931dbd645f7f2.zip
Create push wizards in CommitJob in UI thread
The PushBranchWizard may have an AddRemotePage, which is a RepositorySelectionPage, which accesses the clipboard in its constructor. Let's create the wizard already in the UI thread, as it was before commit af5c88dc. Bug: 494469 Change-Id: Ifd7383a806becc7db20b2b44b6a67533394d91e5 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java63
1 files changed, 35 insertions, 28 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
index c927ca8e63..64952bdbc3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012-2014 Red Hat, Inc. Distributed under license by Red Hat, Inc.
+ * Copyright (c) 2012-2016 Red Hat, Inc, and others. Distributed under license by Red Hat, Inc.
* 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
@@ -163,51 +163,58 @@ public class CommitJob extends Job {
}
private void pushUpstream(final RevCommit commit, final PushMode pushTo) {
- RemoteConfig config = SimpleConfigurePushDialog
+ final RemoteConfig config = SimpleConfigurePushDialog
.getConfiguredRemote(repository);
- if (pushTo == PushMode.GERRIT) {
- final Wizard pushWizard = new PushToGerritWizard(repository);
- openPushWizard(pushWizard);
- } else if (config == null) {
+ if (pushTo == PushMode.GERRIT || config == null) {
+ final Display display = PlatformUI.getWorkbench().getDisplay();
+ display.asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ Wizard pushWizard = getPushWizard(commit, pushTo);
+ if (pushWizard != null) {
+ WizardDialog wizardDialog = new WizardDialog(
+ display.getActiveShell(), pushWizard);
+ wizardDialog.setHelpAvailable(true);
+ wizardDialog.open();
+ }
+ }
+ });
+ } else {
+ PushOperationUI op = new PushOperationUI(repository,
+ config.getName(), false);
+ op.start();
+ }
+ }
+
+ private Wizard getPushWizard(final RevCommit commit,
+ final PushMode pushTo) {
+ switch (pushTo) {
+ case GERRIT:
+ return new PushToGerritWizard(repository);
+ case UPSTREAM:
try {
- Wizard pushWizard = null;
String fullBranch = repository.getFullBranch();
if (fullBranch != null
&& fullBranch.startsWith(Constants.R_HEADS)) {
Ref ref = repository.exactRef(fullBranch);
- pushWizard = new PushBranchWizard(repository, ref);
+ return new PushBranchWizard(repository, ref);
} else {
- pushWizard = new PushBranchWizard(repository,
+ return new PushBranchWizard(repository,
commit.getId());
}
- openPushWizard(pushWizard);
} catch (IOException e) {
Activator.handleError(
NLS.bind(UIText.CommitUI_pushFailedMessage, e), e,
true);
+ return null;
}
- } else {
- PushOperationUI op = new PushOperationUI(repository,
- config.getName(), false);
- op.start();
+ default:
+ return null;
}
}
- private void openPushWizard(final Wizard pushWizard) {
- final Display display = Display.getDefault();
- display.asyncExec(new Runnable() {
-
- @Override
- public void run() {
- WizardDialog wizardDialog = new WizardDialog(display
- .getActiveShell(), pushWizard);
- wizardDialog.setHelpAvailable(true);
- wizardDialog.open();
- }
- });
- }
-
@Override
public boolean belongsTo(Object family) {
if (JobFamilies.COMMIT.equals(family))

Back to the top