Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2009-01-08 16:08:05 -0500
committerPawel Piech2009-01-08 16:08:05 -0500
commit5b471873662a87a77cfd854c98fca9c9948aa878 (patch)
tree3da8dcf3820bf3c2d4ebd17e4e8f3043e9773676 /dsf/org.eclipse.cdt.examples.dsf.pda.ui
parent47093064424981f85335cfdaf25368c54cd840f8 (diff)
parentc1e6da229b8ffcea160498f034bfa6bc8ff6f230 (diff)
downloadorg.eclipse.cdt-5b471873662a87a77cfd854c98fca9c9948aa878.tar.gz
org.eclipse.cdt-5b471873662a87a77cfd854c98fca9c9948aa878.tar.xz
org.eclipse.cdt-5b471873662a87a77cfd854c98fca9c9948aa878.zip
Migrated DSF and DSF-GDB to the CDT project.
Diffstat (limited to 'dsf/org.eclipse.cdt.examples.dsf.pda.ui')
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/.classpath7
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore1
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/.project28
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/.settings/org.eclipse.jdt.core.prefs65
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/META-INF/MANIFEST.MF24
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/about.html28
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/build.properties22
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/icons/full/obj16/pda.gifbin0 -> 182 bytes
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml106
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java266
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java155
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/actions/PDATerminateCommand.java130
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDABreakpointAdapter.java225
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDAEditorAdapterFactory.java52
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java50
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistProcessor.java103
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistant.java43
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditor.java49
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditorMessages.properties15
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAScanner.java93
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDASourceViewerConfiguration.java64
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PopFrameActionDelegate.java90
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/TextHover.java83
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/WordFinder.java80
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDAMainTab.java190
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDATabGroup.java44
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAVMAdapter.java54
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDALaunchVMProvider.java71
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java163
-rw-r--r--dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java187
30 files changed, 2488 insertions, 0 deletions
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.classpath b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.classpath
new file mode 100644
index 00000000000..304e86186aa
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore
new file mode 100644
index 00000000000..ba077a4031a
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.project b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.project
new file mode 100644
index 00000000000..2d088321537
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.examples.dsf.pda.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.settings/org.eclipse.jdt.core.prefs b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..d777d691415
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,65 @@
+#Tue Jun 24 11:03:46 PDT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/META-INF/MANIFEST.MF b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..a453d5834ef
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: PDA Example Device Debugging UI Plug-in
+Bundle-SymbolicName: org.eclipse.cdt.examples.dsf.pda.ui;singleton:=true
+Bundle-Version: 2.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.ui,
+ org.eclipse.debug.ui,
+ org.eclipse.jface.text,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.ui.ide,
+ org.eclipse.cdt.examples.dsf.pda,
+ org.eclipse.cdt.dsf,
+ org.eclipse.cdt.dsf.ui
+Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.cdt.examples.dsf.pda.ui,
+ org.eclipse.cdt.examples.dsf.pda.ui.breakpoints,
+ org.eclipse.cdt.examples.dsf.pda.ui.editor,
+ org.eclipse.cdt.examples.dsf.pda.ui.launcher
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/about.html b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/about.html
new file mode 100644
index 00000000000..c1cb2e12f40
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>May 14, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/build.properties b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/build.properties
new file mode 100644
index 00000000000..e5e3b48cf3f
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/build.properties
@@ -0,0 +1,22 @@
+###############################################################################
+# Copyright (c) 2006, 2008 Wind River Systems 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
+###############################################################################
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ bin/,\
+ about.html,\
+ META-INF/,\
+ .,\
+ icons/
+src.includes = src/,\
+ about.html,\
+ icons/,\
+ plugin.xml
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/icons/full/obj16/pda.gif b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/icons/full/obj16/pda.gif
new file mode 100644
index 00000000000..9a6adbfc87e
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/icons/full/obj16/pda.gif
Binary files differ
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml
new file mode 100644
index 00000000000..da6e4f6b6ee
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/plugin.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.eclipse.cdt.examples.dsf.pda.ui.launcher.PDATabGroup"
+ description="Specify and launch a PDA(DSF) program"
+ id="org.eclipse.cdt.examples.dsf.pda.tabGroup"
+ type="org.eclipse.cdt.examples.dsf.pda.launchType"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icons/full/obj16/pda.gif"
+ configTypeID="org.eclipse.cdt.examples.dsf.pda.launchType"
+ id="org.eclipse.cdt.examples.dsf.pda.typeImage"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ class="org.eclipse.cdt.examples.dsf.pda.ui.PDAAdapterFactory"
+ adaptableType="org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch">
+ <adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider"/>
+ <adapter type="org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory"/>
+ </factory>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ filenames="*.pda"
+ class="org.eclipse.cdt.examples.dsf.pda.ui.editor.PDAEditor"
+ icon="icons/full/obj16/pda.gif"
+ default="true"
+ name="PDA(DSF) Editor"
+ id="org.eclipse.cdt.examples.dsf.pda.editor"
+ extensions="pda"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editorActions">
+ <editorContribution
+ targetID="org.eclipse.cdt.examples.dsf.pda.editor"
+ id="org.eclipse.cdt.examples.dsf.pda.rulerActions">
+ <action
+ label="Not Used"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
+ style="push"
+ actionID="RulerDoubleClick"
+ id="org.eclipse.cdt.examples.dsf.pda.doubleClickBreakpointAction"/>
+ </editorContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.contexts">
+ <context
+ parentId="org.eclipse.debug.ui.debugging"
+ description="Debugging PDA(DSF) Programs"
+ name="Debugging PDA(DSF) Programs"
+ id="org.eclipse.cdt.examples.dsf.pda.debugging"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.debugModelContextBindings">
+ <modelContextBinding
+ contextId="org.eclipse.cdt.examples.dsf.pda.debugging"
+ debugModelId="org.eclipse.cdt.examples.dsf.pda.debugModel"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.contextViewBindings">
+ <contextViewBinding
+ contextId="org.eclipse.cdt.examples.dsf.pda.debugging"
+ viewId="org.eclipse.cdt.examples.dsf.pda.dataStackView"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ targetID="org.eclipse.cdt.examples.dsf.pda.editor.rulerMenu"
+ id="org.eclipse.cdt.examples.dsf.pda.editor.rulerActions">
+ <action
+ label="Toggle Breakpoint"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
+ menubarPath="debug"
+ id="org.eclipse.cdt.examples.dsf.pda.editor.ruler.toggleBreakpointAction"/>
+ </viewerContribution>
+ <viewerContribution
+ targetID="org.eclipse.cdt.examples.dsf.pda.editor.contextMenu"
+ id="org.eclipse.cdt.examples.dsf.pda.editor.menuActions">
+ <action
+ label="Run to Line"
+ definitionId="org.eclipse.debug.ui.commands.RunToLine"
+ class="org.eclipse.debug.ui.actions.RunToLineActionDelegate"
+ menubarPath="additions"
+ id="org.eclipse.cdt.examples.dsf.pda.editor.context.runToLineAction"/>
+ </viewerContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ class="org.eclipse.cdt.examples.dsf.pda.ui.breakpoints.PDAEditorAdapterFactory"
+ adaptableType="org.eclipse.cdt.examples.dsf.pda.ui.editor.PDAEditor">
+ <adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
+ </factory>
+ </extension> -->
+</plugin>
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java
new file mode 100644
index 00000000000..ce756d66613
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAAdapterFactory.java
@@ -0,0 +1,266 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems 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.cdt.examples.dsf.pda.ui;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.cdt.dsf.concurrent.Immutable;
+import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
+import org.eclipse.cdt.dsf.debug.ui.actions.DsfResumeCommand;
+import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepIntoCommand;
+import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepOverCommand;
+import org.eclipse.cdt.dsf.debug.ui.actions.DsfStepReturnCommand;
+import org.eclipse.cdt.dsf.debug.ui.actions.DsfSuspendCommand;
+import org.eclipse.cdt.dsf.debug.ui.sourcelookup.DsfSourceDisplayAdapter;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.examples.dsf.pda.PDAPlugin;
+import org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch;
+import org.eclipse.cdt.examples.dsf.pda.ui.actions.PDATerminateCommand;
+import org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.PDAVMAdapter;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.core.commands.IResumeHandler;
+import org.eclipse.debug.core.commands.IStepIntoHandler;
+import org.eclipse.debug.core.commands.IStepOverHandler;
+import org.eclipse.debug.core.commands.IStepReturnHandler;
+import org.eclipse.debug.core.commands.ISuspendHandler;
+import org.eclipse.debug.core.commands.ITerminateHandler;
+import org.eclipse.debug.core.model.IDebugModelProvider;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
+import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
+
+/**
+ * The adapter factory is the central point of control of view model and other
+ * UI adapters of a DSF-based debugger. As new launches are created and
+ * old ones removed, this factory manages the life cycle of the associated
+ * UI adapters.
+ * <p>
+ * As a platform adapter factory, this factory only provides adapters for
+ * the launch object. Adapters for all other objects in the DSF model hierarchy
+ * are registered with the DSF session.
+ * </p>
+ */
+@ThreadSafe
+@SuppressWarnings({"restriction"})
+public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2
+{
+ /**
+ * Contains the set of adapters that are created for each launch instance.
+ */
+ @Immutable
+ private static class LaunchAdapterSet {
+ // View Model adapter
+ final PDAVMAdapter fViewModelAdapter;
+
+ // Source lookup and positioning adapter
+ final DsfSourceDisplayAdapter fSourceDisplayAdapter;
+
+ // Command adapters
+ final DsfStepIntoCommand fStepIntoCommand;
+ final DsfStepOverCommand fStepOverCommand;
+ final DsfStepReturnCommand fStepReturnCommand;
+ final DsfSuspendCommand fSuspendCommand;
+ final DsfResumeCommand fResumeCommand;
+ final PDATerminateCommand fTerminateCommand;
+
+ // Adapters for integration with other UI actions
+ final IDebugModelProvider fDebugModelProvider;
+ final PDALaunch fLaunch;
+
+ final SteppingController fSteppingController;
+
+ private IModelSelectionPolicyFactory fModelSelectionPolicyFactory;
+
+ LaunchAdapterSet(PDALaunch launch) {
+ // Initialize launch and session.
+ fLaunch = launch;
+ DsfSession session = launch.getSession();
+
+ // register stepping controller
+ fSteppingController = new SteppingController(session);
+ session.registerModelAdapter(SteppingController.class, fSteppingController);
+
+ // Initialize VM
+ fViewModelAdapter = new PDAVMAdapter(session, fSteppingController);
+
+ // Initialize source lookup
+ fSourceDisplayAdapter = new DsfSourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator(), fSteppingController);
+ session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter);
+
+ // Default selection policy
+ fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
+ session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
+
+ // Initialize retargetable command handler.
+ fStepIntoCommand = new DsfStepIntoCommand(session, null);
+ fStepOverCommand = new DsfStepOverCommand(session, null);
+ fStepReturnCommand = new DsfStepReturnCommand(session);
+ fSuspendCommand = new DsfSuspendCommand(session);
+ fResumeCommand = new DsfResumeCommand(session);
+ fTerminateCommand = new PDATerminateCommand(session);
+ session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
+ session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand);
+ session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand);
+ session.registerModelAdapter(ISuspendHandler.class, fSuspendCommand);
+ session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
+ session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
+
+ // Initialize debug model provider
+ fDebugModelProvider = new IDebugModelProvider() {
+ public String[] getModelIdentifiers() {
+ return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL };
+ }
+ };
+ session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider);
+
+ // Register the launch as an adapter This ensures that the launch,
+ // and debug model ID will be associated with all DMContexts from this
+ // session.
+ session.registerModelAdapter(ILaunch.class, fLaunch);
+ }
+
+ void dispose() {
+ DsfSession session = fLaunch.getSession();
+
+ fViewModelAdapter.dispose();
+
+ session.unregisterModelAdapter(ISourceDisplay.class);
+ if (fSourceDisplayAdapter != null) fSourceDisplayAdapter.dispose();
+
+ session.unregisterModelAdapter(SteppingController.class);
+ fSteppingController.dispose();
+
+ session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
+
+ session.unregisterModelAdapter(IStepIntoHandler.class);
+ session.unregisterModelAdapter(IStepOverHandler.class);
+ session.unregisterModelAdapter(IStepReturnHandler.class);
+ session.unregisterModelAdapter(ISuspendHandler.class);
+ session.unregisterModelAdapter(IResumeHandler.class);
+ session.unregisterModelAdapter(ITerminateHandler.class);
+ fStepIntoCommand.dispose();
+ fStepOverCommand.dispose();
+ fStepReturnCommand.dispose();
+ fSuspendCommand.dispose();
+ fResumeCommand.dispose();
+ fTerminateCommand.dispose();
+ }
+ }
+
+ /**
+ * Active adapter sets. They are accessed using the launch instance
+ * which owns the debug services session.
+ */
+ private static Map<PDALaunch, LaunchAdapterSet> fgLaunchAdapterSets =
+ Collections.synchronizedMap(new HashMap<PDALaunch, LaunchAdapterSet>());
+
+ /**
+ * Map of launches for which adapter sets have already been disposed.
+ * This map (used as a set) is maintained in order to avoid re-creating an
+ * adapter set after the launch was removed from the launch manager, but
+ * while the launch is still being held by other classes which may
+ * request its adapters. A weak map is used to avoid leaking
+ * memory once the launches are no longer referenced.
+ * <p>
+ * Access to this map is synchronized using the fgLaunchAdapterSets
+ * instance.
+ * </p>
+ */
+ private static Map<ILaunch, Object> fgDisposedLaunchAdapterSets =
+ new WeakHashMap<ILaunch, Object>();
+
+ static void disposeAdapterSet(ILaunch launch) {
+ synchronized(fgLaunchAdapterSets) {
+ if ( fgLaunchAdapterSets.containsKey(launch) ) {
+ fgLaunchAdapterSets.remove(launch).dispose();
+ fgDisposedLaunchAdapterSets.put(launch, null);
+ }
+ }
+ }
+
+ public PDAAdapterFactory() {
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+ }
+
+ // This IAdapterFactory method returns adapters for the PDA launch object only.
+ @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (!(adaptableObject instanceof PDALaunch)) return null;
+
+ PDALaunch launch = (PDALaunch)adaptableObject;
+
+ // Check for valid session.
+ // Note: even if the session is no longer active, the adapter set
+ // should still be returned. This is because the view model may still
+ // need to show elements representing a terminated process/thread/etc.
+ DsfSession session = launch.getSession();
+ if (session == null) return null;
+
+ // Find the correct set of adapters based on the launch. If not found
+ // it means that we have a new launch, and we have to create a
+ // new set of adapters.
+ LaunchAdapterSet adapterSet;
+ synchronized(fgLaunchAdapterSets) {
+ // The adapter set for the given launch was already disposed.
+ // Return a null adapter.
+ if (fgDisposedLaunchAdapterSets.containsKey(launch)) {
+ return null;
+ }
+ adapterSet = fgLaunchAdapterSets.get(launch);
+ if (adapterSet == null) {
+ adapterSet = new LaunchAdapterSet(launch);
+ fgLaunchAdapterSets.put(launch, adapterSet);
+ }
+ }
+
+ // Returns the adapter type for the launch object.
+ if (adapterType.equals(IElementContentProvider.class)) return adapterSet.fViewModelAdapter;
+ else if (adapterType.equals(IModelProxyFactory.class)) return adapterSet.fViewModelAdapter;
+ else return null;
+ }
+
+ @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
+ public Class[] getAdapterList() {
+ return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class };
+ }
+
+ public void launchesRemoved(ILaunch[] launches) {
+ // Dispose the set of adapters for a launch only after the launch is
+ // removed from the view. If the launch is terminated, the adapters
+ // are still needed to populate the contents of the view.
+ for (ILaunch launch : launches) {
+ if (launch instanceof PDALaunch) {
+ disposeAdapterSet(launch);
+ }
+ }
+ }
+
+ public void launchesTerminated(ILaunch[] launches) {
+ }
+
+ public void launchesAdded(ILaunch[] launches) {
+ }
+
+ public void launchesChanged(ILaunch[] launches) {
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java
new file mode 100644
index 00000000000..e45c6727647
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/PDAUIPlugin.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.examples.dsf.pda.launch.PDALaunch;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.internal.util.BundleUtility;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class PDAUIPlugin extends AbstractUIPlugin {
+
+ public static String PLUGIN_ID = "org.eclipse.cdt.examples.dsf.pda.ui ";
+
+ //The shared instance.
+ private static PDAUIPlugin plugin;
+
+ private static BundleContext fContext;
+
+ private final static String ICONS_PATH = "icons/full/";//$NON-NLS-1$
+ private final static String PATH_OBJECT = ICONS_PATH + "obj16/"; //Model object icons //$NON-NLS-1$
+
+ /**
+ * PDA program image
+ */
+ public final static String IMG_OBJ_PDA = "IMB_OBJ_PDA";
+
+ /**
+ * Keyword color
+ */
+ public final static RGB KEYWORD = new RGB(0,0,255);
+ public final static RGB LABEL = new RGB(128, 128, 0);
+
+ /**
+ * Managed colors
+ */
+ private Map<RGB, Color> fColors = new HashMap<RGB, Color>();
+
+ /**
+ * The constructor.
+ */
+ public PDAUIPlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ fContext = context;
+ super.start(context);
+// Toggles single threaded adapter example
+// IAdapterManager adapterManager = Platform.getAdapterManager();
+// IAdapterFactory factory = new AdapterFactory();
+// adapterManager.registerAdapters(factory, PDADebugTarget.class);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ disposeAdapterSets();
+ super.stop(context);
+ plugin = null;
+ fContext = null;
+ for (Map.Entry<RGB, Color> entry : fColors.entrySet()) {
+ entry.getValue().dispose();
+ }
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static PDAUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static BundleContext getBundleContext() {
+ return fContext;
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ declareImage(IMG_OBJ_PDA, PATH_OBJECT + "pda.gif");
+ }
+
+ /**
+ * Declares a workbench image given the path of the image file (relative to
+ * the workbench plug-in). This is a helper method that creates the image
+ * descriptor and passes it to the main <code>declareImage</code> method.
+ *
+ * @param symbolicName the symbolic name of the image
+ * @param path the path of the image file relative to the base of the workbench
+ * plug-ins install directory
+ * <code>false</code> if this is not a shared image
+ */
+ private void declareImage(String key, String path) {
+ URL url = BundleUtility.find("org.eclipse.cdt.examples.dsf.pda.ui", path);
+ ImageDescriptor desc = ImageDescriptor.createFromURL(url);
+ getImageRegistry().put(key, desc);
+ }
+
+ /**
+ * Returns the color described by the given RGB.
+ *
+ * @param rgb
+ * @return color
+ */
+ public Color getColor(RGB rgb) {
+ Color color = fColors.get(rgb);
+ if (color == null) {
+ color= new Color(Display.getCurrent(), rgb);
+ fColors.put(rgb, color);
+ }
+ return color;
+ }
+
+ /**
+ * Dispose adapter sets for all launches.
+ */
+ private void disposeAdapterSets() {
+ for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
+ if (launch instanceof PDALaunch) {
+ PDAAdapterFactory.disposeAdapterSet(launch);
+ }
+ }
+ }
+
+ }
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/actions/PDATerminateCommand.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/actions/PDATerminateCommand.java
new file mode 100644
index 00000000000..923be68441f
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/actions/PDATerminateCommand.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems 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.cdt.examples.dsf.pda.ui.actions;
+
+import java.util.concurrent.RejectedExecutionException;
+
+import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
+import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
+import org.eclipse.cdt.examples.dsf.pda.service.PDAVirtualMachineDMContext;
+import org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.commands.IDebugCommandRequest;
+import org.eclipse.debug.core.commands.IEnabledStateRequest;
+import org.eclipse.debug.core.commands.ITerminateHandler;
+
+/**
+ * The terminate command is specialized for the PDA debugger. Currently there
+ * is no standard interface for terminating a debug session in DSF, because the
+ * details of initiating and shutting down a debug session vary greatly in
+ * different debuggers.
+ */
+public class PDATerminateCommand implements ITerminateHandler {
+ // The executor and the services tracker, both initialized from a DSF session.
+ private final DsfSession fSession;
+ private final DsfServicesTracker fTracker;
+
+ public PDATerminateCommand(DsfSession session) {
+ fSession = session;
+ fTracker = new DsfServicesTracker(PDAUIPlugin.getBundleContext(), session.getId());
+ }
+
+ public void dispose() {
+ // DSF services tracker always has to be disposed, because the OSGi services
+ // use reference counting.
+ fTracker.dispose();
+ }
+
+ // Run control may not be available after a connection is terminated and shut down.
+ public void canExecute(final IEnabledStateRequest request) {
+ // Terminate can only operate on a single element.
+ if (request.getElements().length != 1 ||
+ !(request.getElements()[0] instanceof IDMVMContext) )
+ {
+ request.setEnabled(false);
+ request.done();
+ return;
+ }
+
+ // Find the PDA program context in the selected element. If one is not found,
+ // the action should be disabled.
+ IDMVMContext vmc = (IDMVMContext)request.getElements()[0];
+ final PDAVirtualMachineDMContext pdaProgramCtx = DMContexts.getAncestorOfType(vmc.getDMContext(), PDAVirtualMachineDMContext.class);
+ if (pdaProgramCtx == null) {
+ request.setEnabled(false);
+ request.done();
+ return;
+ }
+
+ try {
+ fSession.getExecutor().execute(
+ new DsfRunnable() {
+ public void run() {
+ // Get the processes service and the exec context.
+ PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
+ if (commandControl == null || pdaProgramCtx == null) {
+ // Context or service already invalid.
+ request.setEnabled(false);
+ request.done();
+ } else {
+ // Check whether the control is terminated.
+ request.setEnabled(!commandControl.isTerminated());
+ request.done();
+ }
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ // The DSF session for this context is no longer active. It's possible to check
+ // for this condition before calling fSession.getExecutor().execute(), but
+ // since this method is executing in a different thread than the session control,
+ // there would still be a chance for a race condition leading to this exception.
+ request.setEnabled(false);
+ request.done();
+ }
+ }
+
+ public boolean execute(final IDebugCommandRequest request) {
+ // Skip the checks and assume that this method is called only if the action
+ // was enabled.
+
+ try {
+ fSession.getExecutor().submit(new DsfRunnable() {
+ public void run() {
+ // If the command control service is available, attempt to terminate the program.
+ PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
+ if (commandControl != null) {
+
+ commandControl.terminate(
+ new RequestMonitor(ImmediateExecutor.getInstance(), null) {
+ @Override
+ protected void handleCompleted() {
+ request.setStatus(getStatus());
+ request.done();
+ }
+ });
+ }
+ }
+ });
+ } catch (RejectedExecutionException e) {
+ request.setStatus(new Status(IStatus.ERROR, PDAUIPlugin.PLUGIN_ID, "PDA debug session is shut down."));
+ request.done();
+ }
+ return false;
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDABreakpointAdapter.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDABreakpointAdapter.java
new file mode 100644
index 00000000000..806e87bd88b
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDABreakpointAdapter.java
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.breakpoints;
+
+import org.eclipse.cdt.examples.dsf.pda.PDAPlugin;
+import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDALineBreakpoint;
+import org.eclipse.cdt.examples.dsf.pda.breakpoints.PDAWatchpoint;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+/**
+ * Adapter to create breakpoints in PDA files.
+ * <p>
+ * This class is identical to the corresponding in PDA debugger implemented in
+ * org.eclipse.debug.examples.ui.
+ * </p>
+ */
+public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ ITextEditor textEditor = getEditor(part);
+ if (textEditor != null) {
+ IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
+ ITextSelection textSelection = (ITextSelection) selection;
+ int lineNumber = textSelection.getStartLine();
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(PDAPlugin.ID_PDA_DEBUG_MODEL);
+ for (int i = 0; i < breakpoints.length; i++) {
+ IBreakpoint breakpoint = breakpoints[i];
+ if (breakpoint instanceof ILineBreakpoint && resource.equals(breakpoint.getMarker().getResource())) {
+ if (((ILineBreakpoint)breakpoint).getLineNumber() == (lineNumber + 1)) {
+ // remove
+ breakpoint.delete();
+ return;
+ }
+ }
+ }
+ // create line breakpoint (doc line numbers start at 0)
+ PDALineBreakpoint lineBreakpoint = new PDALineBreakpoint(resource, lineNumber + 1);
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return getEditor(part) != null;
+ }
+
+ /**
+ * Returns the editor being used to edit a PDA file, associated with the
+ * given part, or <code>null</code> if none.
+ *
+ * @param part workbench part
+ * @return the editor being used to edit a PDA file, associated with the
+ * given part, or <code>null</code> if none
+ */
+ private ITextEditor getEditor(IWorkbenchPart part) {
+ if (part instanceof ITextEditor) {
+ ITextEditor editorPart = (ITextEditor) part;
+ IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
+ if (resource != null) {
+ String extension = resource.getFileExtension();
+ if (extension != null && extension.equals("pda")) {
+ return editorPart;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ String[] variableAndFunctionName = getVariableAndFunctionName(part, selection);
+ if (variableAndFunctionName != null && part instanceof ITextEditor && selection instanceof ITextSelection) {
+ ITextEditor editorPart = (ITextEditor)part;
+ int lineNumber = ((ITextSelection)selection).getStartLine();
+ IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
+ String var = variableAndFunctionName[0];
+ String fcn = variableAndFunctionName[1];
+ // look for existing watchpoint to delete
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(PDAPlugin.ID_PDA_DEBUG_MODEL);
+ for (int i = 0; i < breakpoints.length; i++) {
+ IBreakpoint breakpoint = breakpoints[i];
+ if (breakpoint instanceof PDAWatchpoint && resource.equals(breakpoint.getMarker().getResource())) {
+ PDAWatchpoint watchpoint = (PDAWatchpoint)breakpoint;
+ String otherVar = watchpoint.getVariableName();
+ String otherFcn = watchpoint.getFunctionName();
+ if (otherVar.equals(var) && otherFcn.equals(fcn)) {
+ breakpoint.delete();
+ return;
+ }
+ }
+ }
+ // create watchpoint
+ PDAWatchpoint watchpoint = new PDAWatchpoint(resource, lineNumber + 1, fcn, var, true, true);
+ DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(watchpoint);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
+ return getVariableAndFunctionName(part, selection) != null;
+ }
+
+ /**
+ * Returns the variable and function names at the current line, or <code>null</code> if none.
+ *
+ * @param part text editor
+ * @param selection text selection
+ * @return the variable and function names at the current line, or <code>null</code> if none.
+ * The array has two elements, the first is the variable name, the second is the function name.
+ */
+ private String[] getVariableAndFunctionName(IWorkbenchPart part, ISelection selection) {
+ ITextEditor editor = getEditor(part);
+ if (editor != null && selection instanceof ITextSelection) {
+ ITextSelection textSelection = (ITextSelection) selection;
+ IDocumentProvider documentProvider = editor.getDocumentProvider();
+ try {
+ documentProvider.connect(this);
+ IDocument document = documentProvider.getDocument(editor.getEditorInput());
+ IRegion region = document.getLineInformationOfOffset(textSelection.getOffset());
+ String string = document.get(region.getOffset(), region.getLength()).trim();
+ if (string.startsWith("var ")) {
+ String varName = string.substring(4).trim();
+ String fcnName = getFunctionName(document, varName, document.getLineOfOffset(textSelection.getOffset()));
+ return new String[] {varName, fcnName};
+ }
+ } catch (CoreException e) {
+ } catch (BadLocationException e) {
+ } finally {
+ documentProvider.disconnect(this);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the name of the function containing the given variable defined at the given
+ * line number in the specified document.
+ *
+ * @param document PDA source file
+ * @param varName variable name
+ * @param line line numbner at which the variable is defined
+ * @return name of function defining the variable
+ */
+ private String getFunctionName(IDocument document, String varName, int line) {
+ // This is a simple guess at the function name - look for the labels preceeding
+ // the variable definition, and then see if there are any 'calls' to that
+ // label. If none, assumet the variable is in the "_main_" function
+ String source = document.get();
+ int lineIndex = line - 1;
+ while (lineIndex >= 0) {
+ try {
+ IRegion information = document.getLineInformation(lineIndex);
+ String lineText = document.get(information.getOffset(), information.getLength());
+ if (lineText.startsWith(":")) {
+ String label = lineText.substring(1);
+ if (source.indexOf("call " + label) >= 0) {
+ return label;
+ }
+ }
+ lineIndex--;
+ } catch (BadLocationException e) {
+ }
+ }
+ return "_main_";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#toggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ if (canToggleWatchpoints(part, selection)) {
+ toggleWatchpoints(part, selection);
+ } else {
+ toggleLineBreakpoints(part, selection);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#canToggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return canToggleLineBreakpoints(part, selection) || canToggleWatchpoints(part, selection);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDAEditorAdapterFactory.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDAEditorAdapterFactory.java
new file mode 100644
index 00000000000..0fdfb769b78
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/breakpoints/PDAEditorAdapterFactory.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.breakpoints;
+import org.eclipse.cdt.examples.dsf.pda.ui.editor.PDAEditor;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+
+/**
+ * Creates a toggle breakpoint adapter
+ * <p>
+ * This class is identical to the corresponding in PDA debugger implemented in
+ * org.eclipse.debug.examples.ui.
+ * </p>
+ */
+public class PDAEditorAdapterFactory implements IAdapterFactory {
+
+ @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof PDAEditor) {
+ ITextEditor editorPart = (ITextEditor) adaptableObject;
+ IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class);
+ if (resource != null) {
+ String extension = resource.getFileExtension();
+ if (extension != null && extension.equals("pda")) {
+ if (adapterType.equals(IToggleBreakpointsTarget.class)) {
+ return new PDABreakpointAdapter();
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3
+ public Class[] getAdapterList() {
+ return new Class[]{IToggleBreakpointsTarget.class};
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java
new file mode 100644
index 00000000000..4f27cb49e94
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/AnnotationHover.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+/**
+ * Returns hover for breakpoints.
+ * <p>
+ * This class is identical to the corresponding in PDA debugger implemented in
+ * org.eclipse.debug.examples.ui.
+ * </p>
+ */
+public class AnnotationHover implements IAnnotationHover {
+
+ public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
+ IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
+ Iterator<?> iterator = annotationModel.getAnnotationIterator();
+ while (iterator.hasNext()) {
+ Annotation annotation = (Annotation) iterator.next();
+ Position position = annotationModel.getPosition(annotation);
+ try {
+ int lineOfAnnotation = sourceViewer.getDocument().getLineOfOffset(position.getOffset());
+ if (lineNumber == lineOfAnnotation) {
+ return annotation.getText();
+ }
+ } catch (BadLocationException e) {
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistProcessor.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistProcessor.java
new file mode 100644
index 00000000000..6db376d2c00
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistProcessor.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+public class PDAContentAssistProcessor implements IContentAssistProcessor {
+
+ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+ int index = offset - 1;
+ StringBuffer prefix = new StringBuffer();
+ IDocument document = viewer.getDocument();
+ while (index > 0) {
+ try {
+ char prev = document.getChar(index);
+ if (Character.isWhitespace(prev)) {
+ break;
+ }
+ prefix.insert(0, prev);
+ index--;
+ } catch (BadLocationException e) {
+ }
+ }
+
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
+ String[] keywords = PDAScanner.fgKeywords;
+ if (prefix.length() > 0) {
+ String word = prefix.toString();
+ for (int i = 0; i < keywords.length; i++) {
+ String keyword = keywords[i];
+ if (keyword.startsWith(word) && word.length() < keyword.length()) {
+ proposals.add(new CompletionProposal(keyword + " ", index + 1, offset - (index + 1), keyword.length() + 1));
+ }
+ }
+ } else {
+ // propose all keywords
+ for (int i = 0; i < keywords.length; i++) {
+ String keyword = keywords[i];
+ proposals.add(new CompletionProposal(keyword + " ", offset, 0, keyword.length() + 1));
+ }
+ }
+ if (!proposals.isEmpty()) {
+ return proposals.toArray(new ICompletionProposal[proposals.size()]);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
+ */
+ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
+ */
+ public char[] getCompletionProposalAutoActivationCharacters() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
+ */
+ public char[] getContextInformationAutoActivationCharacters() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
+ */
+ public String getErrorMessage() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
+ */
+ public IContextInformationValidator getContextInformationValidator() {
+ return null;
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistant.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistant.java
new file mode 100644
index 00000000000..5ba2782f8fb
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAContentAssistant.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.swt.widgets.Shell;
+
+public class PDAContentAssistant extends ContentAssistant {
+
+ public PDAContentAssistant() {
+ super();
+
+ PDAContentAssistProcessor processor= new PDAContentAssistProcessor();
+ setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
+
+ enableAutoActivation(false);
+ enableAutoInsert(false);
+
+ setInformationControlCreator(getInformationControlCreator());
+ }
+
+ private IInformationControlCreator getInformationControlCreator() {
+ return new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ return new DefaultInformationControl(parent);
+ }
+ };
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditor.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditor.java
new file mode 100644
index 00000000000..198575f32ef
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditor.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+/**
+ * PDA editor
+ */
+public class PDAEditor extends AbstractDecoratedTextEditor {
+
+ /**
+ * Creates a PDE editor
+ */
+ public PDAEditor() {
+ super();
+ setSourceViewerConfiguration(new PDASourceViewerConfiguration());
+ setRulerContextMenuId("pda.editor.rulerMenu");
+ setEditorContextMenuId("pda.editor.editorMenu");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
+ */
+ protected void createActions() {
+ super.createActions();
+ ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.cdt.examples.dsf.pda.ui.editor.PDAEditorMessages"); //$NON-NLS-1$
+ IAction action = new ContentAssistAction(bundle, "ContentAssistProposal.", this); //$NON-NLS-1$
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+ setAction("ContentAssistProposal", action); //$NON-NLS-1$
+ }
+
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditorMessages.properties b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditorMessages.properties
new file mode 100644
index 00000000000..3215e8892de
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAEditorMessages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2000, 2007 IBM Corporation 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+ContentAssistProposal.label=Content &Assist
+ContentAssistProposal.tooltip=Content Assist
+ContentAssistProposal.image=
+ContentAssistProposal.description=Content Assist \ No newline at end of file
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAScanner.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAScanner.java
new file mode 100644
index 00000000000..2604c65c0d6
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDAScanner.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+
+
+/**
+ * PDA editor keyword scanner.
+ */
+public class PDAScanner extends BufferedRuleBasedScanner {
+
+ /**
+ * PDA keywods
+ */
+ public static final String[] fgKeywords = new String[] {
+ "add", "branch_not_zero", "call", "dec", "dup",
+ "halt", "output", "pop", "push", "return", "var"
+ };
+
+ /**
+ * Detects potential keywords
+ */
+ class PDAWordDetector implements IWordDetector {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+ */
+ public boolean isWordStart(char c) {
+ return Character.isLetter(c);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+ */
+ public boolean isWordPart(char c) {
+ return Character.isLetter(c) || c == '_';
+ }
+ }
+
+ /**
+ * Detects PDA branch labels
+ */
+ class PDALabelDetector extends PDAWordDetector {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+ */
+ public boolean isWordStart(char c) {
+ return c == ':';
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+ */
+ public boolean isWordPart(char c) {
+ return super.isWordPart(c) || Character.isDigit(c);
+ }
+ }
+
+ /**
+ * Constructs a scanner that identifies PDA keywords.
+ */
+ public PDAScanner() {
+ // keywords
+ Token token = new Token(new TextAttribute(PDAUIPlugin.getDefault().getColor(PDAUIPlugin.KEYWORD)));
+ WordRule keywords = new WordRule(new PDAWordDetector());
+ for (int i = 0; i < fgKeywords.length; i++) {
+ String keyword = fgKeywords[i];
+ keywords.addWord(keyword, token);
+ }
+ // labels
+ token = new Token(new TextAttribute(PDAUIPlugin.getDefault().getColor(PDAUIPlugin.LABEL)));
+ WordRule labels = new WordRule(new PDALabelDetector(), token);
+ setRules(new IRule[]{keywords, labels});
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDASourceViewerConfiguration.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDASourceViewerConfiguration.java
new file mode 100644
index 00000000000..15b6704d341
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PDASourceViewerConfiguration.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+
+/**
+ * Source view configuration for the PDA editor
+ */
+public class PDASourceViewerConfiguration extends TextSourceViewerConfiguration {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTextHover(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+ */
+ public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+ return new TextHover();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
+ return new AnnotationHover();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+ PresentationReconciler reconciler = new PresentationReconciler();
+ reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+ DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new PDAScanner());
+ reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+ return reconciler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+ return new PDAContentAssistant();
+ }
+
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PopFrameActionDelegate.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PopFrameActionDelegate.java
new file mode 100644
index 00000000000..e3a6212fa80
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/PopFrameActionDelegate.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class PopFrameActionDelegate implements IObjectActionDelegate, IActionDelegate2 {
+
+ //private PDAThread fThread = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ /*
+ try {
+ fThread.pop();
+ } catch (DebugException e) {
+ }*/
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ /* if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ Object element = ss.getFirstElement();
+ if (element instanceof PDAStackFrame) {
+ PDAStackFrame frame = (PDAStackFrame) element;
+ //#ifdef ex5
+//# // TODO: Exercise 5 - enable the action if the frame's thread supports it
+ //#else
+ fThread = (PDAThread) frame.getThread();
+ try {
+ action.setEnabled(fThread.canPop() && fThread.getTopStackFrame().equals(frame));
+ } catch (DebugException e) {
+ }
+ return;
+ //#endif
+ }
+
+ }
+ action.setEnabled(false);
+ */
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
+ */
+ public void init(IAction action) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#dispose()
+ */
+ public void dispose() {
+ //fThread = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
+ */
+ public void runWithEvent(IAction action, Event event) {
+ run(action);
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/TextHover.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/TextHover.java
new file mode 100644
index 00000000000..0ca40e87d90
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/TextHover.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextViewer;
+
+
+/**
+ * Produces debug hover for the PDA debugger.
+ */
+public class TextHover implements ITextHover {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+ */
+ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+ /*String varName = null;
+ try {
+ varName = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
+ } catch (BadLocationException e) {
+ return null;
+ }
+ if (varName.startsWith("$") && varName.length() > 1) {
+ varName = varName.substring(1);
+ }
+
+ PDAStackFrame frame = null;
+ IAdaptable debugContext = DebugUITools.getDebugContext();
+ if (debugContext instanceof PDAStackFrame) {
+ frame = (PDAStackFrame) debugContext;
+ } else if (debugContext instanceof PDAThread) {
+ PDAThread thread = (PDAThread) debugContext;
+ try {
+ frame = (PDAStackFrame) thread.getTopStackFrame();
+ } catch (DebugException e) {
+ return null;
+ }
+ } else if (debugContext instanceof PDADebugTarget) {
+ PDADebugTarget target = (PDADebugTarget) debugContext;
+ try {
+ IThread[] threads = target.getThreads();
+ if (threads.length > 0) {
+ frame = (PDAStackFrame) threads[0].getTopStackFrame();
+ }
+ } catch (DebugException e) {
+ return null;
+ }
+ }
+ if (frame != null) {
+ try {
+ IVariable[] variables = frame.getVariables();
+ for (int i = 0; i < variables.length; i++) {
+ IVariable variable = variables[i];
+ if (variable.getName().equals(varName)) {
+ return varName + " = " + variable.getValue().getValueString();
+ }
+ }
+ } catch (DebugException e) {
+ }
+ }*/
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
+ */
+ public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+ return WordFinder.findWord(textViewer.getDocument(), offset);
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/WordFinder.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/WordFinder.java
new file mode 100644
index 00000000000..e67e1adfaaa
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/editor/WordFinder.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.editor;
+
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+
+/**
+ * Looks for an identifier in a source file
+ */
+public class WordFinder {
+
+ /**
+ * Returns the region in the given document that contains an identifier, or
+ * <code>null</code> if none.
+ *
+ * @param document document to search
+ * @param offset offset at which to look for an identifier
+ * @return region containing an identifier, or <code>null</code>
+ */
+ public static IRegion findWord(IDocument document, int offset) {
+
+ int start= -1;
+ int end= -1;
+
+
+ try {
+
+ int pos= offset;
+ char c;
+
+ while (pos >= 0) {
+ c= document.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ --pos;
+ }
+
+ start= pos;
+
+ pos= offset;
+ int length= document.getLength();
+
+ while (pos < length) {
+ c= document.getChar(pos);
+ if (!Character.isJavaIdentifierPart(c))
+ break;
+ ++pos;
+ }
+
+ end= pos;
+
+ } catch (BadLocationException x) {
+ }
+
+ if (start > -1 && end > -1) {
+ if (start == offset && end == offset)
+ return new Region(offset, 0);
+ else if (start == offset)
+ return new Region(start, end - start);
+ else
+ return new Region(start + 1, end - start - 1);
+ }
+
+ return null;
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDAMainTab.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDAMainTab.java
new file mode 100644
index 00000000000..6f4ca94aa4d
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDAMainTab.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.launcher;
+
+
+import org.eclipse.cdt.examples.dsf.pda.PDAPlugin;
+import org.eclipse.cdt.examples.dsf.pda.ui.PDAUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ResourceListSelectionDialog;
+
+
+/**
+ * Tab to specify the PDA program to run/debug.
+ * <p>
+ * This class is identical to the corresponding in PDA debugger implemented in
+ * org.eclipse.debug.examples.ui.
+ * </p>
+ */
+public class PDAMainTab extends AbstractLaunchConfigurationTab {
+
+ private Text fProgramText;
+ private Button fProgramButton;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout();
+ topLayout.verticalSpacing = 0;
+ topLayout.numColumns = 3;
+ comp.setLayout(topLayout);
+ comp.setFont(font);
+
+ createVerticalSpacer(comp, 3);
+
+ Label programLabel = new Label(comp, SWT.NONE);
+ programLabel.setText("&Program:");
+ GridData gd = new GridData(GridData.BEGINNING);
+ programLabel.setLayoutData(gd);
+ programLabel.setFont(font);
+
+ fProgramText = new Text(comp, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fProgramText.setLayoutData(gd);
+ fProgramText.setFont(font);
+ fProgramText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ fProgramButton = createPushButton(comp, "&Browse...", null); //$NON-NLS-1$
+ fProgramButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ browsePDAFiles();
+ }
+ });
+ }
+
+ /**
+ * Open a resource chooser to select a PDA program
+ */
+ protected void browsePDAFiles() {
+ ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
+ dialog.setTitle("PDA Program");
+ dialog.setMessage("Select PDA Program");
+ if (dialog.open() == Window.OK) {
+ Object[] files = dialog.getResult();
+ IFile file = (IFile) files[0];
+ fProgramText.setText(file.getFullPath().toString());
+ }
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ //#ifdef ex1
+//# // TODO: Exercise 1 - retrieve the program path attribute from the launch configuration
+//# String program = null;
+//# if (program != null) {
+//# fProgramText.setText(program);
+//# }
+ //#else
+ try {
+ String program = null;
+ program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null);
+ if (program != null) {
+ fProgramText.setText(program);
+ }
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ }
+ //#endif
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ String program = fProgramText.getText().trim();
+ if (program.length() == 0) {
+ program = null;
+ }
+ //#ifdef ex1
+//# // TODO: Exercise 1 - update the launch configuration with the path to
+//# // currently specified program
+ //#else
+ configuration.setAttribute(PDAPlugin.ATTR_PDA_PROGRAM, program);
+ //#endif
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Main";
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ setErrorMessage(null);
+ setMessage(null);
+ String text = fProgramText.getText();
+ //#ifdef ex1
+//# // TODO: Exercise 1 - validate the currently specified program exists and is not
+//# // empty, providing the user with feedback.
+ //#else
+ if (text.length() > 0) {
+ IPath path = new Path(text);
+ if (ResourcesPlugin.getWorkspace().getRoot().findMember(path) == null) {
+ setErrorMessage("Specified program does not exist");
+ return false;
+ }
+ } else {
+ setMessage("Specify a program");
+ }
+ //#endif
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
+ */
+ public Image getImage() {
+ return PDAUIPlugin.getDefault().getImageRegistry().get(PDAUIPlugin.IMG_OBJ_PDA);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDATabGroup.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDATabGroup.java
new file mode 100644
index 00000000000..7c9ed2fb073
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/launcher/PDATabGroup.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ * Bjorn Freeman-Benson - initial API and implementation
+ * Wind River Systems - adopted to use with DSF
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.launcher;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
+
+/**
+ * Tab group for a PDA application
+ * <p>
+ * This class is identical to the corresponding in PDA debugger implemented in
+ * org.eclipse.debug.examples.ui.
+ * </p>
+ */
+public class PDATabGroup extends AbstractLaunchConfigurationTabGroup {
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ //#ifdef ex1
+//# // TODO: Exercise 1 - add the PDA main tab, source lookup tab and common
+//# // tab to the tab group
+ //#else
+ setTabs(new ILaunchConfigurationTab[] {
+ new PDAMainTab(),
+ new SourceLookupTab(),
+ new CommonTab()
+ });
+ //#endif
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAVMAdapter.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAVMAdapter.java
new file mode 100644
index 00000000000..2e1761f769c
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/PDAVMAdapter.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems 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.cdt.examples.dsf.pda.ui.viewmodel;
+
+import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.AbstractDebugVMAdapter;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.SteppingController;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionVMProvider;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.register.RegisterVMProvider;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.VariableVMProvider;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
+import org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch.PDALaunchVMProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.ui.IDebugUIConstants;
+
+@ThreadSafe
+@SuppressWarnings("restriction")
+public class PDAVMAdapter extends AbstractDebugVMAdapter
+{
+ public PDAVMAdapter(DsfSession session, SteppingController controller) {
+ super(session, controller);
+ getSession().registerModelAdapter(IColumnPresentationFactory.class, this);
+ }
+
+ @Override
+ public void dispose() {
+ getSession().unregisterModelAdapter(IColumnPresentationFactory.class);
+ super.dispose();
+ }
+
+ @Override
+ protected AbstractDMVMProvider createViewModelProvider(IPresentationContext context) {
+ if ( IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId()) ) {
+ return new PDALaunchVMProvider(this, context, getSession());
+ } else if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId()) ) {
+ return new VariableVMProvider(this, context, getSession());
+ } else if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId()) ) {
+ return new ExpressionVMProvider(this, context, getSession());
+ } else if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId()) ) {
+ return new RegisterVMProvider(this, context, getSession());
+ }
+ return null;
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDALaunchVMProvider.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDALaunchVMProvider.java
new file mode 100644
index 00000000000..b00b63e8946
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDALaunchVMProvider.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems 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
+ * Ericsson - Modified for new functionality
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch;
+
+import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractLaunchVMProvider;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StackFramesVMNode;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StandardProcessVMNode;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMAdapter;
+import org.eclipse.cdt.dsf.ui.viewmodel.IRootVMNode;
+import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+
+
+/**
+ * View Model provider for the Launch (AKA Debug) view. The launch VM
+ * provider is configured with three nodes:
+ * <ul>
+ * <li> LaunchRootVMNode - This is the root of the PDA view model.</li>
+ * <li> PDAVirtualMachineVMNode - Supplies the element representing PDA VM</li>
+ * <li> PDAThreadsVMNode - Supplies the PDA thread elements</li>
+ * <li> StackFramesVMNode - Supplies the stack frame elements.</li>
+ * <li> StandardProcessVMNode - Supplies elements representing the PDA
+ * debugger process.</li>
+ * </ul>
+ */
+@SuppressWarnings("restriction")
+public class PDALaunchVMProvider extends AbstractLaunchVMProvider
+ implements IDebugEventSetListener, ILaunchesListener2
+{
+ @ThreadSafe
+ public PDALaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)
+ {
+ super(adapter, presentationContext, session);
+
+ IRootVMNode launchNode = new LaunchRootVMNode(this);
+ setRootNode(launchNode);
+
+ // Launch node is a parent to the processes and program nodes.
+ IVMNode pdaVirtualMachineNode = new PDAVirtualMachineVMNode(this, getSession());
+ IVMNode processesNode = new StandardProcessVMNode(this);
+ addChildNodes(launchNode, new IVMNode[] { pdaVirtualMachineNode, processesNode});
+
+ // Virtual machine node is under the PDA threads node.
+ IVMNode threadsNode = new PDAThreadsVMNode(this, getSession());
+ addChildNodes(pdaVirtualMachineNode, new IVMNode[] { threadsNode });
+
+ // Stack frames node is under the PDA threads node.
+ IVMNode stackFramesNode = new StackFramesVMNode(this, getSession());
+ addChildNodes(threadsNode, new IVMNode[] { stackFramesNode });
+
+ // Register the LaunchVM provider as a listener to debug and launch
+ // events. These events are used by the launch and processes nodes.
+ DebugPlugin.getDefault().addDebugEventListener(this);
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+ }
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java
new file mode 100644
index 00000000000..043f4bc9f08
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAThreadsVMNode.java
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems 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
+ * Ericsson - Modified for multi threaded functionality
+ *******************************************************************************/
+package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch;
+
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.cdt.examples.dsf.pda.service.PDARunControl;
+import org.eclipse.cdt.examples.dsf.pda.service.PDAThreadDMContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.IMemento;
+
+
+/**
+ * View model node supplying the PDA thread elements. It extends
+ * the base threads node and adds label and memento generation.
+ */
+@SuppressWarnings("restriction")
+public class PDAThreadsVMNode extends AbstractThreadVMNode
+ implements IElementLabelProvider, IElementMementoProvider
+{
+ public PDAThreadsVMNode(AbstractDMVMProvider provider, DsfSession session) {
+ super(provider, session);
+ }
+
+ @Override
+ public String toString() {
+ return "PDAThreadVMNode(" + getSession().getId() + ")";
+ }
+
+ @Override
+ protected void updateLabelInSessionThread(ILabelUpdate[] updates) {
+ for (final ILabelUpdate update : updates) {
+ final PDARunControl runControl = getServicesTracker().getService(PDARunControl.class);
+ if ( runControl == null ) {
+ handleFailedUpdate(update);
+ continue;
+ }
+
+ final PDAThreadDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAThreadDMContext.class);
+
+ String imageKey = null;
+ if (getServicesTracker().getService(IRunControl.class).isSuspended(dmc)) {
+ imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
+ } else {
+ imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
+ }
+ update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
+
+ // Find the Reason for the State
+ getDMVMProvider().getModelData(
+ this, update, runControl, dmc,
+ new ViewerDataRequestMonitor<IExecutionDMData>(getSession().getExecutor(), update) {
+ @Override
+ public void handleCompleted(){
+ if (!isSuccess()) {
+ update.setLabel("<unavailable>", 0);
+ update.done();
+ return;
+ }
+
+ // We're in a new dispatch cycle, and we have to check whether the
+ // service reference is still valid.
+ final PDARunControl runControl = getServicesTracker().getService(PDARunControl.class);
+ if ( runControl == null ) {
+ handleFailedUpdate(update);
+ return;
+ }
+
+ final StateChangeReason reason = getData().getStateChangeReason();
+
+ // Create Labels of type Thread[GDBthreadId]RealThreadID/Name (State: Reason)
+ // Thread[1] 3457 (Suspended:BREAKPOINT)
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Thread ");
+ builder.append(dmc.getID());
+ if(getServicesTracker().getService(IRunControl.class).isSuspended(dmc))
+ builder.append(" (Suspended");
+ else
+ builder.append(" (Running");
+ // Reason will be null before ContainerSuspendEvent is fired
+ if(reason != null) {
+ builder.append(" : ");
+ builder.append(reason);
+ }
+ builder.append(")");
+ update.setLabel(builder.toString(), 0);
+ update.done();
+ }
+ },
+ getExecutor());
+
+ }
+ }
+
+ private String produceThreadElementName(String viewName, PDAThreadDMContext execCtx) {
+ return "Thread." + execCtx.getID();
+ }
+
+ private static final String MEMENTO_NAME = "THREAD_MEMENTO_NAME";
+
+ /*
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[])
+ */
+ public void compareElements(IElementCompareRequest[] requests) {
+ for ( IElementCompareRequest request : requests ) {
+ Object element = request.getElement();
+ IMemento memento = request.getMemento();
+ String mementoName = memento.getString(MEMENTO_NAME);
+ if (mementoName != null) {
+ if (element instanceof IDMVMContext) {
+ IDMContext dmc = ((IDMVMContext)element).getDMContext();
+ if ( dmc instanceof PDAThreadDMContext) {
+ String elementName = produceThreadElementName(
+ request.getPresentationContext().getId(), (PDAThreadDMContext) dmc );
+ request.setEqual( elementName.equals( mementoName ) );
+ }
+ }
+ }
+ request.done();
+ }
+ }
+
+ /*
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[])
+ */
+ public void encodeElements(IElementMementoRequest[] requests) {
+ for ( IElementMementoRequest request : requests ) {
+ Object element = request.getElement();
+ IMemento memento = request.getMemento();
+ if (element instanceof IDMVMContext) {
+ IDMContext dmc = ((IDMVMContext)element).getDMContext();
+ if ( dmc instanceof PDAThreadDMContext) {
+ String elementName = produceThreadElementName( request.getPresentationContext().getId(), (PDAThreadDMContext) dmc );
+ memento.putString(MEMENTO_NAME, elementName);
+ }
+ }
+ request.done();
+ }
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java
new file mode 100644
index 00000000000..62b57922fa3
--- /dev/null
+++ b/dsf/org.eclipse.cdt.examples.dsf.pda.ui/src/org/eclipse/cdt/examples/dsf/pda/ui/viewmodel/launch/PDAVirtualMachineVMNode.java
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Ericsson 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:
+ * Ericsson - Initial API and implementation
+ * Wind River Systems - Factored out AbstractContainerVMNode
+ *******************************************************************************/
+
+package org.eclipse.cdt.examples.dsf.pda.ui.viewmodel.launch;
+
+
+import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.service.IRunControl;
+import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
+import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
+import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.cdt.examples.dsf.pda.service.PDACommandControl;
+import org.eclipse.cdt.examples.dsf.pda.service.PDAVirtualMachineDMContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.ui.IMemento;
+
+
+/**
+ * View Model node representing a PDA virtual machine. It extends
+ * the base container node and adds label and memento generation.
+ */
+@SuppressWarnings("restriction")
+public class PDAVirtualMachineVMNode extends AbstractContainerVMNode
+ implements IElementMementoProvider
+{
+ public PDAVirtualMachineVMNode(AbstractDMVMProvider provider, DsfSession session) {
+ super(provider, session);
+ }
+
+ @Override
+ public String toString() {
+ return "PDAContainerVMNode(" + getSession().getId() + ")";
+ }
+
+
+ @Override
+ protected void updateElementsInSessionThread(IChildrenUpdate update) {
+ // Get the instance of the service. Note that there is no race condition
+ // in getting the service since this method is called only in the
+ // service executor thread.
+ final PDACommandControl commandControl = getServicesTracker().getService(PDACommandControl.class);
+
+ // Check if the service is available. If it is not, no elements are
+ // updated.
+ if (commandControl == null) {
+ handleFailedUpdate(update);
+ return;
+ }
+
+ update.setChild(createVMContext(commandControl.getContext()), 0);
+ update.done();
+ }
+
+
+ @Override
+ protected void updateLabelInSessionThread(final ILabelUpdate update) {
+ // Get a reference to the run control service.
+ final IRunControl runControl = getServicesTracker().getService(IRunControl.class);
+ if (runControl == null) {
+ handleFailedUpdate(update);
+ return;
+ }
+
+ // Find the PDA program context.
+ final PDAVirtualMachineDMContext programCtx =
+ findDmcInPath(update.getViewerInput(), update.getElementPath(), PDAVirtualMachineDMContext.class);
+
+ // Call service to get current program state
+ final boolean isSuspended = runControl.isSuspended(programCtx);
+
+ // Set the program icon based on the running state of the program.
+ String imageKey = null;
+ if (isSuspended) {
+ imageKey = IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
+ } else {
+ imageKey = IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
+ }
+ update.setImageDescriptor(DebugUITools.getImageDescriptor(imageKey), 0);
+
+ // Retrieve the last state change reason
+ getDMVMProvider().getModelData(
+ this, update, runControl, programCtx,
+ new ViewerDataRequestMonitor<IExecutionDMData>(ImmediateExecutor.getInstance(), update)
+ {
+ @Override
+ public void handleCompleted(){
+ // If the request failed, fail the udpate.
+ if (!isSuccess()) {
+ handleFailedUpdate(update);
+ return;
+ }
+
+ // Compose the thread name string.
+ final StringBuilder builder = new StringBuilder();
+
+ builder.append("PDA [");
+ builder.append(programCtx.getProgram());
+ builder.append("]");
+
+ if(isSuspended) {
+ builder.append(" (Suspended");
+ } else {
+ builder.append(" (Running");
+ }
+ // Reason will be null before ContainerSuspendEvent is fired
+ if(getData().getStateChangeReason() != null) {
+ builder.append(" : ");
+ builder.append(getData().getStateChangeReason());
+ }
+ builder.append(")");
+ update.setLabel(builder.toString(), 0);
+ update.done();
+ }
+ },
+ getExecutor());
+ }
+
+ private String produceProgramElementName( String viewName , PDAVirtualMachineDMContext execCtx ) {
+ return "PDA." + execCtx.getProgram(); //$NON-NLS-1$
+ }
+
+ private final String MEMENTO_NAME = "PDAPROGRAM_MEMENTO_NAME"; //$NON-NLS-1$
+
+ public void compareElements(IElementCompareRequest[] requests) {
+
+ for ( IElementCompareRequest request : requests ) {
+
+ Object element = request.getElement();
+ IMemento memento = request.getMemento();
+ String mementoName = memento.getString(MEMENTO_NAME);
+
+ if (mementoName != null) {
+ if (element instanceof IDMVMContext) {
+
+ IDMContext dmc = ((IDMVMContext)element).getDMContext();
+
+ if ( dmc instanceof PDAVirtualMachineDMContext) {
+
+ String elementName = produceProgramElementName( request.getPresentationContext().getId(), (PDAVirtualMachineDMContext) dmc );
+ request.setEqual( elementName.equals( mementoName ) );
+ }
+ }
+ }
+ request.done();
+ }
+ }
+
+ public void encodeElements(IElementMementoRequest[] requests) {
+
+ for ( IElementMementoRequest request : requests ) {
+
+ Object element = request.getElement();
+ IMemento memento = request.getMemento();
+
+ if (element instanceof IDMVMContext) {
+
+ IDMContext dmc = ((IDMVMContext)element).getDMContext();
+
+ if ( dmc instanceof PDAVirtualMachineDMContext) {
+
+ String elementName = produceProgramElementName( request.getPresentationContext().getId(), (PDAVirtualMachineDMContext) dmc );
+ memento.putString(MEMENTO_NAME, elementName);
+ }
+ }
+ request.done();
+ }
+ }
+}

Back to the top