|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2000, 2025 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 |
|
16 | 16 |
|
17 | 17 | package org.eclipse.ui.internal; |
18 | 18 |
|
| 19 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_COMMANDS; |
| 20 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_COMMANDS_FLAG; |
| 21 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS; |
| 22 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS_FLAG; |
| 23 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS_PERFORMANCE; |
| 24 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS_PERFORMANCE_FLAG; |
| 25 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS_VERBOSE; |
| 26 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTEXTS_VERBOSE_FLAG; |
| 27 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTRIBUTIONS; |
| 28 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_CONTRIBUTIONS_FLAG; |
| 29 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_DECLARED_IMAGES; |
| 30 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_DECLARED_IMAGES_FLAG; |
| 31 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_DRAG_DROP; |
| 32 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_DRAG_DROP_FLAG; |
| 33 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS; |
| 34 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_FLAG; |
| 35 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_PERFORMANCE; |
| 36 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_PERFORMANCE_FLAG; |
| 37 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_VERBOSE; |
| 38 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID; |
| 39 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_VERBOSE_COMMAND_ID_FLAG; |
| 40 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_HANDLERS_VERBOSE_FLAG; |
| 41 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_KEY_BINDINGS; |
| 42 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_KEY_BINDINGS_FLAG; |
| 43 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_KEY_BINDINGS_VERBOSE; |
| 44 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_KEY_BINDINGS_VERBOSE_FLAG; |
| 45 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_MPE; |
| 46 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_MPE_FLAG; |
| 47 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_OPERATIONS; |
| 48 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_OPERATIONS_FLAG; |
| 49 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_OPERATIONS_VERBOSE; |
| 50 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_OPERATIONS_VERBOSE_FLAG; |
| 51 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SHOW_ALL_JOBS; |
| 52 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SHOW_ALL_JOBS_FLAG; |
| 53 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SOURCES; |
| 54 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SOURCES_FLAG; |
| 55 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_STALE_JOBS; |
| 56 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_STALE_JOBS_FLAG; |
| 57 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_DEBUG; |
| 58 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_DEBUG_FLAG; |
| 59 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_DEBUG_GLOBAL; |
| 60 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_DEBUG_GLOBAL_FLAG; |
| 61 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_GRAPHICS; |
| 62 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_SWT_GRAPHICS_FLAG; |
| 63 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_TOOLBAR_DISPOSAL; |
| 64 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_TOOLBAR_DISPOSAL_FLAG; |
| 65 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_WORKING_SETS; |
| 66 | +import static org.eclipse.ui.internal.misc.Policy.DEBUG_WORKING_SETS_FLAG; |
| 67 | +import static org.eclipse.ui.internal.misc.Policy.DEFAULT; |
| 68 | +import static org.eclipse.ui.internal.misc.Policy.EXPERIMENTAL_MENU; |
| 69 | + |
19 | 70 | import java.text.Bidi; |
20 | 71 | import java.text.MessageFormat; |
21 | 72 | import java.util.Collection; |
22 | 73 | import java.util.Collections; |
23 | 74 | import java.util.HashSet; |
| 75 | +import java.util.Hashtable; |
24 | 76 | import java.util.Locale; |
25 | 77 | import org.eclipse.core.runtime.CoreException; |
26 | 78 | import org.eclipse.core.runtime.IConfigurationElement; |
|
41 | 93 | import org.eclipse.jface.util.BidiUtils; |
42 | 94 | import org.eclipse.jface.window.Window; |
43 | 95 | import org.eclipse.osgi.service.debug.DebugOptions; |
| 96 | +import org.eclipse.osgi.service.debug.DebugOptionsListener; |
| 97 | +import org.eclipse.osgi.service.debug.DebugTrace; |
44 | 98 | import org.eclipse.swt.SWT; |
45 | 99 | import org.eclipse.swt.custom.BusyIndicator; |
| 100 | +import org.eclipse.swt.graphics.Device; |
46 | 101 | import org.eclipse.swt.widgets.Display; |
47 | 102 | import org.eclipse.swt.widgets.Shell; |
48 | 103 | import org.eclipse.ui.IDecoratorManager; |
|
58 | 113 | import org.eclipse.ui.internal.help.HelpServiceImpl; |
59 | 114 | import org.eclipse.ui.internal.intro.IIntroRegistry; |
60 | 115 | import org.eclipse.ui.internal.intro.IntroRegistry; |
| 116 | +import org.eclipse.ui.internal.misc.Policy; |
61 | 117 | import org.eclipse.ui.internal.misc.StatusUtil; |
62 | 118 | import org.eclipse.ui.internal.operations.WorkbenchOperationSupport; |
63 | 119 | import org.eclipse.ui.internal.progress.ProgressManager; |
|
85 | 141 | import org.osgi.framework.BundleEvent; |
86 | 142 | import org.osgi.framework.BundleException; |
87 | 143 | import org.osgi.framework.BundleListener; |
| 144 | +import org.osgi.framework.ServiceRegistration; |
88 | 145 | import org.osgi.util.tracker.ServiceTracker; |
89 | 146 |
|
90 | 147 | /** |
|
103 | 160 | * createExecutableExtension to create an executable instance of our workbench |
104 | 161 | * class. |
105 | 162 | */ |
106 | | -public class WorkbenchPlugin extends AbstractUIPlugin { |
| 163 | +public class WorkbenchPlugin extends AbstractUIPlugin implements DebugOptionsListener { |
107 | 164 |
|
108 | 165 | /** |
109 | 166 | * Splash shell constant. |
@@ -163,6 +220,8 @@ public class WorkbenchPlugin extends AbstractUIPlugin { |
163 | 220 | // TODO we should just drop this constant and use PlatformUI.PLUGIN_ID instead |
164 | 221 | public static String PI_WORKBENCH = PlatformUI.PLUGIN_ID; |
165 | 222 |
|
| 223 | + private static final String JFACE = "org.eclipse.jface"; //$NON-NLS-1$ |
| 224 | + |
166 | 225 | /** |
167 | 226 | * The character used to separate preference page category ids |
168 | 227 | */ |
@@ -202,6 +261,10 @@ public class WorkbenchPlugin extends AbstractUIPlugin { |
202 | 261 |
|
203 | 262 | private ICommandHelpService commandHelpService; |
204 | 263 |
|
| 264 | + private ServiceRegistration<DebugOptionsListener> debugRegistration; |
| 265 | + |
| 266 | + private DebugTrace trace; |
| 267 | + |
205 | 268 | /** |
206 | 269 | * Create an instance of the WorkbenchPlugin. The workbench plugin is |
207 | 270 | * effectively the "application" for the workbench UI. The entire UI operates as |
@@ -762,6 +825,10 @@ public void start(BundleContext context) throws Exception { |
762 | 825 | parseBidiArguments(); |
763 | 826 | Window.setDefaultOrientation(getDefaultOrientation()); |
764 | 827 |
|
| 828 | + Hashtable<String, String> properties = new Hashtable<>(2); |
| 829 | + properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PlatformUI.PLUGIN_ID); |
| 830 | + debugRegistration = context.registerService(DebugOptionsListener.class, this, properties); |
| 831 | + |
765 | 832 | // The UI plugin needs to be initialized so that it can install the callback in |
766 | 833 | // PrefUtil, |
767 | 834 | // which needs to be done as early as possible, before the workbench |
@@ -1061,6 +1128,10 @@ public void stop(BundleContext context) throws Exception { |
1061 | 1128 | testableTracker.close(); |
1062 | 1129 | testableTracker = null; |
1063 | 1130 | } |
| 1131 | + if (debugRegistration != null) { |
| 1132 | + debugRegistration.unregister(); |
| 1133 | + debugRegistration = null; |
| 1134 | + } |
1064 | 1135 | super.stop(context); |
1065 | 1136 | } |
1066 | 1137 |
|
@@ -1436,4 +1507,41 @@ public TestableObject getTestableObject() { |
1436 | 1507 | } |
1437 | 1508 | return (TestableObject) testableTracker.getService(); |
1438 | 1509 | } |
| 1510 | + |
| 1511 | + @Override |
| 1512 | + public void optionsChanged(DebugOptions options) { |
| 1513 | + trace = options.newDebugTrace(PlatformUI.PLUGIN_ID); |
| 1514 | + DEBUG_SWT_GRAPHICS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_SWT_GRAPHICS_FLAG, DEFAULT); |
| 1515 | + DEBUG_SWT_DEBUG = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_SWT_DEBUG_FLAG, DEFAULT); |
| 1516 | + DEBUG_SWT_DEBUG_GLOBAL = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_SWT_DEBUG_GLOBAL_FLAG, DEFAULT); |
| 1517 | + DEBUG_DRAG_DROP = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_DRAG_DROP_FLAG, DEFAULT); |
| 1518 | + DEBUG_SOURCES = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_SOURCES_FLAG, DEFAULT); |
| 1519 | + DEBUG_KEY_BINDINGS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_KEY_BINDINGS_FLAG, DEFAULT); |
| 1520 | + DEBUG_KEY_BINDINGS_VERBOSE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_KEY_BINDINGS_VERBOSE_FLAG, DEFAULT); |
| 1521 | + DEBUG_TOOLBAR_DISPOSAL = options.getBooleanOption(JFACE + DEBUG_TOOLBAR_DISPOSAL_FLAG, DEFAULT); |
| 1522 | + DEBUG_COMMANDS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_COMMANDS_FLAG, DEFAULT); |
| 1523 | + DEBUG_CONTEXTS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_CONTEXTS_FLAG, DEFAULT); |
| 1524 | + DEBUG_CONTEXTS_PERFORMANCE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_CONTEXTS_PERFORMANCE_FLAG, DEFAULT); |
| 1525 | + DEBUG_CONTEXTS_VERBOSE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_CONTEXTS_VERBOSE_FLAG, DEFAULT); |
| 1526 | + DEBUG_HANDLERS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_HANDLERS_FLAG, DEFAULT); |
| 1527 | + DEBUG_HANDLERS_PERFORMANCE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_HANDLERS_PERFORMANCE_FLAG, DEFAULT); |
| 1528 | + DEBUG_HANDLERS_VERBOSE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_HANDLERS_VERBOSE_FLAG, DEFAULT); |
| 1529 | + DEBUG_OPERATIONS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_OPERATIONS_FLAG, DEFAULT); |
| 1530 | + DEBUG_OPERATIONS_VERBOSE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_OPERATIONS_VERBOSE_FLAG, DEFAULT); |
| 1531 | + DEBUG_SHOW_ALL_JOBS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_SHOW_ALL_JOBS_FLAG, DEFAULT); |
| 1532 | + DEBUG_STALE_JOBS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_STALE_JOBS_FLAG, DEFAULT); |
| 1533 | + DEBUG_DECLARED_IMAGES = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_DECLARED_IMAGES_FLAG, DEFAULT); |
| 1534 | + DEBUG_CONTRIBUTIONS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_CONTRIBUTIONS_FLAG, DEFAULT); |
| 1535 | + DEBUG_HANDLERS_VERBOSE_COMMAND_ID = options.getOption(PlatformUI.PLUGIN_ID + DEBUG_HANDLERS_VERBOSE_COMMAND_ID_FLAG, ""); //$NON-NLS-1$ |
| 1536 | + EXPERIMENTAL_MENU = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_CONTRIBUTIONS_FLAG, DEFAULT); |
| 1537 | + DEBUG_MPE = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_MPE_FLAG, DEFAULT); |
| 1538 | + DEBUG_WORKING_SETS = options.getBooleanOption(PlatformUI.PLUGIN_ID + DEBUG_WORKING_SETS_FLAG, DEFAULT); |
| 1539 | + if (Policy.DEBUG_SWT_DEBUG_GLOBAL) { |
| 1540 | + Device.DEBUG = true; |
| 1541 | + } |
| 1542 | + } |
| 1543 | + |
| 1544 | + public DebugTrace getTrace() { |
| 1545 | + return trace; |
| 1546 | + } |
1439 | 1547 | } |
0 commit comments