Skip to content

Commit 7f09196

Browse files
committed
Enable multi-status dialog when message exceeds threshold
Improve the Status Dialog by enabling a multi-status when the no. status message lines exceeds a predefined line threshold. This enhances readability.
1 parent 2a540d3 commit 7f09196

3 files changed

Lines changed: 50 additions & 10 deletions

File tree

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DebugUIMessages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public class DebugUIMessages extends NLS {
146146
public static String JDIDebugUIPlugin_4;
147147
public static String JDIDebugUIPlugin_5;
148148

149+
public static String JDIDebugUIPlugin_MultiStatusError;
150+
149151
public static String JDIModelPresentation__No_explicit_return_value__30;
150152
public static String JDIModelPresentation__conditional__2;
151153
public static String JDIModelPresentation___may_be_out_of_synch__2;
@@ -478,4 +480,8 @@ public class DebugUIMessages extends NLS {
478480
public static String fExceptionBreakpointMsg;
479481

480482
protected static String JavaDebugOptionsManager_Lambda_Breakpoint;
483+
484+
public static String JDIDebugUIPlugin_MultiStatusWarning;
485+
486+
public static String JDIDebugUIPlugin_MultiStatusInfo;
481487
}

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DebugUIMessages.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ JDIDebugUIPlugin_The_target_VM_does_not_support_hot_code_replace_1=The target VM
9090
JDIDebugUIPlugin_3=Do not show error &when hot code replace is not supported
9191
JDIDebugUIPlugin_0=Warning
9292
JDIDebugUIPlugin_5=Ignore errors in current session
93+
JDIDebugUIPlugin_MultiStatusError=Multiple errors occurred
94+
JDIDebugUIPlugin_MultiStatusWarning=There are multiple warnings
95+
JDIDebugUIPlugin_MultiStatusInfo=There are multiple informational messages
9396

9497
JDIModelPresentation__No_explicit_return_value__30=(No explicit return value)
9598
JDIModelPresentation__conditional__2=[conditional]

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2024 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -33,6 +33,7 @@
3333
import org.eclipse.core.runtime.IExtensionPoint;
3434
import org.eclipse.core.runtime.IProgressMonitor;
3535
import org.eclipse.core.runtime.IStatus;
36+
import org.eclipse.core.runtime.MultiStatus;
3637
import org.eclipse.core.runtime.Platform;
3738
import org.eclipse.core.runtime.Status;
3839
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -89,6 +90,7 @@
8990
import org.eclipse.jface.preference.PreferenceNode;
9091
import org.eclipse.jface.resource.ImageRegistry;
9192
import org.eclipse.jface.window.Window;
93+
import org.eclipse.osgi.util.NLS;
9294
import org.eclipse.swt.custom.BusyIndicator;
9395
import org.eclipse.swt.widgets.Display;
9496
import org.eclipse.swt.widgets.Shell;
@@ -139,6 +141,8 @@ public class JDIDebugUIPlugin extends AbstractUIPlugin {
139141

140142
private StackFrameCategorizer stackFrameCategorizer;
141143

144+
private static final int STATUS_LINE_LIMIT = 10;
145+
142146
/**
143147
* Java Debug UI listeners
144148
*/
@@ -276,19 +280,46 @@ public static void statusDialog(IStatus status) {
276280
break;
277281
}
278282
}
283+
279284
public static void statusDialog(String title, IStatus status) {
280285
Shell shell = getActiveWorkbenchShell();
286+
String message = status.getMessage();
287+
long currentLines = message.lines().limit(STATUS_LINE_LIMIT + 1).count();
288+
boolean showInMulti = currentLines > STATUS_LINE_LIMIT;
289+
String pluginId = status.getPlugin();
290+
if (pluginId == null) {
291+
JDIDebugUIPlugin plugin = getDefault();
292+
pluginId = (plugin != null && JDIDebugUIPlugin.getUniqueIdentifier() != null) ? JDIDebugUIPlugin.getUniqueIdentifier()
293+
: JDIDebugUIPlugin.class.getName();
294+
}
295+
281296
if (shell != null) {
282297
switch (status.getSeverity()) {
283-
case IStatus.ERROR:
284-
ErrorDialog.openError(shell, title, null, status);
285-
break;
286-
case IStatus.WARNING:
287-
MessageDialog.openWarning(shell, title, status.getMessage());
288-
break;
289-
case IStatus.INFO:
290-
MessageDialog.openInformation(shell, title, status.getMessage());
291-
break;
298+
case IStatus.ERROR:
299+
if (showInMulti) {
300+
status = new MultiStatus(pluginId, status.getCode(), new IStatus[] {
301+
status }, NLS.bind(DebugUIMessages.JDIDebugUIPlugin_MultiStatusError, title.toLowerCase()), null);
302+
} else {
303+
ErrorDialog.openError(shell, title, null, status);
304+
}
305+
break;
306+
case IStatus.WARNING:
307+
if (showInMulti) {
308+
status = new MultiStatus(pluginId, status.getCode(), new IStatus[] {
309+
status }, NLS.bind(DebugUIMessages.JDIDebugUIPlugin_MultiStatusWarning, title.toLowerCase()), null);
310+
ErrorDialog.openError(shell, title, null, status);
311+
} else {
312+
MessageDialog.openWarning(shell, title, status.getMessage());
313+
}
314+
break;
315+
case IStatus.INFO:
316+
if (showInMulti) {
317+
status = new MultiStatus(pluginId, status.getCode(), new IStatus[] {
318+
status }, NLS.bind(DebugUIMessages.JDIDebugUIPlugin_MultiStatusInfo, title.toLowerCase()), null);
319+
ErrorDialog.openError(shell, title, null, status);
320+
} else {
321+
MessageDialog.openInformation(shell, title, status.getMessage());
322+
}
292323
}
293324
}
294325
}

0 commit comments

Comments
 (0)