diff --git a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/pop.gif b/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/pop.gif
deleted file mode 100644
index 559e462985f..00000000000
Binary files a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/pop.gif and /dev/null differ
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/push.gif b/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/push.gif
deleted file mode 100644
index f7e6cc089c2..00000000000
Binary files a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/dlcl16/push.gif and /dev/null differ
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/pop.gif b/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/pop.gif
deleted file mode 100644
index 2cd9c544436..00000000000
Binary files a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/pop.gif and /dev/null differ
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/push.gif b/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/push.gif
deleted file mode 100644
index a5ac28d4c56..00000000000
Binary files a/plugins/org.eclipse.dd.examples.pda.ui/icons/full/elcl16/push.gif and /dev/null differ
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/plugin.xml b/plugins/org.eclipse.dd.examples.pda.ui/plugin.xml
index e53b8024b6f..4247cf66b16 100644
--- a/plugins/org.eclipse.dd.examples.pda.ui/plugin.xml
+++ b/plugins/org.eclipse.dd.examples.pda.ui/plugin.xml
@@ -27,29 +27,6 @@
-
+ * 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. + *
*/ @ThreadSafe @SuppressWarnings({"restriction"}) public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2 { + /** + * Contains the set of adapters that are created for eacy launch instance. + */ @Immutable - class LaunchAdapterSet { + private static class LaunchAdapterSet { + // View Model adapter final PDAVMAdapter fViewModelAdapter; + + // Source lookup and positioning adapter final MISourceDisplayAdapter fSourceDisplayAdapter; + + // Command adapters final DsfStepIntoCommand fStepIntoCommand; final DsfStepOverCommand fStepOverCommand; final DsfStepReturnCommand fStepReturnCommand; final DsfSuspendCommand fSuspendCommand; final DsfResumeCommand fResumeCommand; - final DsfTerminateCommand fTerminateCommand; + final PDATerminateCommand fTerminateCommand; + + // Adapters for integration with other UI actions final IDebugModelProvider fDebugModelProvider; final PDALaunch fLaunch; LaunchAdapterSet(PDALaunch launch) { + // Initialize launch and session. fLaunch = launch; DsfSession session = launch.getSession(); + // Initialize VM fViewModelAdapter = new PDAVMAdapter(session); - if (launch.getSourceLocator() instanceof ISourceLookupDirector) { - fSourceDisplayAdapter = new MISourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator()); - } else { - fSourceDisplayAdapter = null; - } + // Initialize source lookup + fSourceDisplayAdapter = new MISourceDisplayAdapter(session, (ISourceLookupDirector)launch.getSourceLocator()); session.registerModelAdapter(ISourceDisplay.class, fSourceDisplayAdapter); + // Initialize retargetable command handler. fStepIntoCommand = new DsfStepIntoCommand(session); fStepOverCommand = new DsfStepOverCommand(session); fStepReturnCommand = new DsfStepReturnCommand(session); fSuspendCommand = new DsfSuspendCommand(session); fResumeCommand = new DsfResumeCommand(session); - fTerminateCommand = new DsfTerminateCommand(session); + fTerminateCommand = new PDATerminateCommand(session); session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand); session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand); session.registerModelAdapter(IStepReturnHandler.class, fStepReturnCommand); @@ -93,19 +108,17 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2 session.registerModelAdapter(IResumeHandler.class, fResumeCommand); session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand); + // Initialize debug model provider fDebugModelProvider = new IDebugModelProvider() { - // @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers() public String[] getModelIdentifiers() { return new String[] { PDAPlugin.ID_PDA_DEBUG_MODEL }; } }; session.registerModelAdapter(IDebugModelProvider.class, fDebugModelProvider); - /* - * Registering the launch as an adapter, ensures that this launch, - * and debug model ID will be associated with all DMContexts from this - * session. - */ + // 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); } @@ -139,10 +152,8 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2 DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); } - /** - * This method only actually returns adapters for the launch object. - */ - @SuppressWarnings("unchecked") + // 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; @@ -167,20 +178,15 @@ public class PDAAdapterFactory implements IAdapterFactory, ILaunchesListener2 else return null; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3 public Class[] getAdapterList() { return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, IColumnPresentationFactory.class }; } - public void sessionEnded(DsfSession session) { - } - public void launchesRemoved(ILaunch[] launches) { // Dispose the set of adapters for a launch only after the launch is - // removed. + // 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) { PDALaunch pdaLaunch = (PDALaunch)launch; diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/PDAUIPlugin.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/PDAUIPlugin.java index f44fc65f030..327d9a9a399 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/PDAUIPlugin.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/PDAUIPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,16 +8,13 @@ * 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.dd.examples.pda.ui; import java.net.URL; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.Map.Entry; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; @@ -32,29 +29,16 @@ 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.dd.examples.pda.ui "; + //The shared instance. private static PDAUIPlugin plugin; - //Resource bundle. - private ResourceBundle resourceBundle; 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$ - private final static String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; //Enabled local toolbar icons //$NON-NLS-1$ - private final static String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; //Disabled local toolbar icons //$NON-NLS-1$ - - /** - * Toolbar action to pop data stack - */ - public final static String IMG_ELCL_POP = "IMG_ELCL_POP"; - public final static String IMG_DLCL_POP = "IMG_DLCL_POP"; - - /** - * Toolbar action to push onto data stack - */ - public final static String IMG_ELCL_PUSH = "IMG_ELCL_PUSH"; - public final static String IMG_DLCL_PUSH = "IMG_DLCL_PUSH"; /** * PDA program image @@ -70,7 +54,7 @@ public class PDAUIPlugin extends AbstractUIPlugin { /** * Managed colors */ - private Map fColors = new HashMap(); + private Mapfalse
if this is not a shared image
*/
private void declareImage(String key, String path) {
- URL url = BundleUtility.find("org.eclipse.debug.examples.ui", path);
+ URL url = BundleUtility.find("org.eclipse.dd.examples.pda.ui", path);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
getImageRegistry().put(key, desc);
}
@@ -180,7 +126,7 @@ public class PDAUIPlugin extends AbstractUIPlugin {
* @return color
*/
public Color getColor(RGB rgb) {
- Color color = (Color) fColors.get(rgb);
+ Color color = fColors.get(rgb);
if (color == null) {
color= new Color(Display.getCurrent(), rgb);
fColors.put(rgb, color);
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/actions/DsfTerminateCommand.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/actions/DsfTerminateCommand.java
deleted file mode 100644
index 720c4ec6fc4..00000000000
--- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/actions/DsfTerminateCommand.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.dd.examples.pda.ui.actions;
-
-import org.eclipse.dd.dsf.concurrent.DsfExecutor;
-import org.eclipse.dd.dsf.concurrent.DsfRunnable;
-import org.eclipse.dd.dsf.concurrent.RequestMonitor;
-import org.eclipse.dd.dsf.datamodel.DMContexts;
-import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
-import org.eclipse.dd.dsf.service.DsfServicesTracker;
-import org.eclipse.dd.dsf.service.DsfSession;
-import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
-import org.eclipse.dd.examples.pda.service.command.PDACommandControl;
-import org.eclipse.dd.examples.pda.ui.PDAUIPlugin;
-import org.eclipse.debug.core.commands.IDebugCommandRequest;
-import org.eclipse.debug.core.commands.IEnabledStateRequest;
-import org.eclipse.debug.core.commands.ITerminateHandler;
-
-public class DsfTerminateCommand implements ITerminateHandler {
- private final DsfExecutor fExecutor;
- private final DsfServicesTracker fTracker;
-
- public DsfTerminateCommand(DsfSession session) {
- fExecutor = session.getExecutor();
- fTracker = new DsfServicesTracker(PDAUIPlugin.getBundleContext(), session.getId());
- }
-
- public void dispose() {
- fTracker.dispose();
- }
-
- // Run control may not be avilable after a connection is terminated and shut down.
- public void canExecute(final IEnabledStateRequest request) {
- if (request.getElements().length != 1 ||
- !(request.getElements()[0] instanceof IDMVMContext) )
- {
- request.setEnabled(false);
- request.done();
- return;
- }
-
- // Javac doesn't like the cast to "(AbstractDMVMLayoutNode>.DMVMContext)" need to use the
- // construct below and suppress warnings.
- IDMVMContext vmc = (IDMVMContext)request.getElements()[0];
- final IExecutionDMContext dmc = DMContexts.getAncestorOfType(vmc.getDMContext(), IExecutionDMContext.class);
- if (dmc == null) {
- request.setEnabled(false);
- request.done();
- return;
- }
-
- fExecutor.execute(
- new DsfRunnable() {
- public void run() {
- // Get the processes service and the exec context.
- PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
- if (commandControl == null || dmc == null) {
- // Context or service already invalid.
- request.setEnabled(false);
- request.done();
- } else {
- // Check the terminate.
- request.setEnabled(!commandControl.isTerminated());
- request.done();
- }
- }
- });
- }
-
- public boolean execute(final IDebugCommandRequest request) {
- if (request.getElements().length != 1) {
- request.done();
- return false;
- }
-
- fExecutor.submit(new DsfRunnable() {
- public void run() {
- PDACommandControl commandControl = fTracker.getService(PDACommandControl.class);
- if (commandControl != null) {
- commandControl.shutdown(new RequestMonitor(fExecutor, null));
- }
- }
- });
- return false;
- }
-
-}
diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/actions/PDATerminateCommand.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/actions/PDATerminateCommand.java
new file mode 100644
index 00000000000..cbfb60c4f75
--- /dev/null
+++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/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.dd.examples.pda.ui.actions;
+
+import java.util.concurrent.RejectedExecutionException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.dd.dsf.concurrent.DsfRunnable;
+import org.eclipse.dd.dsf.concurrent.ImmediateExecutor;
+import org.eclipse.dd.dsf.concurrent.RequestMonitor;
+import org.eclipse.dd.dsf.datamodel.DMContexts;
+import org.eclipse.dd.dsf.service.DsfServicesTracker;
+import org.eclipse.dd.dsf.service.DsfSession;
+import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
+import org.eclipse.dd.examples.pda.service.PDACommandControl;
+import org.eclipse.dd.examples.pda.service.PDAProgramDMContext;
+import org.eclipse.dd.examples.pda.ui.PDAUIPlugin;
+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 PDAProgramDMContext pdaProgramCtx = DMContexts.getAncestorOfType(vmc.getDMContext(), PDAProgramDMContext.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/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDABreakpointAdapter.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDABreakpointAdapter.java
index 006fbe1d6aa..f23551444b4 100644
--- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDABreakpointAdapter.java
+++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDABreakpointAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * 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
@@ -8,6 +8,7 @@
* 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.dd.examples.pda.ui.breakpoints;
@@ -32,6 +33,10 @@ import org.eclipse.ui.texteditor.ITextEditor;
/**
* Adapter to create breakpoints in PDA files.
+ * + * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples.ui. + *
*/ public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension { /* (non-Javadoc) diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDAEditorAdapterFactory.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDAEditorAdapterFactory.java index 30d8c770a39..5065cadaa68 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDAEditorAdapterFactory.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDAEditorAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,25 +8,28 @@ * 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.dd.examples.pda.ui.breakpoints; - import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.dd.examples.pda.ui.editor.PDAEditor; -import org.eclipse.debug.ui.actions.IRunToLineTarget; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.ui.texteditor.ITextEditor; + /** * Creates a toggle breakpoint adapter + *+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples.ui. + *
*/ public class PDAEditorAdapterFactory implements IAdapterFactory { - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { + + @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); @@ -36,22 +39,14 @@ public class PDAEditorAdapterFactory implements IAdapterFactory { if (adapterType.equals(IToggleBreakpointsTarget.class)) { return new PDABreakpointAdapter(); } - //#ifdef ex7 -//# // TODO: Exercise 7 - create run to line adapter - //#else - if (adapterType.equals(IRunToLineTarget.class)) { - return new PDARunToLineAdapter(); - } - //#endif } } } return null; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { + + @SuppressWarnings("unchecked") // IAdapterFactory is Java 1.3 + public Class[] getAdapterList() { return new Class[]{IToggleBreakpointsTarget.class}; } } diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDARunToLineAdapter.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDARunToLineAdapter.java deleted file mode 100644 index e73fbeeedab..00000000000 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/breakpoints/PDARunToLineAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - * Bjorn Freeman-Benson - initial API and implementation - *******************************************************************************/ -package org.eclipse.dd.examples.pda.ui.breakpoints; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.dd.examples.pda.PDAPlugin; -import org.eclipse.dd.examples.pda.breakpoints.PDARunToLineBreakpoint; -import org.eclipse.debug.core.model.IBreakpoint; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IDebugTarget; -import org.eclipse.debug.core.model.ISuspendResume; -import org.eclipse.debug.ui.actions.IRunToLineTarget; -import org.eclipse.debug.ui.actions.RunToLineHandler; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.texteditor.ITextEditor; - - -/** - * Run to line target for the Java debugger - */ -public class PDARunToLineAdapter implements IRunToLineTarget { - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) - */ - public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException { - IEditorPart editorPart = (IEditorPart)part; - ITextEditor textEditor = (ITextEditor)editorPart; - ITextSelection textSelection = (ITextSelection) selection; - int lineNumber = textSelection.getStartLine() + 1; - if (lineNumber > 0) { - if (target instanceof IAdaptable) { - IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable)target).getAdapter(IDebugTarget.class); - if (debugTarget != null) { - //#ifdef ex7 -//# // TODO: Exercise 7 - perform the run-to-line with a run-to-line breakpoint and handler - //#else - IFile resource = (IFile) textEditor.getEditorInput().getAdapter(IResource.class); - IBreakpoint breakpoint= new PDARunToLineBreakpoint(resource, lineNumber); - RunToLineHandler handler = new RunToLineHandler(debugTarget, target, breakpoint); - handler.run(new NullProgressMonitor()); - //#endif - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume) - */ - public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) { - //#ifdef ex7 -//# // TODO: Exercise 7 - ensure the target is a PDA target -//# return false; - //#else - return target instanceof IDebugElement && - ((IDebugElement)target).getModelIdentifier().equals(PDAPlugin.ID_PDA_DEBUG_MODEL); - //#endif - } -} diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/AnnotationHover.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/AnnotationHover.java index 0e76a9ca3f7..c06509aeac4 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/AnnotationHover.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/AnnotationHover.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.dd.examples.pda.ui.editor; @@ -22,12 +23,16 @@ import org.eclipse.jface.text.source.ISourceViewer; /** * Returns hover for breakpoints. + *+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples.ui. + *
*/ public class AnnotationHover implements IAnnotationHover { public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) { IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); - Iterator iterator = annotationModel.getAnnotationIterator(); + Iterator> iterator = annotationModel.getAnnotationIterator(); while (iterator.hasNext()) { Annotation annotation = (Annotation) iterator.next(); Position position = annotationModel.getPosition(annotation); diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/PDAContentAssistProcessor.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/PDAContentAssistProcessor.java index 93519ba4680..795b8dd05a0 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/PDAContentAssistProcessor.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/editor/PDAContentAssistProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.dd.examples.pda.ui.editor; @@ -41,7 +42,7 @@ public class PDAContentAssistProcessor implements IContentAssistProcessor { } } - List proposals = new ArrayList(); + List+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples.ui. + *
*/ public class PDAMainTab extends AbstractLaunchConfigurationTab { diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/launcher/PDATabGroup.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/launcher/PDATabGroup.java index 5df54b6f66d..af66ec6a5d4 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/launcher/PDATabGroup.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/launcher/PDATabGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.dd.examples.pda.ui.launcher; @@ -19,6 +20,10 @@ import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; /** * Tab group for a PDA application + *+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples.ui. + *
*/ public class PDATabGroup extends AbstractLaunchConfigurationTabGroup { /* (non-Javadoc) diff --git a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/viewmodel/launch/LaunchVMProvider.java b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/viewmodel/launch/LaunchVMProvider.java index 2990aa9d968..3cbd4c36cef 100644 --- a/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/viewmodel/launch/LaunchVMProvider.java +++ b/plugins/org.eclipse.dd.examples.pda.ui/src/org/eclipse/dd/examples/pda/ui/viewmodel/launch/LaunchVMProvider.java @@ -32,7 +32,15 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont /** - * + * View Model provider for the Launch (AKA Debug) view. The PDA debugger is + * single-threaded, so there is no need for a debug target element to be visible + * in the debug view. Therefore the launch VM provider is configured with three nodes: + *- C: setvar {variable} {value} + C: setvar {frame_number} {variable} {value} R: okdiff --git a/plugins/org.eclipse.dd.examples.pda/plugin.xml b/plugins/org.eclipse.dd.examples.pda/plugin.xml index 053f2625f91..1841f1cb7fc 100644 --- a/plugins/org.eclipse.dd.examples.pda/plugin.xml +++ b/plugins/org.eclipse.dd.examples.pda/plugin.xml @@ -21,14 +21,14 @@
+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples. + *
*/ public class PDALineBreakpoint extends LineBreakpoint { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDARunToLineBreakpoint.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDARunToLineBreakpoint.java deleted file mode 100644 index eda5308d957..00000000000 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDARunToLineBreakpoint.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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 - * Bjorn Freeman-Benson - initial API and implementation - *******************************************************************************/ -package org.eclipse.dd.examples.pda.breakpoints; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IBreakpoint; - -/** - * A run to line breakpoint. - */ -public class PDARunToLineBreakpoint extends PDALineBreakpoint { - - private IFile fSourceFile; - - /** - * Constructs a run-to-line breakpoint in the given PDA program. - * - * @param resource PDA source file - * @param lineNumber line to run to - * @exception DebugException if unable to create the breakpoint - */ - public PDARunToLineBreakpoint(final IFile resource, final int lineNumber) throws DebugException { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - // associate with workspace root to avoid drawing in editor ruler - IMarker marker = ResourcesPlugin.getWorkspace().getRoot().createMarker("org.eclipse.debug.examples.core.pda.markerType.lineBreakpoint"); - setMarker(marker); - marker.setAttribute(IBreakpoint.ENABLED, Boolean.TRUE); - marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); - marker.setAttribute(IBreakpoint.ID, getModelIdentifier()); - setRegistered(false); - fSourceFile = resource; - } - }; - run(getMarkerRule(resource), runnable); - } - - /** - * Returns whether this breakpoint is a run-to-line breakpoint - * - * @return whether this breakpoint is a run-to-line breakpoint - */ - public boolean isRunToLineBreakpoint() { - return true; - } - - /** - * Returns the source file this breakpoint is contained in. - * - * @return the source file this breakpoint is contained in - */ - public IFile getSourceFile() { - return fSourceFile; - } -} diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java index ac3e9bcc80a..6a9b1353371 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/breakpoints/PDAWatchpoint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.dd.examples.pda.breakpoints; @@ -22,6 +23,10 @@ import org.eclipse.debug.core.model.IWatchpoint; /** * A watchpoint. + *+ * This class is identical to the corresponding in PDA debugger implemented in + * org.eclipse.debug.examples. + *
*/ public class PDAWatchpoint extends PDALineBreakpoint implements IWatchpoint { diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java index 587d8c993fc..6341c937efe 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunch.java @@ -15,16 +15,14 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.dd.dsf.concurrent.ConfinedToDsfExecutor; import org.eclipse.dd.dsf.concurrent.DefaultDsfExecutor; -import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.ImmediateExecutor; import org.eclipse.dd.dsf.concurrent.RequestMonitor; import org.eclipse.dd.dsf.concurrent.Sequence; import org.eclipse.dd.dsf.concurrent.ThreadSafe; import org.eclipse.dd.dsf.service.DsfServiceEventHandler; -import org.eclipse.dd.dsf.service.DsfServicesTracker; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.examples.pda.PDAPlugin; -import org.eclipse.dd.examples.pda.service.command.PDATerminatedEvent; +import org.eclipse.dd.examples.pda.service.PDATerminatedEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.Launch; @@ -32,23 +30,38 @@ import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.ITerminate; /** - * A DSF-based debugger has to override the base launch class in order to - * supply its own content providers for the debug view. + * The PDA launch object. In general, a DSF-based debugger has to override + * the base launch class in order to supply its own content providers for the + * debug view. Additionally, the PDA launch is used to monitor the state of the + * PDA debugger and to shutdown the DSF services and session belonging to the + * launch. + *+ * The PDA launch class mostly contains methods and fields that can be accessed + * on any thread. However, some fields and methods used for managing the DSF + * session need to be synchronized using the DSF executor. + *
*/ @ThreadSafe public class PDALaunch extends Launch implements ITerminate -{ +{ + // DSF executor and session. Both are created and shutdown by the launch. private final DefaultDsfExecutor fExecutor; private final DsfSession fSession; - - @ConfinedToDsfExecutor("getSession().getExecutor()") - private DsfServicesTracker fTracker; - + + // Objects used to track the status of the DSF session. private Sequence fInitializationSequence = null; private boolean fInitialized = false; private boolean fShutDown = false; + /** + * Launch constructor creates the launch for given parameters. The + * constructor also creates a DSF session and an executor, so that + * {@link #getSession()} returns a valid value, however no services + * are initialized yet. + * + * @see Launch + */ public PDALaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) { super(launchConfiguration, mode, locator); @@ -60,34 +73,68 @@ public class PDALaunch extends Launch fSession = DsfSession.startSession(fExecutor, PDAPlugin.ID_PDA_DEBUG_MODEL); } - public DsfExecutor getDsfExecutor() { return fExecutor; } - + /** + * Returns the DSF services session that belongs to this launch. This + * method will always return a DsfSession object, however if the debugger + * is shut down, the session will no longer active. + */ public DsfSession getSession() { return fSession; } + /** + * Initializes the DSF services using the specified parameters. This + * method has to be called on the executor thread in order to avoid + * synchronization issues. + */ @ConfinedToDsfExecutor("getSession().getExecutor()") public void initializeServices(String program, int requestPort, int eventPort, final RequestMonitor rm) { - fTracker = new DsfServicesTracker(PDAPlugin.getBundleContext(), fSession.getId()); + // Double-check that we're being called in the correct thread. + assert fExecutor.isInExecutorThread(); + + // Check if shutdownServices() was called already, which would be + // highly unusual, but if so we don't need to do anything except set + // the initialized flag. + synchronized(this) { + if (fShutDown) { + fInitialized = true; + return; + } + } + + // Register the launch as listener for services events. fSession.addServiceEventListener(PDALaunch.this, null); + // Initialize the fInitializationSequence attribute in a synchronized + // block, because it may be accessed in another thread by shutdown(). + // The initialization sequence is stored in a field to allow it to be + // canceled if shutdownServices() is called before the sequence + // completes. synchronized(this) { fInitializationSequence = new PDAServicesInitSequence( - getSession(), this, program, requestPort, eventPort, + getSession(), program, requestPort, eventPort, new RequestMonitor(ImmediateExecutor.getInstance(), rm) { @Override protected void handleCompleted() { + // Set the initialized flag and check whether the + // shutdown flag is set. Access the flags in a + // synchronized section as these flags can be accessed + // on any thread. boolean doShutdown = false; - synchronized (this) - { + synchronized (this) { fInitialized = true; fInitializationSequence = null; if (fShutDown) { doShutdown = true; } } + if (doShutdown) { + // If shutdownServices() was already called, start the + // shutdown sequence now. doShutdown(rm); } else { + // If there was an error in the startup sequence, + // report the error to the client. if (getStatus().getSeverity() == IStatus.ERROR) { rm.setStatus(getStatus()); } @@ -97,18 +144,30 @@ public class PDALaunch extends Launch } }); } + + // Finally, execute the sequence. getSession().getExecutor().execute(fInitializationSequence); } + /** + * Event handler for a debugger terminated event. + */ @DsfServiceEventHandler public void eventDispatched(PDATerminatedEvent event) { shutdownServices(new RequestMonitor(ImmediateExecutor.getInstance(), null)); } + /** + * Returns whether the DSF service initialization sequence has completed yet. + */ public synchronized boolean isInitialized() { return fInitialized; } + /** + * Returns whether the DSF services have been set to shut down. + * @return + */ public synchronized boolean isShutDown() { return fShutDown; } @@ -144,9 +203,13 @@ public class PDALaunch extends Launch */ @ConfinedToDsfExecutor("getSession().getExecutor()") public void shutdownServices(final RequestMonitor rm) { + // Check initialize and shutdown flags to determine if the shutdown + // sequence can be called yet. boolean doShutdown = false; synchronized (this) { if (!fInitialized && fInitializationSequence != null) { + // Launch has not yet initialized, try to cancel the + // shutdown sequence. fInitializationSequence.cancel(false); } else { doShutdown = !fShutDown && fInitialized; @@ -164,7 +227,7 @@ public class PDALaunch extends Launch @ConfinedToDsfExecutor("getSession().getExecutor()") private void doShutdown(final RequestMonitor rm) { fExecutor.execute( new PDAServicesShutdownSequence( - getDsfExecutor(), fSession.getId(), + fExecutor, fSession.getId(), new RequestMonitor(fSession.getExecutor(), rm) { @Override public void handleCompleted() { @@ -174,8 +237,6 @@ public class PDALaunch extends Launch PDAPlugin.PLUGIN_ID, -1, new IStatus[]{getStatus()}, "Session shutdown failed", null)); //$NON-NLS-1$ } // Last order of business, shutdown the dispatch queue. - fTracker.dispose(); - fTracker = null; DsfSession.endSession(fSession); // endSession takes a full dispatch to distribute the // session-ended event, finish step only after the dispatch. diff --git a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java index 0f203cf26d4..9aa119d29bd 100644 --- a/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java +++ b/plugins/org.eclipse.dd.examples.pda/src/org/eclipse/dd/examples/pda/launch/PDALaunchDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.dd.examples.pda.launch; @@ -42,7 +43,7 @@ import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2; /** - * Launches PDA program on a PDA interpretter written in Perl + * Launches PDA program on a PDA interpretter written in Perl */ public class PDALaunchDelegate extends LaunchConfigurationDelegate { @@ -59,9 +60,13 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { @Override public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { + // PDA programs do not require building. return false; } + /** + * Returns a source locator created based on the attributes in the launch configuration. + */ private ISourceLocator getSourceLocator(ILaunchConfiguration configuration) throws CoreException { String type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); if (type == null) { @@ -83,12 +88,7 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { return null; } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor) - */ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { - String program = configuration.getAttribute(PDAPlugin.ATTR_PDA_PROGRAM, (String)null); if (program == null) { abort("Perl program unspecified.", null); @@ -104,11 +104,21 @@ public class PDALaunchDelegate extends LaunchConfigurationDelegate { PDALaunch pdaLaunch = (PDALaunch)launch; initServices(pdaLaunch, program, requestPort, eventPort); } - + + /** + * Launches PDA interpreter with the given program. + * + * @param launch Launch that will contain the new process. + * @param program PDA program to use in the interpreter. + * @param requestPort The port number for connecting the request socket. + * @param eventPort The port number for connecting the events socket. + * + * @throws CoreException + */ private void launchProcess(ILaunch launch, String program, int requestPort, int eventPort) throws CoreException { List