From 37a044c9d72df50775bcb186e00cf3c2bb5c384c Mon Sep 17 00:00:00 2001
From: Eugene Tarassov
Date: Wed, 29 Apr 2015 19:36:59 -0700
Subject: Bug 465756 - TCFModelManager does not register its workbench listener
---
plugins/org.eclipse.tcf.debug.ui/plugin.xml | 2 --
.../internal/debug/ui/model/TCFModelManager.java | 6 ++++--
.../internal/debug/launch/TCFLaunchDelegate.java | 22 ++++++++++++++++++++++
3 files changed, 26 insertions(+), 4 deletions(-)
(limited to 'plugins')
diff --git a/plugins/org.eclipse.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tcf.debug.ui/plugin.xml
index 10ce7735f..705d94a37 100644
--- a/plugins/org.eclipse.tcf.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.tcf.debug.ui/plugin.xml
@@ -18,8 +18,6 @@
-
-
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModelManager.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModelManager.java
index 17b4f846f..1df6f12b6 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModelManager.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModelManager.java
@@ -156,7 +156,8 @@ public class TCFModelManager {
assert Protocol.isDispatchThread();
try {
PlatformUI.getWorkbench().addWorkbenchListener(workbench_listener);
- } catch (IllegalStateException e) {
+ }
+ catch (IllegalStateException e) {
// In headless environments the plug-in load can be still triggered.
// Should not trigger an "Unhandled exception in TCF event dispatch thread"
}
@@ -168,7 +169,8 @@ public class TCFModelManager {
assert Protocol.isDispatchThread();
try {
PlatformUI.getWorkbench().removeWorkbenchListener(workbench_listener);
- } catch (IllegalStateException e) {
+ }
+ catch (IllegalStateException e) {
// In headless environments the plug-in load can be still triggered.
// Should not trigger an "Unhandled exception in TCF event dispatch thread"
}
diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
index fbfec6d34..7c062f549 100644
--- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
+++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/launch/TCFLaunchDelegate.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -40,6 +41,7 @@ import org.eclipse.tcf.services.IMemoryMap;
import org.eclipse.tcf.services.IPathMap;
import org.eclipse.tcf.util.TCFPathMapRule;
import org.eclipse.tcf.util.TCFTask;
+import org.osgi.framework.Bundle;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -84,6 +86,9 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
FILES_SET_PC = "SetPC",
FILES_ENABLE_OSA = "EnableOSA";
+ private static Boolean is_headless;
+ private static boolean ui_activation_done;
+
public static class PathMapRule extends TCFPathMapRule {
public PathMapRule(Map props) {
@@ -334,6 +339,23 @@ public class TCFLaunchDelegate extends LaunchConfigurationDelegate {
return new TCFTask() {
int cnt;
public void run() {
+ if (is_headless == null) {
+ Bundle b = Platform.getBundle("org.eclipse.ui.workbench");
+ is_headless = new Boolean(b == null || b.getState() != Bundle.ACTIVE);
+ }
+
+ if (!is_headless && !ui_activation_done) {
+ /* Make sure UI bundle is activated and is listening for launch events */
+ try {
+ Bundle bundle = Platform.getBundle("org.eclipse.tcf.debug.ui");
+ bundle.start(Bundle.START_TRANSIENT);
+ }
+ catch (Throwable x) {
+ Protocol.log("TCF debugger UI startup error", x); //$NON-NLS-1$
+ }
+ ui_activation_done = true;
+ }
+
// Need to delay at least one dispatch cycle to work around
// a possible racing between thread that calls getLaunch() and
// the process of activation of other TCF plug-ins.
--
cgit v1.2.3