Skip to content

Commit c0274eb

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 3c8fbbd commit c0274eb

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

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

Lines changed: 3 additions & 1 deletion
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
@@ -144,6 +144,8 @@ public class DebugUIMessages extends NLS {
144144
public static String JDIDebugUIPlugin_4;
145145
public static String JDIDebugUIPlugin_5;
146146

147+
public static String JDIDebugUIPlugin_MultiStatusLabel;
148+
147149
public static String JDIModelPresentation__No_explicit_return_value__30;
148150
public static String JDIModelPresentation__conditional__2;
149151
public static String JDIModelPresentation___may_be_out_of_synch__2;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ JDIDebugUIPlugin_The_target_VM_does_not_support_hot_code_replace_1=The target VM
8989
JDIDebugUIPlugin_3=Do not show error &when hot code replace is not supported
9090
JDIDebugUIPlugin_0=Warning
9191
JDIDebugUIPlugin_5=Ignore errors in current session
92+
JDIDebugUIPlugin_MultiStatusLabel=Multiple occurrences of ''{0}'' encountered. See details for more information.
9293

9394
JDIModelPresentation__No_explicit_return_value__30=(No explicit return value)
9495
JDIModelPresentation__conditional__2=[conditional]

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

Lines changed: 48 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,21 +280,55 @@ 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+
boolean showInMulti = exceedsStatusLineLimit(message);
288+
if (showInMulti) {
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+
status = new MultiStatus(pluginId, status.getCode(), new IStatus[] {
296+
status }, NLS.bind(DebugUIMessages.JDIDebugUIPlugin_MultiStatusLabel, title.toLowerCase()), null);
297+
}
281298
if (shell != null) {
282299
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;
300+
case IStatus.ERROR:
301+
ErrorDialog.openError(shell, title, null, status);
302+
break;
303+
case IStatus.WARNING:
304+
MessageDialog.openWarning(shell, title, status.getMessage());
305+
break;
306+
case IStatus.INFO:
307+
MessageDialog.openInformation(shell, title, status.getMessage());
308+
break;
309+
}
310+
}
311+
}
312+
313+
private static boolean exceedsStatusLineLimit(String message) {
314+
if (message == null || message.isEmpty()) {
315+
return false;
316+
}
317+
int lines = 1;
318+
for (int i = 0; i < message.length(); i++) {
319+
char c = message.charAt(i);
320+
if (c == '\n' || c == '\r') {
321+
lines++;
322+
if (lines > STATUS_LINE_LIMIT) {
323+
return true;
324+
}
325+
326+
if (c == '\r' && i + 1 < message.length() && message.charAt(i + 1) == '\n') {
327+
i++;
328+
}
292329
}
293330
}
331+
return false;
294332
}
295333

296334
/**

0 commit comments

Comments
 (0)