Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimeon Andreev2018-08-08 07:51:52 +0000
committerSimeon Andreev2018-08-08 10:24:41 +0000
commite0c6dbf15dc7a6f63d5511a85395138bddf2aece (patch)
treeb41ce77a1bb49087cf003b16046ba51a5eafc4ea
parent4d9a3fd93350e5cc3ee78e8586a4a3acf8e303c9 (diff)
downloadeclipse.platform.team-I20180810-2000.tar.gz
eclipse.platform.team-I20180810-2000.tar.xz
eclipse.platform.team-I20180810-2000.zip
A dialog is shown when validating a read-only file, which has a pending modification in an editor. The dialog states that the file is read-only and asks whether the file should be made writable. When running the validation code (DefaultUIFileModificationValidator.validateEdit()) from a non-UI thread, an extra shell is created. This shell is seen as an additional empty window. This change avoids the extra window by using the workbench display to run the necessary UI code, if validation is done from a non-UI thread. It also passes down a null parent shell to the dialog, which is handled by the jface dialog. Change-Id: Ie16286f1d51d2282593fdb4c6dc5d4d6ec914249 Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java
index bcafdf853..366ee49cd 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java
@@ -22,10 +22,10 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.*;
import org.eclipse.team.internal.core.DefaultFileModificationValidator;
import org.eclipse.team.internal.ui.dialogs.DetailsDialog;
+import org.eclipse.ui.*;
/**
* Override the default file modification validator to prompt to
@@ -112,9 +112,9 @@ public class DefaultUIFileModificationValidator extends DefaultFileModificationV
final Shell shell = getShell(context);
final boolean[] ok = new boolean[] { false };
if (readOnlyFiles.length == 1) {
- shell.getDisplay().syncExec(() -> ok[0] = MessageDialog.openQuestion(shell, TeamUIMessages.DefaultUIFileModificationValidator_3, NLS.bind(TeamUIMessages.DefaultUIFileModificationValidator_4, new String[] { readOnlyFiles[0].getFullPath().toString() })));
+ syncExec(() -> ok[0] = MessageDialog.openQuestion(shell, TeamUIMessages.DefaultUIFileModificationValidator_3, NLS.bind(TeamUIMessages.DefaultUIFileModificationValidator_4, new String[] { readOnlyFiles[0].getFullPath().toString() })));
} else {
- shell.getDisplay().syncExec(() -> ok[0] = FileListDialog.openQuestion(shell, readOnlyFiles));
+ syncExec(() -> ok[0] = FileListDialog.openQuestion(shell, readOnlyFiles));
}
if (ok[0]) {
setWritable(readOnlyFiles);
@@ -130,7 +130,17 @@ public class DefaultUIFileModificationValidator extends DefaultFileModificationV
private Shell getShell(FileModificationValidationContext context) {
if (context.getShell() != null)
return (Shell)context.getShell();
- return Utils.getShell(null, true);
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ if (window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
+
+ private static void syncExec(Runnable runnable) {
+ Display display = PlatformUI.getWorkbench().getDisplay();
+ display.syncExec(runnable);
}
@Override

Back to the top