Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug.ui')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/META-INF/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml54
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/ITCFLaunchContext.java24
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchContext.java69
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchShortcut.java132
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java45
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFPropertyTester.java44
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java178
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelSelectionPolicy.java4
9 files changed, 399 insertions, 158 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.tm.tcf.debug.ui/META-INF/MANIFEST.MF
index 218f33382..0249afef6 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/META-INF/MANIFEST.MF
@@ -19,11 +19,12 @@ Require-Bundle: org.eclipse.ui,
com.jcraft.jsch;bundle-version="0.1.37",
org.eclipse.jsch.core;bundle-version="1.1.100",
org.eclipse.jsch.ui;bundle-version="1.1.100"
-Import-Package: org.eclipse.tm.tcf.core;version="0.2.0",
+Import-Package: org.eclipse.core.expressions,
+ org.eclipse.tm.tcf.core;version="0.2.0",
org.eclipse.tm.tcf.protocol;version="0.2.0",
org.eclipse.tm.tcf.services;version="0.2.0",
- org.eclipse.tm.tcf.util;version="0.2.0",
- org.eclipse.tm.tcf.ssl;version="0.2.0"
+ org.eclipse.tm.tcf.ssl;version="0.2.0",
+ org.eclipse.tm.tcf.util;version="0.2.0"
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
index 5393b8e64..dbb5df199 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
@@ -25,16 +25,14 @@
</factory>
</extension>
- <extension
- point="org.eclipse.debug.ui.debugModelPresentations">
+ <extension point="org.eclipse.debug.ui.debugModelPresentations">
<debugModelPresentation
class = "org.eclipse.tm.internal.tcf.debug.ui.model.TCFModelPresentation"
id = "org.eclipse.tm.tcf.debug">
</debugModelPresentation>
</extension>
- <extension
- point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
<launchConfigurationTypeImage
icon="icons/tcf.gif"
configTypeID="org.eclipse.tm.tcf.debug.LaunchConfigurationType"
@@ -42,8 +40,7 @@
</launchConfigurationTypeImage>
</extension>
- <extension
- point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <extension point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
type="org.eclipse.tm.tcf.debug.LaunchConfigurationType"
description="Run or debug a program using Target Communication Framework"
@@ -52,6 +49,51 @@
</launchConfigurationTabGroup>
</extension>
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ namespace="org.eclipse.tm.tcf.launch"
+ properties="isExecutable"
+ type="org.eclipse.core.runtime.IAdaptable"
+ class="org.eclipse.tm.internal.tcf.debug.ui.launch.TCFPropertyTester"
+ id="org.eclipse.tm.tcf.launch.PropertyTester">
+ </propertyTester>
+ </extension>
+
+ <extension point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ label="TCF Application"
+ icon="icons/tcf.gif"
+ helpContextId="org.eclipse.tm.tcf.debug.ui.shortcut_tcf_application"
+ modes="run, debug"
+ class="org.eclipse.tm.internal.tcf.debug.ui.launch.TCFLaunchShortcut"
+ description="Launch an application using Target Communication Framework (TCF)"
+ id="org.eclipse.tm.tcf.debug.ui.TCFShortcut">
+ <description
+ description="Runs an application using Target Communication Framework (TCF)"
+ mode="run">
+ </description>
+ <description
+ description="Debugs an application using Target Communication Framework (TCF)"
+ mode="debug">
+ </description>
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.tm.tcf.launch.isExecutable"/>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ <configurationType
+ id="org.eclipse.tm.tcf.debug.LaunchConfigurationType">
+ </configurationType>
+ </shortcut>
+ </extension>
+
<extension
point="org.eclipse.ui.contexts">
<context
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/ITCFLaunchContext.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/ITCFLaunchContext.java
index 90be235bc..e00ef465f 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/ITCFLaunchContext.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/ITCFLaunchContext.java
@@ -39,11 +39,25 @@ public interface ITCFLaunchContext {
boolean isActive();
/**
- * Check if this context recognizes type of a project.
- * @param project
- * @return true if the project is supported by this context.
+ * Check if this context recognizes type of a selection.
+ * @param selection
+ * @return true if the selection is supported by this context.
+ */
+ boolean isSupportedSelection(Object selection);
+
+ /**
+ * Get selection project.
+ * @param selection
+ * @return selection project or null if selection is not part of a project
+ */
+ IProject getProject(Object selection);
+
+ /**
+ * Get selection file path.
+ * @param selection
+ * @return selection file path or null if selection is not a file
*/
- boolean isSupportedProject(IProject project);
+ IPath getPath(Object selection);
/**
* Set launch configuration attributes to default values best suited for current context.
@@ -71,7 +85,7 @@ public interface ITCFLaunchContext {
/**
* Check if a path represents an executable binary file.
* @param project
- * @param path
+ * @param path - full path to a file in the project
* @return
* @throws CoreException
*/
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchContext.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchContext.java
new file mode 100644
index 000000000..8fbffd059
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchContext.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.internal.tcf.debug.ui.launch;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+import org.osgi.framework.Bundle;
+
+/**
+ * TCF clients can implement ITCFLaunchContext to provide information about
+ * workspace projects to TCF Launch Configuration.
+ *
+ * The information includes default values for launch configuration attributes,
+ * list of executable binary files, etc.
+ *
+ * Since each project type can have its own methods to retrieve relevant information,
+ * there should be implementation of this interface for each project type that support TCF.
+ *
+ * Implementation should be able to examine current IDE state (like active editor input source,
+ * project explorer selection, etc.) and figure out an "active project".
+ */
+public class TCFLaunchContext {
+
+ public static ITCFLaunchContext getLaunchContext(Object selection) {
+ try {
+ IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launch_context");
+ IExtension[] extensions = point.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ try {
+ Bundle bundle = Platform.getBundle(extensions[i].getNamespaceIdentifier());
+ bundle.start();
+ IConfigurationElement[] e = extensions[i].getConfigurationElements();
+ for (int j = 0; j < e.length; j++) {
+ String nm = e[j].getName();
+ if (nm.equals("class")) { //$NON-NLS-1$
+ Class<?> c = bundle.loadClass(e[j].getAttribute("name")); //$NON-NLS-1$
+ ITCFLaunchContext launch_context = (ITCFLaunchContext)c.newInstance();
+ if (selection != null) {
+ if (launch_context.isSupportedSelection(selection)) return launch_context;
+ }
+ else {
+ if (launch_context.isActive()) return launch_context;
+ }
+ }
+ }
+ }
+ catch (Throwable x) {
+ Activator.log("Cannot access launch context extension points", x);
+ }
+ }
+ }
+ catch (Exception x) {
+ Activator.log("Cannot access launch context extension points", x);
+ }
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchShortcut.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchShortcut.java
new file mode 100644
index 000000000..3783db2b5
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFLaunchShortcut.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.internal.tcf.debug.ui.launch;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFLaunchDelegate;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+/**
+ * This class implements extension point that provides support for selection sensitive launching using TCF.
+ * Extensions register a shortcut which appears in the run and/or debug cascade menus to launch
+ * the workbench selection or active editor.
+ */
+public class TCFLaunchShortcut implements ILaunchShortcut {
+
+ private static final String LAUNCH_CONFIGURATION_TYPE_ID = "org.eclipse.tm.tcf.debug.LaunchConfigurationType"; //$NON-NLS-1$
+
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ Object obj = ss.getFirstElement();
+ ITCFLaunchContext context = TCFLaunchContext.getLaunchContext(obj);
+ IProject project = context.getProject(obj);
+ IPath path = context.getPath(obj);
+ ILaunchConfiguration config = null;
+ List<ILaunchConfiguration> list = searchConfigurations(project, path);
+ if (list != null) {
+ int count = list.size();
+ if (count == 0) {
+ config = createConfiguration(project, path);
+ }
+ else if (count == 1) {
+ config = list.get(0);
+ }
+ else {
+ config = chooseConfiguration(list);
+ }
+ if (config != null) DebugUITools.launch(config, mode);
+ }
+ }
+ }
+
+ public void launch(IEditorPart editor, String mode) {
+ }
+
+ private List<ILaunchConfiguration> searchConfigurations(IProject project, IPath path) {
+ try {
+ List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID);
+ ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
+ for (ILaunchConfiguration config : configs) {
+ if (config.getAttribute(TCFLaunchDelegate.ATTR_LOCAL_PROGRAM_FILE, "").equals(path.toOSString()) && //$NON-NLS-1$
+ config.getAttribute(TCFLaunchDelegate.ATTR_PROJECT_NAME, "").equals(project.getName())) { //$NON-NLS-1$
+ list.add(config);
+ }
+ }
+ return list;
+ }
+ catch (CoreException x) {
+ MessageDialog.openError(getShell(), "Error searching available launch configurations", x.getStatus().getMessage());
+ return null;
+ }
+ }
+
+ private ILaunchConfiguration chooseConfiguration(List<ILaunchConfiguration> list) {
+ IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+ ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setElements(list.toArray());
+ dialog.setTitle("TCF Launch Configuration");
+ dialog.setMessage("&Select existing configuration:");
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ labelProvider.dispose();
+ if (result == Window.OK) return (ILaunchConfiguration) dialog.getFirstResult();
+ return null;
+ }
+
+ private ILaunchConfiguration createConfiguration(IProject project, IPath path) {
+ ILaunchConfiguration config = null;
+ ILaunchConfigurationWorkingCopy wc = null;
+ try {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID);
+ wc = type.newInstance(null, manager.generateUniqueLaunchConfigurationNameFrom("TCF Local Host " + path.lastSegment()));
+ wc.setAttribute(TCFLaunchDelegate.ATTR_LOCAL_PROGRAM_FILE, path.toOSString());
+ wc.setAttribute(TCFLaunchDelegate.ATTR_PROJECT_NAME, project.getName());
+ // wc.setMappedResources(new IResource[] { });
+ config = wc.doSave();
+ }
+ catch (CoreException x) {
+ MessageDialog.openError(getShell(), "Cannot create launch configuration", x.getStatus().getMessage());
+ }
+ return config;
+ }
+
+ private Shell getShell() {
+ Shell shell = null;
+ IWorkbenchWindow window = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) shell = window.getShell();
+ return shell;
+ }
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
index 713e23fea..1aaa1bbc9 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFMainTab.java
@@ -15,12 +15,8 @@ import java.io.File;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@@ -46,7 +42,6 @@ import org.eclipse.tm.internal.tcf.debug.launch.TCFLaunchDelegate;
import org.eclipse.tm.internal.tcf.debug.ui.Activator;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.osgi.framework.Bundle;
public class TCFMainTab extends AbstractLaunchConfigurationTab {
@@ -213,40 +208,6 @@ public class TCFMainTab extends AbstractLaunchConfigurationTab {
working_dir_text.setEnabled(!default_dir_button.getSelection());
}
- private ITCFLaunchContext getLaunchContext(IProject project) {
- try {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "launch_context");
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- try {
- Bundle bundle = Platform.getBundle(extensions[i].getNamespaceIdentifier());
- bundle.start();
- IConfigurationElement[] e = extensions[i].getConfigurationElements();
- for (int j = 0; j < e.length; j++) {
- String nm = e[j].getName();
- if (nm.equals("class")) { //$NON-NLS-1$
- Class<?> c = bundle.loadClass(e[j].getAttribute("name")); //$NON-NLS-1$
- ITCFLaunchContext launch_context = (ITCFLaunchContext)c.newInstance();
- if (project != null) {
- if (launch_context.isSupportedProject(project)) return launch_context;
- }
- else {
- if (launch_context.isActive()) return launch_context;
- }
- }
- }
- }
- catch (Throwable x) {
- Activator.log("Cannot access launch context extension points", x);
- }
- }
- }
- catch (Exception x) {
- Activator.log("Cannot access launch context extension points", x);
- }
- return null;
- }
-
private void createTerminalOption(Composite parent, int colSpan) {
Composite terminal_comp = new Composite(parent, SWT.NONE);
GridLayout terminal_layout = new GridLayout();
@@ -316,7 +277,7 @@ public class TCFMainTab extends AbstractLaunchConfigurationTab {
"Enter project before searching for program");
return;
}
- ITCFLaunchContext launch_context = getLaunchContext(project);
+ ITCFLaunchContext launch_context = TCFLaunchContext.getLaunchContext(project);
if (launch_context == null) return;
String path = launch_context.chooseBinary(getShell(), project);
if (path != null) local_program_text.setText(path);
@@ -449,7 +410,7 @@ public class TCFMainTab extends AbstractLaunchConfigurationTab {
}
if (project != null) {
try {
- ITCFLaunchContext launch_context = getLaunchContext(project);
+ ITCFLaunchContext launch_context = TCFLaunchContext.getLaunchContext(project);
if (launch_context != null && !launch_context.isBinary(project, program_path)) {
setErrorMessage("Program is not a recongnized executable");
return false;
@@ -469,7 +430,7 @@ public class TCFMainTab extends AbstractLaunchConfigurationTab {
config.setAttribute(TCFLaunchDelegate.ATTR_PROJECT_NAME, "");
config.setAttribute(TCFLaunchDelegate.ATTR_USE_TERMINAL, true);
config.setAttribute(TCFLaunchDelegate.ATTR_WORKING_DIRECTORY, (String)null);
- ITCFLaunchContext launch_context = getLaunchContext(null);
+ ITCFLaunchContext launch_context = TCFLaunchContext.getLaunchContext(null);
if (launch_context != null) launch_context.setDefaults(getLaunchConfigurationDialog(), config);
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFPropertyTester.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFPropertyTester.java
new file mode 100644
index 000000000..a2778b0a5
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFPropertyTester.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.internal.tcf.debug.ui.launch;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+
+public class TCFPropertyTester extends PropertyTester {
+
+ public boolean test(Object receiver, String property, Object[] args, Object expected_value) {
+ Object value = null;
+ try {
+ if (receiver instanceof IAdaptable) {
+ IAdaptable selection = (IAdaptable)receiver;
+ ITCFLaunchContext context = TCFLaunchContext.getLaunchContext(selection);
+ if (context != null) {
+ if (property.equals("isExecutable")) {
+ IProject project = context.getProject(selection);
+ IPath path = context.getPath(selection);
+ if (project != null && path != null) {
+ value = context.isBinary(project, path);
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable x) {
+ Activator.log(x);
+ }
+ if (expected_value != null) return expected_value.equals(value);
+ return (value instanceof Boolean) && ((Boolean)value).booleanValue();
+ }
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
index 27b142554..7bf3cd845 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
@@ -45,8 +45,6 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactor
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
-import org.eclipse.debug.ui.AbstractDebugView;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
import org.eclipse.debug.ui.ISourcePresentation;
@@ -765,39 +763,30 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
if (initial_selection && debug_view_selection_set) return;
debug_view_selection_set = true;
final int cnt = ++debug_view_selection_cnt;
- display.asyncExec(new Runnable() {
+ Protocol.invokeLater(200, new Runnable() {
public void run() {
+ TCFNode node = getNode(node_id);
+ if (node == null) return;
+ if (node.disposed) return;
+ if (!node.validateNode(this)) return;
if (cnt != debug_view_selection_cnt) return;
- final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window == null) return;
- final IDebugView view = (IDebugView)window.getActivePage().findView(IDebugUIConstants.ID_DEBUG_VIEW);
- if (view == null) return;
- if (!((AbstractDebugView)view).isAvailable()) return;
- Protocol.invokeLater(100, new Runnable() {
- public void run() {
- TCFNode node = getNode(node_id);
- if (node == null) return;
- if (node.disposed) return;
- if (!node.validateNode(this)) return;
- if (node instanceof TCFNodeExecContext) {
- TCFNode frame = ((TCFNodeExecContext)node).getTopFrame();
- if (frame != null && !frame.disposed) {
- if (!frame.validateNode(this)) return;
- node = frame;
- }
- }
- final TreeModelViewer viewer = (TreeModelViewer)view.getViewer();
- for (TCFModelProxy proxy : model_proxies.values()) {
- if (proxy.getProxyViewer() == viewer) {
- proxy.fireModelChanged();
- proxy.addDelta(node, IModelDelta.REVEAL);
- proxy.fireModelChanged();
- proxy.addDelta(node, IModelDelta.SELECT);
- proxy.fireModelChanged();
- }
- }
+ if (node instanceof TCFNodeExecContext) {
+ if (!((TCFNodeExecContext)node).isSuspended()) return;
+ TCFNode frame = ((TCFNodeExecContext)node).getTopFrame();
+ if (frame != null && !frame.disposed) {
+ if (!frame.validateNode(this)) return;
+ node = frame;
}
- });
+ }
+ for (TCFModelProxy proxy : model_proxies.values()) {
+ if (proxy.getPresentationContext().getId().equals(IDebugUIConstants.ID_DEBUG_VIEW)) {
+ proxy.fireModelChanged();
+ proxy.addDelta(node, IModelDelta.REVEAL);
+ proxy.fireModelChanged();
+ proxy.addDelta(node, IModelDelta.SELECT);
+ proxy.fireModelChanged();
+ }
+ }
}
});
}
@@ -807,85 +796,74 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
* The method is part of ISourceDisplay interface.
* The method is normally called from SourceLookupService.
*/
- public void displaySource(Object element, final IWorkbenchPage page, boolean forceSourceLookup) {
+ public void displaySource(final Object element, final IWorkbenchPage page, boolean forceSourceLookup) {
final int cnt = ++display_source_cnt;
- if (element instanceof TCFNodeExecContext) {
- final TCFNodeExecContext node = (TCFNodeExecContext)element;
- element = new TCFTask<TCFNode>() {
- public void run() {
- if (node.disposed) {
- done(null);
- }
- else {
- if (!node.validateNode(this)) return;
- if (!node.isSuspended()) {
- done(null);
+ Protocol.invokeLater(new Runnable() {
+ public void run() {
+ if (cnt != display_source_cnt) return;
+ TCFNodeStackFrame stack_frame = null;
+ IChannel channel = getLaunch().getChannel();
+ if (!disposed && channel.getState() == IChannel.STATE_OPEN) {
+ if (element instanceof TCFNodeExecContext) {
+ TCFNodeExecContext node = (TCFNodeExecContext)element;
+ if (!node.disposed) {
+ if (!node.validateNode(this)) return;
+ if (node.isSuspended()) stack_frame = node.getTopFrame();
}
- else {
- TCFNodeStackFrame f = node.getTopFrame();
- done(f == null ? node : f);
+ }
+ else if (element instanceof TCFNodeStackFrame) {
+ TCFNodeStackFrame node = (TCFNodeStackFrame)element;
+ if (!node.disposed) {
+ stack_frame = (TCFNodeStackFrame)element;
}
}
}
- }.getE();
- }
- if (element instanceof TCFNodeStackFrame) {
- final TCFNodeStackFrame stack_frame = (TCFNodeStackFrame)element;
- Protocol.invokeLater(new Runnable() {
- public void run() {
- if (cnt != display_source_cnt) return;
- IChannel channel = getLaunch().getChannel();
- if (!disposed && channel.getState() == IChannel.STATE_OPEN && !stack_frame.disposed) {
- TCFDataCache<TCFSourceRef> line_info = stack_frame.getLineInfo();
- if (!line_info.validate()) {
- line_info.wait(this);
+ if (stack_frame != null) {
+ TCFDataCache<TCFSourceRef> line_info = stack_frame.getLineInfo();
+ if (!line_info.validate()) {
+ line_info.wait(this);
+ return;
+ }
+ String editor_id = null;
+ IEditorInput editor_input = null;
+ Throwable error = line_info.getError();
+ TCFSourceRef src_ref = line_info.getData();
+ int line = 0;
+ if (error == null && src_ref != null) error = src_ref.error;
+ if (error != null) Activator.log("Error retrieving source mapping for a stack frame", error);
+ if (src_ref != null && src_ref.area != null) {
+ ISourceLocator locator = getLaunch().getSourceLocator();
+ Object source_element = null;
+ if (locator instanceof ISourceLookupDirector) {
+ source_element = ((ISourceLookupDirector)locator).getSourceElement(src_ref.area);
+ }
+ if (source_element == null) {
+ ILaunchConfiguration cfg = launch.getLaunchConfiguration();
+ editor_input = editor_not_found.get(cfg);
+ if (editor_input == null) {
+ editor_not_found.put(cfg, editor_input = new CommonSourceNotFoundEditorInput(cfg));
+ }
+ editor_id = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
}
else {
- String editor_id = null;
- IEditorInput editor_input = null;
- Throwable error = line_info.getError();
- TCFSourceRef src_ref = line_info.getData();
- int line = 0;
- if (error == null && src_ref != null) error = src_ref.error;
- if (error != null) Activator.log("Error retrieving source mapping for a stack frame", error);
- if (src_ref != null && src_ref.area != null) {
- ISourceLocator locator = getLaunch().getSourceLocator();
- Object source_element = null;
- if (locator instanceof ISourceLookupDirector) {
- source_element = ((ISourceLookupDirector)locator).getSourceElement(src_ref.area);
- }
- if (source_element == null) {
- ILaunchConfiguration cfg = launch.getLaunchConfiguration();
- editor_input = editor_not_found.get(cfg);
- if (editor_input == null) {
- editor_not_found.put(cfg, editor_input = new CommonSourceNotFoundEditorInput(cfg));
- }
- editor_id = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR;
- }
- else {
- ISourcePresentation presentation = TCFModelPresentation.getDefault();
- if (presentation != null) {
- editor_input = presentation.getEditorInput(source_element);
- }
- if (editor_input != null) {
- editor_id = presentation.getEditorId(editor_input, source_element);
- }
- line = src_ref.area.start_line;
- }
+ ISourcePresentation presentation = TCFModelPresentation.getDefault();
+ if (presentation != null) {
+ editor_input = presentation.getEditorInput(source_element);
}
- displaySource(cnt, editor_id, editor_input, page,
- stack_frame.parent.id, stack_frame.getFrameNo() == 0, line);
+ if (editor_input != null) {
+ editor_id = presentation.getEditorId(editor_input, source_element);
+ }
+ line = src_ref.area.start_line;
}
}
- else {
- displaySource(cnt, null, null, page, null, false, 0);
- }
+ displaySource(cnt, editor_id, editor_input, page,
+ stack_frame.parent.id, stack_frame.getFrameNo() == 0, line);
}
- });
- }
- else {
- displaySource(cnt, null, null, page, null, false, 0);
- }
+ else {
+ displaySource(cnt, null, null, page, null, false, 0);
+ }
+ }
+ });
}
private void displaySource(final int cnt,
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelSelectionPolicy.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelSelectionPolicy.java
index 488a33cff..883b869e0 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelSelectionPolicy.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelSelectionPolicy.java
@@ -54,13 +54,13 @@ class TCFModelSelectionPolicy implements IModelSelectionPolicy {
if (n instanceof TCFNodeExecContext) {
if (!n.validateNode(this)) return;
if (((TCFNodeExecContext)n).isSuspended()) {
- done(Boolean.TRUE);
+ done(true);
return;
}
}
n = n.parent;
}
- done(Boolean.FALSE);
+ done(false);
}
}.getE();
}

Back to the top