|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2024 IBM Corporation and others. |
| 2 | + * Copyright (c) 2000, 2026 IBM Corporation and others. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
33 | 33 | import org.eclipse.core.runtime.IExtensionPoint; |
34 | 34 | import org.eclipse.core.runtime.IProgressMonitor; |
35 | 35 | import org.eclipse.core.runtime.IStatus; |
| 36 | +import org.eclipse.core.runtime.MultiStatus; |
36 | 37 | import org.eclipse.core.runtime.Platform; |
37 | 38 | import org.eclipse.core.runtime.Status; |
38 | 39 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|
89 | 90 | import org.eclipse.jface.preference.PreferenceNode; |
90 | 91 | import org.eclipse.jface.resource.ImageRegistry; |
91 | 92 | import org.eclipse.jface.window.Window; |
| 93 | +import org.eclipse.osgi.util.NLS; |
92 | 94 | import org.eclipse.swt.custom.BusyIndicator; |
93 | 95 | import org.eclipse.swt.widgets.Display; |
94 | 96 | import org.eclipse.swt.widgets.Shell; |
@@ -139,6 +141,8 @@ public class JDIDebugUIPlugin extends AbstractUIPlugin { |
139 | 141 |
|
140 | 142 | private StackFrameCategorizer stackFrameCategorizer; |
141 | 143 |
|
| 144 | + private static final int STATUS_LINE_LIMIT = 10; |
| 145 | + |
142 | 146 | /** |
143 | 147 | * Java Debug UI listeners |
144 | 148 | */ |
@@ -276,21 +280,55 @@ public static void statusDialog(IStatus status) { |
276 | 280 | break; |
277 | 281 | } |
278 | 282 | } |
| 283 | + |
279 | 284 | public static void statusDialog(String title, IStatus status) { |
280 | 285 | 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 | + } |
281 | 298 | if (shell != null) { |
282 | 299 | 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 | + } |
292 | 329 | } |
293 | 330 | } |
| 331 | + return false; |
294 | 332 | } |
295 | 333 |
|
296 | 334 | /** |
|
0 commit comments