Skip to content

Commit

Permalink
Use proper shell for modal dialogs
Browse files Browse the repository at this point in the history
This prevents the dialogs to appear behind the possible opened progress
dialog (or any other modal dialog).

See eclipse-platform/eclipse.platform#1373
  • Loading branch information
iloveeclipse committed May 16, 2024
1 parent dc5bf43 commit 3530050
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

import com.sun.jdi.ReferenceType;

Expand All @@ -32,7 +33,7 @@ public Object handleStatus(IStatus status, Object source) {
ReferenceType type= (ReferenceType) source;
IPreferenceStore preferenceStore= JDIDebugUIPlugin.getDefault().getPreferenceStore();
if (preferenceStore.getBoolean(IJDIPreferencesConstants.PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT)) {
final ErrorDialogWithToggle dialog= new ErrorDialogWithToggle(JDIDebugUIPlugin.getActiveWorkbenchShell(),
final ErrorDialogWithToggle dialog = new ErrorDialogWithToggle(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(),
DebugUIMessages.NoLineNumberAttributesStatusHandler_Java_Breakpoint_1,
NLS.bind(DebugUIMessages.NoLineNumberAttributesStatusHandler_2, new String[] {type.name()}),
status, IJDIPreferencesConstants.PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;

public class SuspendTimeoutStatusHandler implements IStatusHandler {

Expand All @@ -30,7 +31,7 @@ public class SuspendTimeoutStatusHandler implements IStatusHandler {
@Override
public Object handleStatus(IStatus status, Object source) throws CoreException {
IJavaThread thread= (IJavaThread) source;
final ErrorDialog dialog= new ErrorDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), DebugUIMessages.SuspendTimeoutHandler_suspend, NLS.bind(DebugUIMessages.SuspendTimeoutHandler_timeout_occurred, new String[] {thread.getName()}), status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); //
final ErrorDialog dialog= new ErrorDialog(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), DebugUIMessages.SuspendTimeoutHandler_suspend, NLS.bind(DebugUIMessages.SuspendTimeoutHandler_timeout_occurred, new String[] {thread.getName()}), status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); //
Display display= JDIDebugUIPlugin.getStandardDisplay();
display.syncExec(new Runnable() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.PlatformUI;

/**
* Prompts the user to continue waiting for a connection
Expand All @@ -36,7 +37,7 @@ public Object handleStatus(IStatus status, Object source) {
public void run() {
String title= LauncherMessages.VMConnectTimeoutStatusHandler_Java_Application_1;
String message= LauncherMessages.jdkLauncher_error_timeout;
result[0]= (MessageDialog.openQuestion(JDIDebugUIPlugin.getActiveWorkbenchShell(), title, message));
result[0] = (MessageDialog.openQuestion(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), title, message));
}
});
return Boolean.valueOf(result[0]);
Expand Down

0 comments on commit 3530050

Please sign in to comment.