Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2019-12-11 08:31:43 +0000
committerThomas Wolf2019-12-11 08:33:46 +0000
commit9ee1c5174b874c212f33b67b3ec4572e793ef74a (patch)
tree0b8c36bf0f762596ded31de565f560ddb9ff5b5c
parent0a7c760f1ab994c76a55b4b77ca59a7d75e1b91e (diff)
downloadegit-9ee1c5174b874c212f33b67b3ec4572e793ef74a.tar.gz
egit-9ee1c5174b874c212f33b67b3ec4572e793ef74a.tar.xz
egit-9ee1c5174b874c212f33b67b3ec4572e793ef74a.zip
Fix parent of LoginDialog
This dialog may be opened from background tasks. It cannot use the current window's shell as parent but must be parented off the top- most modal dialog, if there is any. Use the IModalDialogShellProvider. Bug: 558012 Change-Id: I0a3b4ef63ae1ad11d477a19403893d1fd7267778 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/credentials/EGitCredentialsProvider.java43
1 files changed, 16 insertions, 27 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/credentials/EGitCredentialsProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/credentials/EGitCredentialsProvider.java
index 4d543df39..5e2dc6d27 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/credentials/EGitCredentialsProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/credentials/EGitCredentialsProvider.java
@@ -120,18 +120,15 @@ public class EGitCredentialsProvider extends CredentialsProvider {
// special handling for non-user,non-password type items
final boolean[] result = new boolean[1];
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
-
- if (items.length == 1) {
- CredentialItem item = items[0];
- result[0] = getSingleSpecial(shell, uri, item);
- } else {
- result[0] = getMultiSpecial(shell, uri, items);
- }
+ PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ Shell shell = PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell();
+
+ if (items.length == 1) {
+ CredentialItem item = items[0];
+ result[0] = getSingleSpecial(shell, uri, item);
+ } else {
+ result[0] = getMultiSpecial(shell, uri, items);
}
});
@@ -170,21 +167,18 @@ public class EGitCredentialsProvider extends CredentialsProvider {
MessageDialog.QUESTION_WITH_CANCEL,
labels,
0);
- dialog.setBlockOnOpen(true);
int r = dialog.open();
if (r < 0) {
return false;
}
switch (resultIDs[r]) {
- case IDialogConstants.YES_ID: {
+ case IDialogConstants.YES_ID:
v.setValue(true);
return true;
- }
- case IDialogConstants.NO_ID: {
+ case IDialogConstants.NO_ID:
v.setValue(false);
return true;
- }
default:
// abort
return false;
@@ -205,9 +199,7 @@ public class EGitCredentialsProvider extends CredentialsProvider {
*/
private boolean getMultiSpecial(Shell shell, URIish uri, CredentialItem... items) {
CustomPromptDialog dialog = new CustomPromptDialog(shell, uri, UIText.EGitCredentialsProvider_information, items);
- dialog.setBlockOnOpen(true);
- int r = dialog.open();
- if (r == Window.OK) {
+ if (dialog.open() == Window.OK) {
return true;
}
return false;
@@ -216,13 +208,10 @@ public class EGitCredentialsProvider extends CredentialsProvider {
private UserPasswordCredentials getCredentialsFromUser(final URIish uri) {
final AtomicReference<UserPasswordCredentials> aRef = new AtomicReference<>(
null);
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getShell();
- aRef.set(LoginService.login(shell, uri));
- }
+ PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ Shell shell = PlatformUI.getWorkbench()
+ .getModalDialogShellProvider().getShell();
+ aRef.set(LoginService.login(shell, uri));
});
return aRef.get();
}

Back to the top