Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.core/core/org/eclipse/debug/internal/core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java581
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java26
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties26
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java192
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java121
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java465
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java501
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java139
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java490
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java1372
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/Launcher.java120
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ListenerList.java131
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java167
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ProcessMonitor.java79
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/RuntimeProcess.java272
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java96
16 files changed, 0 insertions, 4778 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java
deleted file mode 100644
index 9db6e3fa6..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java
+++ /dev/null
@@ -1,581 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IMarkerDelta;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointListener;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.model.IBreakpoint;
-
-/**
- * The breakpoint manager manages all registered breakpoints
- * for the debug plugin. It is instantiated by the debug plugin at startup.
- *
- * @see IBreakpointManager
- */
-public class BreakpointManager implements IBreakpointManager, IResourceChangeListener {
-
- /**
- * Constants for breakpoint add/remove/change updates
- */
- private final static int ADDED = 0;
- private final static int REMOVED = 1;
- private final static int CHANGED = 2;
-
- /**
- * String constants corresponding to XML extension keys
- */
- private final static String CLASS = "class"; //$NON-NLS-1$
-
- /**
- * Attribute name for the <code>"markerType"</code> attribute of
- * a breakpoint extension.
- */
- private static final String MARKER_TYPE= "markerType"; //$NON-NLS-1$
-
- /**
- * A collection of breakpoints registered with this manager.
- */
- private Vector fBreakpoints= null;
-
- /**
- * A table of breakpoint extension points, keyed by
- * marker type
- * key: a marker type
- * value: the breakpoint extension which corresponds to that marker type
- */
- private HashMap fBreakpointExtensions;
-
- /**
- * Collection of markers that associates markers to breakpoints
- * key: a marker
- * value: the breakpoint which contains that marker
- */
- private HashMap fMarkersToBreakpoints;
-
- /**
- * Collection of breakpoint listeners.
- */
- private ListenerList fBreakpointListeners= new ListenerList(6);
-
- /**
- * Singleton resource delta visitor which handles marker
- * additions, changes, and removals.
- */
- private static BreakpointManagerVisitor fgVisitor;
-
- /**
- * Constructs a new breakpoint manager.
- */
- public BreakpointManager() {
- fMarkersToBreakpoints= new HashMap(10);
- fBreakpointExtensions = new HashMap(15);
- }
-
- /**
- * Registers this manager as a resource change listener and
- * initializes the collection of defined breakpoint extensions.
- *
- * This method should only be called on initial startup of
- * the debug plugin.
- */
- public void startup() throws CoreException {
- initBreakpointExtensions();
- deleteNonPersistedBreakpoints(ResourcesPlugin.getWorkspace().getRoot());
- getWorkspace().addResourceChangeListener(this);
- }
-
- /**
- * Loads all the breakpoints on the given resource.
- *
- * @param resource the resource which contains the breakpoints
- */
- private void loadBreakpoints(IResource resource) throws CoreException {
- IMarker[] markers= resource.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
- for (int i = 0; i < markers.length; i++) {
- IMarker marker= markers[i];
- try {
- createBreakpoint(marker);
- } catch (DebugException e) {
- DebugPlugin.log(e);
- }
- }
- }
-
- /**
- * Delete any non-persisted/invalid breakpoint markers. This is done
- * at startup rather than shutdown, since the changes made at
- * shutdown are not persisted as the workspace state has already
- * been saved. See bug 7683.
- */
- protected void deleteNonPersistedBreakpoints(IResource resource) throws CoreException {
- IMarker[] markers= resource.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE);
- final List delete = new ArrayList();
- for (int i = 0; i < markers.length; i++) {
- IMarker marker= markers[i];
- // ensure the marker has a valid model identifier attribute
- // and delete the breakpoint if not
- String modelId = marker.getAttribute(IBreakpoint.ID, null);
- if (modelId == null) {
- // marker with old/invalid format - delete
- delete.add(marker);
- } else if (!marker.getAttribute(IBreakpoint.PERSISTED, true)) {
- // the breakpoint is marked as not to be persisted,
- // schedule for deletion
- delete.add(marker);
- }
- }
- // delete any markers that are not to be restored
- if (!delete.isEmpty()) {
- IWorkspaceRunnable wr = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- ResourcesPlugin.getWorkspace().deleteMarkers((IMarker[])delete.toArray(new IMarker[delete.size()]));
- }
- };
- fork(wr);
- }
- }
-
- /**
- * Removes this manager as a resource change listener
- * and removes all breakpoint listeners.
- */
- public void shutdown() {
- getWorkspace().removeResourceChangeListener(this);
- fBreakpointListeners.removeAll();
- }
-
- /**
- * Find the defined breakpoint extensions and cache them for use in recreating
- * breakpoints from markers.
- */
- private void initBreakpointExtensions() {
- IExtensionPoint ep= DebugPlugin.getDefault().getDescriptor().getExtensionPoint(DebugPlugin.EXTENSION_POINT_BREAKPOINTS);
- IConfigurationElement[] elements = ep.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- fBreakpointExtensions.put(elements[i].getAttribute(MARKER_TYPE), elements[i]);
- }
-
- }
-
- /**
- * Convenience method to get the workspace
- */
- private IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * @see IBreakpointManager#getBreakpoint(IMarker)
- */
- public IBreakpoint getBreakpoint(IMarker marker) {
- // ensure that breakpoints are initialized
- getBreakpoints0();
- return (IBreakpoint)fMarkersToBreakpoints.get(marker);
- }
-
- /**
- * @see IBreakpointManager#getBreakpoints()
- */
- public IBreakpoint[] getBreakpoints() {
- Vector breakpoints= getBreakpoints0();
- IBreakpoint[] temp= new IBreakpoint[breakpoints.size()];
- breakpoints.copyInto(temp);
- return temp;
- }
-
- /**
- * The BreakpointManager waits to load the breakpoints
- * of the workspace until a request is made to retrieve the
- * breakpoints.
- */
- private Vector getBreakpoints0() {
- if (fBreakpoints == null) {
- initializeBreakpoints();
- }
- return fBreakpoints;
- }
-
-
-
- /**
- * @see IBreakpointManager#getBreakpoints(String)
- */
- public IBreakpoint[] getBreakpoints(String modelIdentifier) {
- Vector allBreakpoints= getBreakpoints0();
- ArrayList temp= new ArrayList(allBreakpoints.size());
- Iterator breakpoints= allBreakpoints.iterator();
- while (breakpoints.hasNext()) {
- IBreakpoint breakpoint= (IBreakpoint) breakpoints.next();
- String id= breakpoint.getModelIdentifier();
- if (id != null && id.equals(modelIdentifier)) {
- temp.add(breakpoint);
- }
- }
- return (IBreakpoint[]) temp.toArray(new IBreakpoint[temp.size()]);
- }
-
- /**
- * Loads the list of breakpoints from the breakpoint markers in the
- * workspace.
- */
- private void initializeBreakpoints() {
- setBreakpoints(new Vector(10));
- IWorkspaceRoot root= getWorkspace().getRoot();
- try {
- loadBreakpoints(root);
- } catch (CoreException ce) {
- DebugPlugin.log(ce);
- setBreakpoints(new Vector(0));
- }
- }
-
- /**
- * @see IBreakpointManager#isRegistered(IBreakpoint)
- */
- public boolean isRegistered(IBreakpoint breakpoint) {
- return getBreakpoints0().contains(breakpoint);
- }
-
-
- /**
- * @see IBreakpointManager#removeBreakpoint(IBreakpoint, boolean)
- */
- public void removeBreakpoint(IBreakpoint breakpoint, boolean delete) throws CoreException {
- if (getBreakpoints0().remove(breakpoint)) {
- fMarkersToBreakpoints.remove(breakpoint.getMarker());
- fireUpdate(breakpoint, null, REMOVED);
- if (delete) {
- breakpoint.delete();
- } else {
- // if the breakpoint is being removed from the manager
- // because the project is closing, the breakpoint should
- // remain as registered, otherwise, the breakpoint should
- // be marked as deregistered
- IMarker marker = breakpoint.getMarker();
- if (marker.exists()) {
- IProject project = breakpoint.getMarker().getResource().getProject();
- if (project == null || project.isOpen()) {
- breakpoint.setRegistered(false);
- }
- }
- }
- }
- }
-
- /**
- * Create a breakpoint for the given marker. The created breakpoint
- * is of the type specified in the breakpoint extension associated
- * with the given marker type.
- *
- * @return a breakpoint on this marker
- * @exception DebugException if breakpoint creation fails. Reasons for
- * failure include:
- * <ol>
- * <li>The breakpoint manager cannot determine what kind of breakpoint
- * to instantiate for the given marker type</li>
- * <li>A lower level exception occurred while accessing the given marker</li>
- * </ol>
- */
- private IBreakpoint createBreakpoint(IMarker marker) throws DebugException {
- IBreakpoint breakpoint= (IBreakpoint) fMarkersToBreakpoints.get(marker);
- if (breakpoint != null) {
- return breakpoint;
- }
- try {
- IConfigurationElement config = (IConfigurationElement)fBreakpointExtensions.get(marker.getType());
- if (config == null) {
- throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.CONFIGURATION_INVALID, MessageFormat.format(DebugCoreMessages.getString("BreakpointManager.Missing_breakpoint_definition"), new String[] {marker.getType()}), null)); //$NON-NLS-1$
- }
- breakpoint = (IBreakpoint)config.createExecutableExtension(CLASS);
- breakpoint.setMarker(marker);
- if (breakpoint.isRegistered()) {
- addBreakpoint(breakpoint);
- }
- return breakpoint;
- } catch (CoreException e) {
- throw new DebugException(e.getStatus());
- }
- }
-
- /**
- * @see IBreakpointManager#addBreakpoint(IBreakpoint)
- */
- public void addBreakpoint(IBreakpoint breakpoint) throws CoreException {
- if (!getBreakpoints0().contains(breakpoint)) {
- verifyBreakpoint(breakpoint);
- // set the registered property before adding to the collection
- // such that a change notification is not fired
- breakpoint.setRegistered(true);
- getBreakpoints0().add(breakpoint);
- fMarkersToBreakpoints.put(breakpoint.getMarker(), breakpoint);
- fireUpdate(breakpoint, null, ADDED);
- }
- }
-
- /**
- * @see IBreakpointManager#fireBreakpointChanged(IBreakpoint)
- */
- public void fireBreakpointChanged(IBreakpoint breakpoint) {
- if (getBreakpoints0().contains(breakpoint)) {
- fireUpdate(breakpoint, null, CHANGED);
- }
- }
-
- /**
- * Verifies that the breakpoint marker has the minimal required attributes,
- * and throws a debug exception if not.
- */
- private void verifyBreakpoint(IBreakpoint breakpoint) throws DebugException {
- try {
- String id= breakpoint.getModelIdentifier();
- if (id == null) {
- throw new DebugException(new Status(IStatus.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.CONFIGURATION_INVALID, DebugCoreMessages.getString("BreakpointManager.Missing_model_identifier"), null)); //$NON-NLS-1$
- }
- } catch (CoreException e) {
- throw new DebugException(e.getStatus());
- }
- }
-
- /**
- * A resource has changed. Traverses the delta for breakpoint changes.
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (!isRestored()) {
- // if breakpoints have not been restored, deltas
- // should not be processed (we are unable to restore
- // breakpoints in a resource callback, as that might
- // cause the resource tree to be modififed, which is
- // not allowed during notification).
- // @see bug 9327
- return;
- }
- IResourceDelta delta= event.getDelta();
- if (delta != null) {
- try {
- if (fgVisitor == null) {
- fgVisitor= new BreakpointManagerVisitor();
- }
- delta.accept(fgVisitor);
- } catch (CoreException ce) {
- DebugPlugin.log(ce);
- }
- }
- }
-
- /**
- * Returns whether breakpoints have been restored
- * since the workbench was started.
- *
- * @return whether breakpoints have been restored
- * since the workbench was started
- */
- protected boolean isRestored() {
- return fBreakpoints != null;
- }
-
- /**
- * A project has been opened or closed. Updates the breakpoints for
- * that project
- */
- private void handleProjectResourceOpenStateChange(IResource project) {
- if (!project.isAccessible()) {
- //closed
- Enumeration breakpoints= getBreakpoints0().elements();
- while (breakpoints.hasMoreElements()) {
- IBreakpoint breakpoint= (IBreakpoint) breakpoints.nextElement();
- IResource markerResource= breakpoint.getMarker().getResource();
- if (project.getFullPath().isPrefixOf(markerResource.getFullPath())) {
- try {
- removeBreakpoint(breakpoint, false);
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- }
- return;
- } else {
- try {
- loadBreakpoints(project);
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- }
-
- /**
- * Visitor for handling resource deltas
- */
- class BreakpointManagerVisitor implements IResourceDeltaVisitor {
- /**
- * @see IResourceDeltaVisitor#visit(IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) {
- if (delta == null) {
- return false;
- }
- if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
- handleProjectResourceOpenStateChange(delta.getResource());
- return false;
- }
- IMarkerDelta[] markerDeltas= delta.getMarkerDeltas();
- for (int i= 0; i < markerDeltas.length; i++) {
- IMarkerDelta markerDelta= markerDeltas[i];
- if (markerDelta.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
- switch (markerDelta.getKind()) {
- case IResourceDelta.ADDED :
- handleAddBreakpoint(delta, markerDelta.getMarker(), markerDelta);
- break;
- case IResourceDelta.REMOVED :
- handleRemoveBreakpoint(markerDelta.getMarker(), markerDelta);
- break;
- case IResourceDelta.CHANGED :
- handleChangeBreakpoint(markerDelta.getMarker(), markerDelta);
- break;
- }
- }
- }
-
- return true;
- }
-
- /**
- * Wrapper for handling adds
- */
- protected void handleAddBreakpoint(IResourceDelta rDelta, final IMarker marker, IMarkerDelta mDelta) {
- if (0 != (rDelta.getFlags() & IResourceDelta.MOVED_FROM)) {
- // This breakpoint has actually been moved - already removed
- // from the Breakpoint manager during the remove callback
- // Delete the marker associated with the new resource
- IWorkspaceRunnable wRunnable= new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) {
- try {
- marker.delete();
- } catch (CoreException ce) {
- DebugPlugin.log(ce);
- }
- }
- };
- fork(wRunnable);
- } else {
- // do nothing - we do not add until explicitly added
- }
- }
-
- /**
- * Wrapper for handling removes
- */
- protected void handleRemoveBreakpoint(IMarker marker, IMarkerDelta delta) {
- IBreakpoint breakpoint= getBreakpoint(marker);
- if (breakpoint != null) {
- try {
- removeBreakpoint(breakpoint, false);
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- }
-
- /**
- * Wrapper for handling changes
- */
- protected void handleChangeBreakpoint(IMarker marker, IMarkerDelta delta) {
- final IBreakpoint breakpoint= getBreakpoint(marker);
- if (breakpoint != null && isRegistered(breakpoint)) {
- fireUpdate(breakpoint, delta, CHANGED);
- }
- }
- }
-
- /**
- * @see IBreakpointManager#addBreakpointListener(IBreakpointListener)
- */
- public void addBreakpointListener(IBreakpointListener listener) {
- fBreakpointListeners.add(listener);
- }
-
- /**
- * @see IBreakpointManager#removeBreakpointListener(IBreakpointListener)
- */
- public void removeBreakpointListener(IBreakpointListener listener) {
- fBreakpointListeners.remove(listener);
- }
-
- /**
- * Notifies listeners of the add/remove/change
- */
- private void fireUpdate(IBreakpoint breakpoint, IMarkerDelta delta, int update) {
- Object[] copiedListeners= fBreakpointListeners.getListeners();
- for (int i= 0; i < copiedListeners.length; i++) {
- IBreakpointListener listener = (IBreakpointListener)copiedListeners[i];
- switch (update) {
- case ADDED:
- listener.breakpointAdded(breakpoint);
- break;
- case REMOVED:
- listener.breakpointRemoved(breakpoint, delta);
- break;
- case CHANGED:
- listener.breakpointChanged(breakpoint, delta);
- break;
- }
- }
- }
-
- protected void setBreakpoints(Vector breakpoints) {
- fBreakpoints = breakpoints;
- }
-
- protected void fork(final IWorkspaceRunnable wRunnable) {
- Runnable runnable= new Runnable() {
- public void run() {
- try {
- getWorkspace().run(wRunnable, null);
- } catch (CoreException ce) {
- DebugPlugin.log(ce);
- }
- }
- };
- new Thread(runnable).start();
- }
-
- /**
- * @see IBreakpointManager#hasBreakpoints()
- */
- public boolean hasBreakpoints() {
- return !getBreakpoints0().isEmpty();
- }
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
deleted file mode 100644
index 4953856fc..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package org.eclipse.debug.internal.core;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class DebugCoreMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.debug.internal.core.DebugCoreMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private DebugCoreMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
deleted file mode 100644
index 2ba828f87..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugCoreMessages.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-Breakpoint.no_associated_marker=Breakpoint does not have an associated marker.
-
-BreakpointManager.Missing_breakpoint_definition=Missing breakpoint definition for marker type {0}
-BreakpointManager.Missing_model_identifier=Breakpoint missing debug model identifier
-InputStreamMonitor.label=Input Stream Monitor
-OutputStreamMonitor.label=Output Stream Monitor
-ProcessMonitor.label=Process Monitor
-RuntimeProcess.terminate_failed=Terminate failed
-Launch.terminate_failed=Terminate failed
-LaunchConfiguration.Failed_to_delete_launch_configuration._1=Failed to delete launch configuration.
-LaunchConfigurationInfo.Invalid_launch_configuration_XML._10=Invalid launch configuration XML.
-LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_boolean._3=Attribute {0} is not of type boolean.
-LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_int._2=Attribute {0} is not of type int.
-LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.lang.String._1=Attribute {0} is not of type java.lang.String.
-LaunchConfigurationWorkingCopy.{0}_occurred_generating_launch_configuration_XML._1={0} occurred generating launch configuration XML.
-Invalid_launch_configuration_index._18=Invalid launch configuration index.
-LaunchManager.{0}_occurred_while_reading_launch_configuration_index._11={0} occurred while reading launch configuration index.
-LaunchManager.{0}_occurred_generating_launch_configuration_index._7={0} occurred generating launch configuration index.
-LaunchManager.Launch_configuration_does_not_exist._6=Launch configuration does not exist.
-LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1={0} occurred while reading launch configuration file.
-DebugEvent.illegal_kind=kind is not one of the allowed constants, see IDebugEventConstants
-DebugEvent.illegal_detail=detail is not one of the allowed constants, see IDebugEventConstants
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java
deleted file mode 100644
index 7fe23da91..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ExpressionManager.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.IExpressionListener;
-import org.eclipse.debug.core.IExpressionManager;
-import org.eclipse.debug.core.model.IExpression;
-
-/**
- * The expression manager manages all registered expressions
- * for the debug plugin. It is instantiated by the debug plugin
- * at startup.
- *
- * [XXX: expression persistence not yet implemented]
- *
- * @see IExpressionManager
- */
-public class ExpressionManager implements IExpressionManager, IDebugEventSetListener {
-
- /**
- * Collection of registered expressions.
- */
- private Vector fExpressions = new Vector(10);
-
- /**
- * List of expression listeners
- */
- private ListenerList fListeners = new ListenerList(2);
-
- /**
- * @see IExpressionManager#addExpression(IExpression, String)
- */
- public void addExpression(IExpression expression) {
- if (getExpressions0().indexOf(expression) == -1) {
- getExpressions0().add(expression);
- fireExpressionAdded(expression);
- }
- }
-
- /**
- * @see IExpressionManager#getExpressions()
- */
- public IExpression[] getExpressions() {
- Vector expressions = getExpressions0();
- IExpression[] temp= new IExpression[expressions.size()];
- expressions.copyInto(temp);
- return temp;
- }
-
- /**
- * @see IExpressionManager#getExpressions(String)
- */
- public IExpression[] getExpressions(String modelIdentifier) {
- Vector expressions = getExpressions0();
- ArrayList temp= new ArrayList(expressions.size());
- Iterator iter= expressions.iterator();
- while (iter.hasNext()) {
- IExpression expression= (IExpression) iter.next();
- String id= expression.getModelIdentifier();
- if (id != null && id.equals(modelIdentifier)) {
- temp.add(expression);
- }
- }
- return (IExpression[]) temp.toArray(new IExpression[temp.size()]);
- }
-
- /**
- * @see IExpressionManager#removeExpression(IExpression)
- */
- public void removeExpression(IExpression expression) {
- if (getExpressions0().indexOf(expression) >= 0) {
- getExpressions0().remove(expression);
- expression.dispose();
- fireExpressionRemoved(expression);
- }
- }
-
- /**
- * @see IExpressionManager#addExpressionListener(IExpressionListener)
- */
- public void addExpressionListener(IExpressionListener listener) {
- fListeners.add(listener);
- }
-
- /**
- * @see IExpressionManager#removeExpressionListener(IExpressionListener)
- */
- public void removeExpressionListener(IExpressionListener listener) {
- fListeners.remove(listener);
- }
-
- /**
- * Called be the debug plug-in when starting up.
- */
- public void startup() {
- DebugPlugin.getDefault().addDebugEventListener(this);
- }
-
- /**
- * Called by the debug plug-in when shutting down.
- */
- public void shutdown() {
- DebugPlugin.getDefault().removeDebugEventListener(this);
- }
-
- /**
- * Returns the list of registered expressions as
- * a vector.
- *
- * @return vector of registered expressions
- */
- protected Vector getExpressions0() {
- return fExpressions;
- }
-
- /**
- * @see IDebugEventListener#handleDebugEvent(DebugEvent)
- */
- public void handleDebugEvents(DebugEvent[] events) {
- for (int i = 0; i < events.length; i++) {
- DebugEvent event = events[i];
- if (event.getSource() instanceof IExpression) {
- switch (event.getKind()) {
- case DebugEvent.CHANGE:
- fireExpressionChanged((IExpression)event.getSource());
- break;
- case DebugEvent.TERMINATE:
- removeExpression((IExpression)event.getSource());
- break;
- default:
- break;
- }
- }
- }
- }
-
- /**
- * Notifies listeners that the given expression has been
- * added.
- *
- * @param expression the newly added expression
- */
- protected void fireExpressionAdded(IExpression expression) {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IExpressionListener)listeners[i]).expressionAdded(expression);
- }
- }
-
- /**
- * Notifies listeners that the given expression has been
- * removed.
- *
- * @param expression the removed expression
- */
- protected void fireExpressionRemoved(IExpression expression) {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IExpressionListener)listeners[i]).expressionRemoved(expression);
- }
- }
-
- /**
- * Notifies listeners that the given expression has changed.
- *
- * @param expression the changed expression
- */
- protected void fireExpressionChanged(IExpression expression) {
- Object[] listeners = fListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ((IExpressionListener)listeners[i]).expressionChanged(expression);
- }
- }
-
- /**
- * @see IExpressionManager#hasExpressions()
- */
- public boolean hasExpressions() {
- return !getExpressions0().isEmpty();
- }
-
-}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java
deleted file mode 100644
index 6abddc3e4..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/InputStreamMonitor.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Vector;
-
-import org.eclipse.debug.core.DebugPlugin;
-
-/**
- * Writes to the input stream of a system process,
- * queueing output if the stream is blocked.
- *
- * The input stream monitor writes to system in via
- * an output stream.
- */
-public class InputStreamMonitor {
-
- /**
- * The stream which is being written to (connected to system in).
- */
- private OutputStream fStream;
- /**
- * The queue of output.
- */
- private Vector fQueue;
- /**
- * The thread which writes to the stream.
- */
- private Thread fThread;
- /**
- * A lock for ensuring that writes to the queue are contiguous
- */
- private Object fLock;
-
- /**
- * Creates an input stream monitor which writes
- * to system in via the given output stream.
- */
- public InputStreamMonitor(OutputStream stream) {
- fStream= stream;
- fQueue= new Vector();
- fLock= new Object();
- }
-
- /**
- * Appends the given text to the stream, or
- * queues the text to be written at a later time
- * if the stream is blocked.
- */
- public void write(String text) {
- synchronized(fLock) {
- fQueue.add(text);
- fLock.notifyAll();
- }
- }
-
- /**
- * Starts a thread which writes the stream.
- */
- public void startMonitoring() {
- if (fThread == null) {
- fThread= new Thread(new Runnable() {
- public void run() {
- write();
- }
- }, DebugCoreMessages.getString("InputStreamMonitor.label")); //$NON-NLS-1$
- fThread.start();
- }
- }
-
- /**
- * Close all communications between this
- * monitor and the underlying stream.
- */
- public void close() {
- if (fThread != null) {
- Thread thread= fThread;
- fThread= null;
- thread.interrupt();
- }
- }
-
- /**
- * Continuously writes to the stream.
- */
- protected void write() {
- while (fThread != null) {
- writeNext();
- }
- }
-
- /**
- * Write the text in the queue to the stream.
- */
- protected void writeNext() {
- while (!fQueue.isEmpty()) {
- String text = (String)fQueue.firstElement();
- fQueue.removeElementAt(0);
- try {
- if (fStream != null) {
- fStream.write(text.getBytes());
- fStream.flush();
- }
- } catch (IOException e) {
- DebugPlugin.log(e);
- }
- }
- try {
- synchronized(fLock) {
- fLock.wait();
- }
- } catch (InterruptedException e) {
- }
- }
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
deleted file mode 100644
index 6bdd542d0..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java
+++ /dev/null
@@ -1,465 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.apache.xerces.dom.DocumentImpl;
-import org.apache.xml.serialize.Method;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
-import org.eclipse.core.resources.IContainer;
-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.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.Launch;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
-import org.eclipse.debug.core.model.IPersistableSourceLocator;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Launch configuration handle.
- *
- * @see ILaunchConfiguration
- */
-public class LaunchConfiguration extends PlatformObject implements ILaunchConfiguration {
-
- /**
- * Location this configuration is stored in. This
- * is the key for a launch configuration handle.
- */
- private IPath fLocation;
-
- /**
- * Constructs a launch configuration in the given location.
- *
- * @param location path to where this launch configuration's
- * underlying file is located
- */
- protected LaunchConfiguration(IPath location) {
- setLocation(location);
- }
-
- /**
- * Constructs a launch configuration from the given
- * memento.
- *
- * @param memento launch configuration memento
- * @exception CoreException if the memento is invalid or
- * an exception occurrs reading the memento
- */
- protected LaunchConfiguration(String memento) throws CoreException {
- Exception ex = null;
- try {
- Element root = null;
- DocumentBuilder parser =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- StringReader reader = new StringReader(memento);
- InputSource source = new InputSource(reader);
- root = parser.parse(source).getDocumentElement();
-
- String localString = root.getAttribute("local");
- String path = root.getAttribute("path");
-
- String message = null;
- if (path == null) {
- message = "Invalid launch configuration memento: missing path attribute.";
- } else if (localString == null) {
- message = "Invalid launch configuration memento: missing local attribute.";
- }
- if (message != null) {
- IStatus s = newStatus(message, DebugException.INTERNAL_ERROR, null);
- throw new CoreException(s);
- }
-
- IPath location = null;
- boolean local = (Boolean.valueOf(localString)).booleanValue();
- if (local) {
- location = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.append(path);
- } else {
- location = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(path);
- }
- setLocation(location);
- return;
- } catch (ParserConfigurationException e) {
- ex = e;
- } catch (SAXException e) {
- ex = e;
- } catch (IOException e) {
- ex = e;
- }
- IStatus s = newStatus("Exception occurred parsing memento.", DebugException.INTERNAL_ERROR, ex);
- throw new CoreException(s);
- }
-
- /**
- * Creates and returns a new error status based on
- * the given mesasge, code, and exception.
- *
- * @param message error message
- * @param code error code
- * @param e exception or <code>null</code>
- * @return status
- */
- protected IStatus newStatus(String message, int code, Throwable e) {
- return new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, code, message, e);
- }
-
- /**
- * @see ILaunchConfiguration#launch(String, IProgressMonitor)
- */
- public ILaunch launch(String mode, IProgressMonitor monitor) throws CoreException {
- ILaunch launch = new Launch(this, mode, null);
- getLaunchManager().addLaunch(launch);
- getDelegate().launch(this, mode, launch, monitor);
- if (monitor != null && monitor.isCanceled()) {
- getLaunchManager().removeLaunch(launch);
- } else {
- initializeSourceLocator(launch);
- }
- return launch;
- }
-
- /**
- * Set the source locator to use with the launch, if specified
- * by this configuration.
- *
- * @param launch the launch on which to set the source locator
- */
- protected void initializeSourceLocator(ILaunch launch) throws CoreException {
- if (launch.getSourceLocator() == null) {
- String type = getAttribute(ATTR_SOURCE_LOCATOR_ID, (String)null);
- if (type != null) {
- IPersistableSourceLocator locator = getLaunchManager().newSourceLocator(type);
- String memento = getAttribute(ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
- if (memento == null) {
- locator.initializeDefaults(this);
- } else {
- locator.initiatlizeFromMemento(memento);
- }
- launch.setSourceLocator(locator);
- }
- }
- }
-
- /**
- * @see ILaunchConfiguration#supportsMode(String)
- */
- public boolean supportsMode(String mode) throws CoreException {
- return getType().supportsMode(mode);
- }
-
- /**
- * A configuration's name is that of the last segment
- * in it's location (subtract the ".launch" extension).
- *
- * @see ILaunchConfiguration#getName()
- */
- public String getName() {
- return getLastLocationSegment();
- }
-
- private String getLastLocationSegment() {
- String name = getLocation().lastSegment();
- name = name.substring(0, name.length() - (LAUNCH_CONFIGURATION_FILE_EXTENSION.length() + 1));
- return name;
- }
-
- /**
- * @see ILaunchConfiguration#getLocation()
- */
- public IPath getLocation() {
- return fLocation;
- }
-
- /**
- * Sets the location of this configuration's underlying
- * file.
- *
- * @param location the location of this configuration's underlying
- * file
- */
- private void setLocation(IPath location) {
- fLocation = location;
- }
-
- /**
- * @see ILaunchConfiguration#exists()
- */
- public boolean exists() {
- IFile file = getFile();
- if (file == null) {
- return getLocation().toFile().exists();
- } else {
- return file.exists();
- }
- }
-
- /**
- * @see ILaunchConfiguration#getAttribute(String, int)
- */
- public int getAttribute(String attributeName, int defaultValue) throws CoreException {
- return getInfo().getIntAttribute(attributeName, defaultValue);
- }
-
- /**
- * @see ILaunchConfiguration#getAttribute(String, String)
- */
- public String getAttribute(String attributeName, String defaultValue) throws CoreException {
- return getInfo().getStringAttribute(attributeName, defaultValue);
- }
-
- /**
- * @see ILaunchConfiguration#getAttribute(String, boolean)
- */
- public boolean getAttribute(String attributeName, boolean defaultValue) throws CoreException {
- return getInfo().getBooleanAttribute(attributeName, defaultValue);
- }
-
- /**
- * @see ILaunchConfiguration#getAttribute(String, List)
- */
- public List getAttribute(String attributeName, List defaultValue) throws CoreException {
- return getInfo().getListAttribute(attributeName, defaultValue);
- }
-
- /**
- * @see ILaunchConfiguration#getAttribute(String, Map)
- */
- public Map getAttribute(String attributeName, Map defaultValue) throws CoreException {
- return getInfo().getMapAttribute(attributeName, defaultValue);
- }
-
- /**
- * @see ILaunchConfiguration#getType()
- */
- public ILaunchConfigurationType getType() throws CoreException {
- return getInfo().getType();
- }
-
- /**
- * @see ILaunchConfiguration#isLocal()
- */
- public boolean isLocal() {
- return getFile() == null;
- }
-
- /**
- * @see ILaunchConfiguration#getWorkingCopy()
- */
- public ILaunchConfigurationWorkingCopy getWorkingCopy() throws CoreException {
- return new LaunchConfigurationWorkingCopy(this);
- }
-
- /**
- * @see ILaunchConfiguration#copy(String name)
- */
- public ILaunchConfigurationWorkingCopy copy(String name) throws CoreException {
- ILaunchConfigurationWorkingCopy copy = new LaunchConfigurationWorkingCopy(this, name);
- return copy;
- }
-
- /**
- * @see ILaunchConfiguration#isWorkingCopy()
- */
- public boolean isWorkingCopy() {
- return false;
- }
-
- /**
- * @see ILaunchConfiguration#delete()
- */
- public void delete() throws CoreException {
- if (exists()) {
- if (isLocal()) {
- if (!(getLocation().toFile().delete())) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, DebugCoreMessages.getString("LaunchConfiguration.Failed_to_delete_launch_configuration._1"), null) //$NON-NLS-1$
- );
- }
- // manually update the launch manager cache since there
- // will be no resource delta
- getLaunchManager().launchConfigurationDeleted(this);
- } else {
- // delete the resource using IFile API such that
- // resource deltas are fired.
- IResource file = getFile();
- if (file != null) {
- file.delete(true, null);
- } else {
- // Error - the exists test passed, but could not locate file
- }
- }
- }
- }
-
- /**
- * Returns the info object containing the attributes
- * of this configuration
- *
- * @return info for this handle
- * @exception CoreException if unable to retrieve the
- * info object
- */
- protected LaunchConfigurationInfo getInfo() throws CoreException {
- return getLaunchManager().getInfo(this);
- }
-
- /**
- * Returns the launch configuration delegate for this
- * launch configuration.
- *
- * @return launch configuration delegate
- * @exception CoreException if the delegate was unable
- * to be created
- */
- protected ILaunchConfigurationDelegate getDelegate() throws CoreException {
- return ((LaunchConfigurationType)getType()).getDelegate();
- }
-
- /**
- * Returns the launch manager
- *
- * @return launch manager
- */
- protected LaunchManager getLaunchManager() {
- return (LaunchManager)DebugPlugin.getDefault().getLaunchManager();
- }
-
- /**
- * @see ILaunchConfiguration#getMemento()
- */
- public String getMemento() throws CoreException {
- IPath relativePath = null;
- if (isLocal()) {
- IPath rootPath = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- IPath configPath = getLocation();
- relativePath = configPath.removeFirstSegments(rootPath.segmentCount());
- } else {
- relativePath = getFile().getFullPath();
- }
- relativePath = relativePath.setDevice(null);
-
- Document doc = new DocumentImpl();
- Element node = doc.createElement("launchConfiguration");
- node.setAttribute("local", (new Boolean(isLocal())).toString());
- node.setAttribute("path", relativePath.toString());
-
- // produce a String output
- StringWriter writer = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- writer,
- format);
-
- try {
- serializer.asDOMSerializer().serialize(node);
- } catch (IOException e) {
- IStatus status = newStatus("Exception occurred creating launch configuration memento.", DebugException.INTERNAL_ERROR, e);
- throw new CoreException(status);
- }
- return writer.toString();
- }
-
- /**
- * @see ILaunchConfiguration#getFile()
- */
- public IFile getFile() {
- return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(getLocation());
- }
-
- /**
- * @see ILaunchConfiguration#contentsEqual(ILaunchConfiguration)
- */
- public boolean contentsEqual(ILaunchConfiguration object) {
- try {
- if (object instanceof LaunchConfiguration) {
- LaunchConfiguration otherConfig = (LaunchConfiguration) object;
- return getName().equals(otherConfig.getName())
- && getType().equals(otherConfig.getType())
- && getLocation().equals(otherConfig.getLocation())
- && getInfo().equals(otherConfig.getInfo());
- }
- return false;
- } catch (CoreException ce) {
- return false;
- }
- }
-
- /**
- * Returns whether this configuration is equal to the
- * given configuration. Two configurations are equal if
- * they are stored in the same location (and neither one
- * is a working copy).
- *
- * @return whether this configuration is equal to the
- * given configuration
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
- if (object instanceof ILaunchConfiguration) {
- if (isWorkingCopy()) {
- return this == object;
- }
- ILaunchConfiguration config = (ILaunchConfiguration) object;
- if (!config.isWorkingCopy()) {
- return config.getLocation().equals(getLocation());
- }
- }
- return false;
- }
-
- /**
- * @see Object#hashCode()
- */
- public int hashCode() {
- return getLocation().hashCode();
- }
-
- /**
- * Returns the container this launch configuration is
- * stored in, or <code>null</code> if this launch configuration
- * is stored locally.
- *
- * @return the container this launch configuration is
- * stored in, or <code>null</code> if this launch configuration
- * is stored locally
- */
- protected IContainer getContainer() {
- IFile file = getFile();
- if (file != null) {
- return file.getParent();
- }
- return null;
- }
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java
deleted file mode 100644
index 41d5bc4c3..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationInfo.java
+++ /dev/null
@@ -1,501 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.xerces.dom.DocumentImpl;
-import org.apache.xml.serialize.Method;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * The information associated with a launch configuration
- * handle.
- */
-public class LaunchConfigurationInfo {
-
- /**
- * This configurations attribute table.
- * Keys are <code>String</code>s and values
- * are one of <code>String</code>, <code>Integer</code>,
- * or <code>Boolean</code>.
- */
- private HashMap fAttributes;
-
- /**
- * This launch configuration's type
- */
- private ILaunchConfigurationType fType;
-
- /**
- * Constructs a new empty info
- */
- protected LaunchConfigurationInfo() {
- setAttributeTable(new HashMap(10));
- }
-
- /**
- * Returns this configuration's attribute table.
- *
- * @return attribute table
- */
- private HashMap getAttributeTable() {
- return fAttributes;
- }
-
- /**
- * Sets this configuration's attribute table.
- *
- * @param table attribute table
- */
- private void setAttributeTable(HashMap table) {
- fAttributes = table;
- }
-
- /**
- * Returns the <code>String</code> attribute with the
- * given key or the given default value if undefined.
- *
- * @return attribute specified by given key or the defaultValue
- * if undefined
- * @exception if the attribute with the given key exists
- * but is not a <code>String</code>
- */
- protected String getStringAttribute(String key, String defaultValue) throws CoreException {
- Object attr = getAttributeTable().get(key);
- if (attr != null) {
- if (attr instanceof String) {
- return (String)attr;
- } else {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.lang.String._1"), new String[] {key}), null //$NON-NLS-1$
- )
- );
- }
- }
- return defaultValue;
- }
-
- /**
- * Returns the <code>int</code> attribute with the
- * given key or the given default value if undefined.
- *
- * @return attribute specified by given key or the defaultValue
- * if undefined
- * @exception if the attribute with the given key exists
- * but is not an <code>int</code>
- */
- protected int getIntAttribute(String key, int defaultValue) throws CoreException {
- Object attr = getAttributeTable().get(key);
- if (attr != null) {
- if (attr instanceof Integer) {
- return ((Integer)attr).intValue();
- } else {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_int._2"), new String[] {key}), null //$NON-NLS-1$
- )
- );
- }
- }
- return defaultValue;
- }
-
- /**
- * Returns the <code>boolean</code> attribute with the
- * given key or the given default value if undefined.
- *
- * @return attribute specified by given key or the defaultValue
- * if undefined
- * @exception if the attribute with the given key exists
- * but is not a <code>boolean</code>
- */
- protected boolean getBooleanAttribute(String key, boolean defaultValue) throws CoreException {
- Object attr = getAttributeTable().get(key);
- if (attr != null) {
- if (attr instanceof Boolean) {
- return ((Boolean)attr).booleanValue();
- } else {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_boolean._3"), new String[] {key}), null //$NON-NLS-1$
- )
- );
- }
- }
- return defaultValue;
- }
-
- /**
- * Returns the <code>java.util.List</code> attribute with the
- * given key or the given default value if undefined.
- *
- * @return attribute specified by given key or the defaultValue
- * if undefined
- * @exception if the attribute with the given key exists
- * but is not a <code>java.util.List</code>
- */
- protected List getListAttribute(String key, List defaultValue) throws CoreException {
- Object attr = getAttributeTable().get(key);
- if (attr != null) {
- if (attr instanceof List) {
- return (List)attr;
- } else {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.util.List._1"), new String[] {key}), null //$NON-NLS-1$
- )
- );
- }
- }
- return defaultValue;
- }
-
- /**
- * Returns the <code>java.util.Map</code> attribute with the
- * given key or the given default value if undefined.
- *
- * @return attribute specified by given key or the defaultValue
- * if undefined
- * @exception if the attribute with the given key exists
- * but is not a <code>java.util.Map</code>
- */
- protected Map getMapAttribute(String key, Map defaultValue) throws CoreException {
- Object attr = getAttributeTable().get(key);
- if (attr != null) {
- if (attr instanceof Map) {
- return (Map)attr;
- } else {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationInfo.Attribute_{0}_is_not_of_type_java.util.Map._1"), new String[] {key}), null //$NON-NLS-1$
- )
- );
- }
- }
- return defaultValue;
- }
-
- /**
- * Sets this configuration's type.
- *
- * @param type launch configuration type
- */
- protected void setType(ILaunchConfigurationType type) {
- fType = type;
- }
-
- /**
- * Returns this configuration's type.
- *
- * @return launch configuration type
- */
- protected ILaunchConfigurationType getType() {
- return fType;
- }
-
-
- /**
- * Returns a copy of this info object
- *
- * @return copy of this info
- */
- protected LaunchConfigurationInfo getCopy() {
- LaunchConfigurationInfo copy = new LaunchConfigurationInfo();
- copy.setType(getType());
- copy.setAttributeTable((HashMap)getAttributeTable().clone());
- return copy;
- }
-
- /**
- * Sets the given attribute to the given value. Only
- * working copy's should use this API.
- *
- * @param key attribute key
- * @param value attribuet value
- */
- protected void setAttribute(String key, Object value) {
- if (value == null) {
- getAttributeTable().remove(key);
- } else {
- getAttributeTable().put(key, value);
- }
- }
-
- /**
- * Returns the content of this info as XML
- *
- * @return the content of this info as XML
- * @exception IOException if an exception occurs creating the XML
- */
- protected String getAsXML() throws IOException {
-
- Document doc = new DocumentImpl();
- Element configRootElement = doc.createElement("launchConfiguration"); //$NON-NLS-1$
- doc.appendChild(configRootElement);
-
- configRootElement.setAttribute("type", getType().getIdentifier()); //$NON-NLS-1$
-
- Iterator keys = getAttributeTable().keySet().iterator();
- while (keys.hasNext()) {
- String key = (String)keys.next();
- Object value = getAttributeTable().get(key);
- if (value == null) {
- continue;
- }
- Element element = null;
- String valueString = null;
- if (value instanceof String) {
- valueString = (String)value;
- element = createKeyValueElement(doc, "stringAttribute", key, valueString); //$NON-NLS-1$
- } else if (value instanceof Integer) {
- valueString = ((Integer)value).toString();
- element = createKeyValueElement(doc, "intAttribute", key, valueString); //$NON-NLS-1$
- } else if (value instanceof Boolean) {
- valueString = ((Boolean)value).toString();
- element = createKeyValueElement(doc, "booleanAttribute", key, valueString); //$NON-NLS-1$
- } else if (value instanceof List) {
- element = createListElement(doc, "listAttribute", key, (List)value); //$NON-NLS-1$
- } else if (value instanceof Map) {
- element = createMapElement(doc, "mapAttribute", key, (Map)value); //$NON-NLS-1$
- }
- configRootElement.appendChild(element);
- }
-
- // produce a String output
- StringWriter writer = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- writer,
- format);
- serializer.asDOMSerializer().serialize(doc);
- return writer.toString();
-
- }
-
- /**
- * Helper method that creates a 'key value' element of the specified type with the
- * specified attribute values.
- */
- protected Element createKeyValueElement(Document doc, String elementType, String key, String value) {
- Element element = doc.createElement(elementType);
- element.setAttribute("key", key);
- element.setAttribute("value", value);
- return element;
- }
-
- protected Element createListElement(Document doc, String elementType, String listKey, List list) {
- Element listElement = doc.createElement(elementType);
- listElement.setAttribute("key", listKey);
- Iterator iterator = list.iterator();
- while (iterator.hasNext()) {
- String value = (String) iterator.next();
- Element element = doc.createElement("listEntry");
- element.setAttribute("value", value);
- listElement.appendChild(element);
- }
- return listElement;
- }
-
- protected Element createMapElement(Document doc, String elementType, String mapKey, Map map) {
- Element mapElement = doc.createElement(elementType);
- mapElement.setAttribute("key", mapKey);
- Iterator iterator = map.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String) iterator.next();
- String value = (String) map.get(key);
- Element element = doc.createElement("mapEntry");
- element.setAttribute("key", key);
- element.setAttribute("value", value);
- mapElement.appendChild(element);
- }
- return mapElement;
- }
-
- protected void initializeFromXML(Element root) throws CoreException {
- if (!root.getNodeName().equalsIgnoreCase("launchConfiguration")) { //$NON-NLS-1$
- throw getInvalidFormatDebugException();
- }
-
- // read type
- String id = root.getAttribute("type"); //$NON-NLS-1$
- if (id == null) {
- throw getInvalidFormatDebugException();
- } else {
- ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(id);
- if (type == null) {
- throw getInvalidFormatDebugException();
- }
- setType(type);
- }
-
- NodeList list = root.getChildNodes();
- int length = list.getLength();
- for (int i = 0; i < length; ++i) {
- Node node = list.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String nodeName = element.getNodeName();
-
- if (nodeName.equalsIgnoreCase("stringAttribute")) { //$NON-NLS-1$
- setStringAttribute(element);
- } else if (nodeName.equalsIgnoreCase("intAttribute")) { //$NON-NLS-1$
- setIntegerAttribute(element);
- } else if (nodeName.equalsIgnoreCase("booleanAttribute")) { //$NON-NLS-1$
- setBooleanAttribute(element);
- } else if (nodeName.equalsIgnoreCase("listAttribute")) { //$NON-NLS-1$
- setListAttribute(element);
- } else if (nodeName.equalsIgnoreCase("mapAttribute")) { //$NON-NLS-1$
- setMapAttribute(element);
- }
- }
- }
- }
-
- protected void setStringAttribute(Element element) throws CoreException {
- String key = getKeyAttribute(element);
- String value = getValueAttribute(element);
- setAttribute(key, value);
- }
-
- protected void setIntegerAttribute(Element element) throws CoreException {
- String key = getKeyAttribute(element);
- String value = getValueAttribute(element);
- setAttribute(key, new Integer(value));
- }
-
- protected void setBooleanAttribute(Element element) throws CoreException {
- String key = getKeyAttribute(element);
- String value = getValueAttribute(element);
- setAttribute(key, new Boolean(value));
- }
-
- protected void setListAttribute(Element element) throws CoreException {
- String listKey = element.getAttribute("key"); //$NON-NLS-1$
- NodeList nodeList = element.getChildNodes();
- int entryCount = nodeList.getLength();
- List list = new ArrayList(entryCount);
- for (int i = 0; i < entryCount; i++) {
- Node node = nodeList.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element subElement = (Element) node;
- String nodeName = subElement.getNodeName();
- if (!nodeName.equalsIgnoreCase("listEntry")) { //$NON-NLS-1$
- throw getInvalidFormatDebugException();
- }
- String value = getValueAttribute(subElement);
- list.add(value);
- }
- }
- setAttribute(listKey, list);
- }
-
- protected void setMapAttribute(Element element) throws CoreException {
- String mapKey = element.getAttribute("key"); //$NON-NLS-1$
- NodeList nodeList = element.getChildNodes();
- int entryCount = nodeList.getLength();
- Map map = new HashMap(entryCount);
- for (int i = 0; i < entryCount; i++) {
- Node node = nodeList.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element subElement = (Element) node;
- String nodeName = subElement.getNodeName();
- if (!nodeName.equalsIgnoreCase("mapEntry")) { //$NON-NLS-1$
- throw getInvalidFormatDebugException();
- }
- String key = getKeyAttribute(subElement);
- String value = getValueAttribute(subElement);
- map.put(key, value);
- }
- }
- setAttribute(mapKey, map);
- }
-
- protected String getKeyAttribute(Element element) throws CoreException {
- String key = element.getAttribute("key"); //$NON-NLS-1$
- if (key == null) {
- throw getInvalidFormatDebugException();
- }
- return key;
- }
-
- protected String getValueAttribute(Element element) throws CoreException {
- String value = element.getAttribute("value"); //$NON-NLS-1$
- if (value == null) {
- throw getInvalidFormatDebugException();
- }
- return value;
- }
-
- protected DebugException getInvalidFormatDebugException() {
- return
- new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, DebugCoreMessages.getString("LaunchConfigurationInfo.Invalid_launch_configuration_XML._10"), null //$NON-NLS-1$
- )
- );
- }
-
- /**
- * Two <code>LaunchConfigurationInfo</code> objects are equal if and only if they have the
- * same type and they have the same set of attributes with the same values.
- *
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
-
- // Make sure it's a LaunchConfigurationInfo object
- if (!(obj instanceof LaunchConfigurationInfo)) {
- return false;
- }
-
- // Make sure the types are the same
- LaunchConfigurationInfo other = (LaunchConfigurationInfo) obj;
- if (!fType.getIdentifier().equals(other.getType().getIdentifier())) {
- return false;
- }
-
- // Make sure the attributes are the same
- if (!fAttributes.equals(other.getAttributeTable())) {
- return false;
- }
-
- // They're equal
- return true;
- }
-
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
deleted file mode 100644
index ecd2c2ba4..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationType.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
-
-/**
- * A launch configuration type wrappers a configuration
- * element for a <code>launchConfigurationType</code>
- * extension.
- */
-public class LaunchConfigurationType implements ILaunchConfigurationType {
-
- /**
- * The configuration element of the extension.
- */
- private IConfigurationElement fElement;
-
- /**
- * Modes this type supports.
- */
- private Set fModes;
-
- /**
- * The delegate for launch configurations of this type.
- * Delegates are instantiated lazily as required.
- */
- private ILaunchConfigurationDelegate fDelegate;
-
- /**
- * Constructs a new launch configuration type on the
- * given configuration element.
- *
- * @param element configuration element
- */
- protected LaunchConfigurationType(IConfigurationElement element) {
- setConfigurationElement(element);
- }
-
- /**
- * Sets this type's configuration element.
- *
- * @param element this type's configuration element
- */
- private void setConfigurationElement(IConfigurationElement element) {
- fElement = element;
- }
-
- /**
- * Returns this type's configuration element.
- *
- * @return this type's configuration element
- */
- protected IConfigurationElement getConfigurationElement() {
- return fElement;
- }
-
-
- /**
- * @see ILaunchConfigurationType#supportsMode(String)
- */
- public boolean supportsMode(String mode) {
- return getModes().contains(mode);
- }
-
- /**
- * Returns the set of modes specified in the configuration data.
- *
- * @return the set of modes specified in the configuration data
- */
- protected Set getModes() {
- if (fModes == null) {
- String modes= getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
- if (modes == null) {
- return new HashSet(0);
- }
- StringTokenizer tokenizer= new StringTokenizer(modes, ","); //$NON-NLS-1$
- fModes = new HashSet(tokenizer.countTokens());
- while (tokenizer.hasMoreTokens()) {
- fModes.add(tokenizer.nextToken().trim());
- }
- }
- return fModes;
- }
-
- /**
- * @see ILaunchConfigurationType#getName()
- */
- public String getName() {
- return getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- }
-
- /**
- * @see ILaunchConfigurationType#getIdentifier()
- */
- public String getIdentifier() {
- return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
- }
-
- /*
- * @see ILaunchConfigurationType#newInstance(IContainer, String)
- */
- public ILaunchConfigurationWorkingCopy newInstance(
- IContainer container,
- String name)
- throws CoreException {
- return new LaunchConfigurationWorkingCopy(container, name, this);
- }
-
- /**
- * Returns the launch configuration delegate for launch
- * configurations of this type. The first time this method
- * is called, the delegate is instantiated.
- *
- * @return launch configuration delegate
- * @exception CoreException if unable to instantiate the
- * delegate
- */
- public ILaunchConfigurationDelegate getDelegate() throws CoreException {
- if (fDelegate == null) {
- fDelegate = (ILaunchConfigurationDelegate)getConfigurationElement().createExecutableExtension("delegate"); //$NON-NLS-1$
- }
- return fDelegate;
- }
-
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
deleted file mode 100644
index 296195464..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfigurationWorkingCopy.java
+++ /dev/null
@@ -1,490 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-
-/**
- * A working copy launch configuration
- */
-public class LaunchConfigurationWorkingCopy extends LaunchConfiguration implements ILaunchConfigurationWorkingCopy {
-
- /**
- * Handle of original launch configuration this
- * working copy is based on
- */
- private LaunchConfiguration fOriginal;
-
- /**
- * Working copy of attributes.
- */
- private LaunchConfigurationInfo fInfo;
-
- /**
- * Whether this working copy has been modified since
- * it was created
- */
- private boolean fDirty = false;
-
- /**
- * The name for this configuration.
- */
- private String fName;
-
- /**
- * Indicates whether this working copy has been explicitly renamed.
- */
- private boolean fRenamed = false;
-
- /**
- * Suppress change notification until created
- */
- private boolean fSuppressChange = true;
-
- /**
- * The container this working copy will be
- * stored in when saved.
- */
- private IContainer fContainer;
-
- /**
- * Constructs a working copy of the specified launch
- * configuration.
- *
- * @param original launch configuration to make
- * a working copy of
- * @exception CoreException if unable to initialize this
- * working copy's attributes based on the original configuration
- */
- protected LaunchConfigurationWorkingCopy(LaunchConfiguration original) throws CoreException {
- super(original.getLocation());
- setName(original.getName());
- copyFrom(original);
- setOriginal(original);
- fSuppressChange = false;
- }
-
- /**
- * Constructs a copy of the specified launch
- * configuration, with the given (new) name.
- *
- * @param original launch configuration to make
- * a working copy of
- * @param name the new name for the copy of the launch
- * configuration
- * @exception CoreException if unable to initialize this
- * working copy's attributes based on the original configuration
- */
- protected LaunchConfigurationWorkingCopy(LaunchConfiguration original, String name) throws CoreException {
- super(original.getLocation());
- copyFrom(original);
- setName(name);
- fSuppressChange = false;
- }
-
- /**
- * Constructs a new working copy to be created in the specified
- * location.
- *
- * @param container the container that the configuration will be created in
- * or <code>null</code> if to be local
- * @param name the name of the new launch configuration
- * @param type the type of this working copy
- */
- protected LaunchConfigurationWorkingCopy(IContainer container, String name, ILaunchConfigurationType type) {
- super((IPath)null);
- setName(name);
- setInfo(new LaunchConfigurationInfo());
- getInfo().setType(type);
- setContainer(container);
- fSuppressChange = false;
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#isDirty()
- */
- public boolean isDirty() {
- return fDirty;
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#doSave()
- */
- public ILaunchConfiguration doSave() throws CoreException {
- if (isDirty()) {
- IWorkspaceRunnable wr = new IWorkspaceRunnable() {
- public void run(IProgressMonitor pm) throws CoreException {
- // write the new file
- LaunchConfigurationWorkingCopy.this.writeNewFile();
- // delete the old file if this is not a new configuration
- // or the file was renamed/moved
- if (!LaunchConfigurationWorkingCopy.this.isNew()) {
- if (LaunchConfigurationWorkingCopy.this.isMoved()) {
- LaunchConfigurationWorkingCopy.this.getOriginal().delete();
- }
- }
- resetDirty();
- }
- };
-
- ResourcesPlugin.getWorkspace().run(wr, null);
- }
-
- return new LaunchConfiguration(getLocation());
- }
-
- /**
- * Writes the new configuration information to a file.
- *
- * @exception CoreException if writing the file fails
- */
- protected void writeNewFile() throws CoreException {
- String xml = null;
- try {
- xml = getInfo().getAsXML();
- } catch (IOException e) {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationWorkingCopy.{0}_occurred_generating_launch_configuration_XML._1"), new String[]{e.toString()}), null //$NON-NLS-1$
- )
- );
- }
-
- if (isLocal()) {
- // use java.io to update configuration file
- try {
- boolean added = false;
- File file = getLocation().toFile();
- File dir = getLocation().removeLastSegments(1).toFile();
- dir.mkdirs();
- if (!file.exists()) {
- added = true;
- file.createNewFile();
- }
- FileOutputStream stream = new FileOutputStream(file);
- stream.write(xml.getBytes("UTF8"));
- stream.close();
- if (added) {
- getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getLocation()));
- } else {
- getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getLocation()));
- }
- } catch (IOException e) {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format(DebugCoreMessages.getString("LaunchConfigurationWorkingCopy.{0}_occurred_generating_launch_configuration_XML._1"), new String[]{e.toString()}), null //$NON-NLS-1$
- )
- );
- }
- } else {
- // use resource API to update configuration file
- IFile file = getFile();
- IContainer dir = file.getParent();
- if (!dir.exists()) {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, "Specified container for launch configuration does not exist.", null
- )
- );
- }
- ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes());
- if (!file.exists()) {
- file.create(stream, false, null);
- //getLaunchManager().launchConfigurationAdded(new LaunchConfiguration(getLocation()));
- } else {
- file.setContents(stream, false, false, null);
- //getLaunchManager().launchConfigurationChanged(new LaunchConfiguration(getLocation()));
- }
- }
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setAttribute(String, int)
- */
- public void setAttribute(String attributeName, int value) {
- getInfo().setAttribute(attributeName, new Integer(value));
- setDirty();
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setAttribute(String, String)
- */
- public void setAttribute(String attributeName, String value) {
- getInfo().setAttribute(attributeName, value);
- setDirty();
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setAttribute(String, boolean)
- */
- public void setAttribute(String attributeName, boolean value) {
- getInfo().setAttribute(attributeName, new Boolean(value));
- setDirty();
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setAttribute(String, List)
- */
- public void setAttribute(String attributeName, List value) {
- getInfo().setAttribute(attributeName, value);
- setDirty();
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setAttribute(String, Map)
- */
- public void setAttribute(String attributeName, Map value) {
- getInfo().setAttribute(attributeName, value);
- setDirty();
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#getOriginal()
- */
- public ILaunchConfiguration getOriginal() {
- return fOriginal;
- }
-
- /**
- * Sets the launch configuration this working copy
- * is based on. Initializes the attributes of this
- * working copy to the current values of the given
- * configuration.
- *
- * @param originl the launch configuration this working
- * copy is based on.
- * @exception CoreException if unable to initialize this
- * working copy based on the original's current attribute
- * set
- */
- private void copyFrom(LaunchConfiguration original) throws CoreException {
- LaunchConfigurationInfo info = original.getInfo();
- setInfo(info.getCopy());
- setContainer(original.getContainer());
- resetDirty();
- }
-
- /**
- * Sets the launch configuration this working copy
- * is based on.
- *
- * @param originl the launch configuration this working
- * copy is based on.
- */
- private void setOriginal(LaunchConfiguration original) {
- fOriginal = original;
- }
-
- /**
- * Sets the working copy info object for this working copy.
- *
- * @param info a copy of attributes from this working copy's
- * original launch configuration
- */
- protected void setInfo(LaunchConfigurationInfo info) {
- fInfo = info;
- }
-
- /**
- * @see ILaunchConfiguration#isWorkingCopy()
- */
- public boolean isWorkingCopy() {
- return true;
- }
-
- /**
- * A working copy keeps a local info object that is not
- * cached with the launch manager.
- *
- * @see LaunchConfiguration#getInfo()
- */
- protected LaunchConfigurationInfo getInfo() {
- return fInfo;
- }
-
- /**
- * Sets this working copy's state to dirty.
- * Notifies listeners that this working copy has
- * changed.
- */
- private void setDirty() {
- fDirty = true;
- if (!suppressChangeNotification()) {
- getLaunchManager().notifyChanged(this);
- }
- }
-
- /**
- * Sets this working copy's state to not dirty.
- */
- private void resetDirty() {
- fDirty = false;
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#rename(String)
- */
- public void rename(String name) {
- if (!getName().equals(name)) {
- setName(name);
- fRenamed = isNew() || !(getOriginal().getName().equals(name));
- }
- }
-
- /**
- * Sets the new name for this configuration.
- *
- * @param name the new name for this configuration
- */
- private void setName(String name) {
- fName = name;
- setDirty();
- }
-
- /**
- * @see ILaunchConfiguration#getName()
- */
- public String getName() {
- return fName;
- }
-
- /**
- * @see ILaunchConfiguration#isLocal()
- */
- public boolean isLocal() {
- return getContainer() == null;
- }
-
- /**
- * Returns the location this launch configuration will reside at
- * when saved.
- *
- * @see ILaunchConfiguration#getLocation()
- */
- public IPath getLocation() {
- if (isMoved()) {
- IPath path = null;
- if (isLocal()) {
- path = LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- } else {
- path = getContainer().getLocation();
- }
- path = path.append(getName() + "." + LAUNCH_CONFIGURATION_FILE_EXTENSION); //$NON-NLS-1$
- return path;
- } else {
- return getOriginal().getLocation();
- }
- }
-
- /**
- * Returns whether this working copy is new, or is a
- * working copy of another launch configuration.
- *
- * @return whether this working copy is new, or is a
- * working copy of another launch configuration
- */
- protected boolean isNew() {
- return getOriginal() == null;
- }
-
- /**
- * Returns whether this working copy is new or if its
- * location has changed from that of its original.
- *
- * @return whether this working copy is new or if its
- * location has changed from that of its original
- */
- protected boolean isMoved() {
- if (isNew() || fRenamed) {
- return true;
- }
- IContainer newContainer = getContainer();
- IContainer originalContainer = ((LaunchConfiguration)getOriginal()).getContainer();
- if (newContainer == originalContainer) {
- return false;
- }
- if (newContainer == null) {
- return !originalContainer.equals(newContainer);
- } else {
- return !newContainer.equals(originalContainer);
- }
- }
-
- /**
- * A working copy cannot generate a memento.
- *
- * @see ILaunchConfiguration#getMemento()
- */
- public String getMemento() {
- return null;
- }
-
- /**
- * Returns whether change notification should be
- * suppressed
- */
- protected boolean suppressChangeNotification() {
- return fSuppressChange;
- }
-
- /**
- * @see ILaunchConfigurationWorkingCopy#setContainer(IContainer)
- */
- public void setContainer(IContainer container) {
- if (container == fContainer) {
- return;
- }
- if (container != null) {
- if (container.equals(fContainer)) {
- return;
- }
- } else {
- if (fContainer.equals(container)) {
- return;
- }
- }
- fContainer = container;
- setDirty();
- }
-
- /**
- * Returns the container this working copy will be
- * stored in when saved, or <code>null</code> if
- * this working copy is local.
- *
- * @return the container this working copy will be
- * stored in when saved, or <code>null</code> if
- * this working copy is local
- */
- protected IContainer getContainer() {
- return fContainer;
- }
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
deleted file mode 100644
index beb82384d..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java
+++ /dev/null
@@ -1,1372 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.apache.xerces.dom.DocumentImpl;
-import org.apache.xml.serialize.Method;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationListener;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchListener;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILauncher;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IPersistableSourceLocator;
-import org.eclipse.debug.core.model.IProcess;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Manages launch configurations, launch configuration types, and registered launches.
- *
- * @see ILaunchManager
- */
-public class LaunchManager implements ILaunchManager, IResourceChangeListener {
-
- /**
- * Collection of defined launch configuration type
- * extensions.
- */
- private List fLaunchConfigurationTypes = new ArrayList(5);
-
- /**
- * Table of default launch configuration types keyed by file extension.
- */
- private HashMap fDefaultLaunchConfigurationTypes = new HashMap(5);
-
- /**
- * Table of lists of launch configuration types keyed by file extension.
- */
- private HashMap fLaunchConfigurationTypesByFileExtension = new HashMap(5);
-
- /**
- * Launch configuration cache. Keys are <code>LaunchConfiguration</code>,
- * values are <code>LaunchConfigurationInfo</code>.
- */
- private HashMap fLaunchConfigurations = new HashMap(10);
-
- /**
- * A cache of launch configuration names currently in the workspace.
- */
- private String[] fSortedConfigNames = null;
-
- /**
- * Collection of all launch configurations in the workspace.
- * <code>List</code> of <code>ILaunchConfiguration</code>.
- */
- private List fLaunchConfigurationIndex = null;
-
- /**
- * Constant for use as local name part of <code>QualifiedName</code>
- * for persisting the default launcher.
- */
- private static final String DEFAULT_LAUNCHER= "launcher"; //$NON-NLS-1$
-
- /**
- * Constant for use as local name part of <code>QualifiedName</code>
- * for persisting the default launch configuration type.
- */
- private static final String DEFAULT_CONFIG_TYPE = "defaultLaunchConfigurationType"; //$NON-NLS-1$
-
- /**
- * Constant for use as local name part of <code>QualifiedName</code>
- * for persisting the default launch configuration.
- */
- private static final String DEFAULT_LAUNCH_CONFIGURATION= "default_launch_configuration"; //$NON-NLS-1$
-
- /**
- * Constant used for reading and writing the default config type to metadata.
- */
- private static final QualifiedName fgQualNameDefaultConfigType = new QualifiedName(DebugPlugin.PLUGIN_ID, DEFAULT_CONFIG_TYPE);
-
- /**
- * Types of notifications
- */
- public static final int ADDED = 0;
- public static final int REMOVED= 1;
- public static final int CHANGED= 2;
-
- /**
- * Collection of launches
- */
- private Vector fLaunches= new Vector(10);
-
- /**
- * Collection of listeners
- */
- private ListenerList fListeners= new ListenerList(5);
-
- /**
- * Visitor used to process resource deltas,
- * to update launch configuration index.
- */
- private IResourceDeltaVisitor fgVisitor;
-
- /**
- * Launch configuration listeners
- */
- private ListenerList fLaunchConfigurationListeners = new ListenerList(5);
-
- /**
- * Table of source locator extensions. Keys
- * are identifiers, and values are associated
- * configuration elements.
- */
- private Map fSourceLocators = new HashMap(10);
-
- /**
- * Path to the local directory where local launch configurations
- * are stored with the workspace.
- */
- protected static final IPath LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH =
- DebugPlugin.getDefault().getStateLocation().append(".launches"); //$NON-NLS-1$
-
- /**
- * @see ILaunchManager#addLaunchListener(ILaunchListener)
- */
- public void addLaunchListener(ILaunchListener listener) {
- fListeners.add(listener);
- }
-
- /**
- * Returns a collection of all launch configuration handles in
- * the workspace. This collection is initialized lazily.
- *
- * @return all launch configuration handles
- */
- private List getAllLaunchConfigurations() throws CoreException {
- if (fLaunchConfigurationIndex == null) {
- fLaunchConfigurationIndex = new ArrayList(20);
- fLaunchConfigurationIndex.addAll(findLocalLaunchConfigurations());
- fLaunchConfigurationIndex.addAll(findLaunchConfigurations(ResourcesPlugin.getWorkspace().getRoot()));
- }
- return fLaunchConfigurationIndex;
- }
-
- /**
- * @see ILaunchManager#deregisterLaunch(ILaunch)
- */
- public void deregisterLaunch(ILaunch launch) {
- removeLaunch(launch);
- }
-
- /**
- * @see ILaunchManager#removeLaunch(ILaunch)
- */
- public void removeLaunch(ILaunch launch) {
- if (launch == null) {
- return;
- }
- fLaunches.remove(launch);
- fireUpdate(launch, REMOVED);
- }
-
- /**
- * @see ILaunchManager#findLaunch(IProcess)
- */
- public ILaunch findLaunch(IProcess process) {
- synchronized (fLaunches) {
- for (int i= 0; i < fLaunches.size(); i++) {
- ILaunch l= (ILaunch) fLaunches.elementAt(i);
- IProcess[] ps= l.getProcesses();
- for (int j= 0; j < ps.length; j++) {
- if (ps[j].equals(process)) {
- return l;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * @see ILaunchManager#findLaunch(IDebugTarget)
- */
- public ILaunch findLaunch(IDebugTarget target) {
- synchronized (fLaunches) {
- for (int i= 0; i < fLaunches.size(); i++) {
- ILaunch l= (ILaunch) fLaunches.elementAt(i);
- IDebugTarget[] targets = l.getDebugTargets();
- for (int j = 0; j < targets.length; j++) {
- if (target.equals(targets[j])) {
- return l;
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Fires notification to the listeners that a launch has been (de)registered.
- */
- public void fireUpdate(ILaunch launch, int update) {
- Object[] copiedListeners= fListeners.getListeners();
- for (int i= 0; i < copiedListeners.length; i++) {
- ILaunchListener listener = (ILaunchListener)copiedListeners[i];
- switch (update) {
- case ADDED:
- listener.launchAdded(launch);
- break;
- case REMOVED:
- listener.launchRemoved(launch);
- break;
- case CHANGED:
- listener.launchChanged(launch);
- break;
- }
- }
- }
-
- /**
- * @see ILaunchManager#getDebugTargets()
- */
- public IDebugTarget[] getDebugTargets() {
- List allTargets= new ArrayList(fLaunches.size());
- if (fLaunches.size() > 0) {
- Iterator e= fLaunches.iterator();
- while (e.hasNext()) {
- IDebugTarget[] targets= ((ILaunch) e.next()).getDebugTargets();
- for (int i = 0; i < targets.length; i++) {
- allTargets.add(targets[i]);
- }
- }
- }
- return (IDebugTarget[])allTargets.toArray(new IDebugTarget[allTargets.size()]);
- }
-
- /**
- * @see ILaunchManager#getDefaultLauncher(IProject)
- */
- public ILauncher getDefaultLauncher(IProject project) throws CoreException {
- ILauncher launcher= null;
- if ((project != null) && project.isOpen()) {
- String launcherID = project.getPersistentProperty(new QualifiedName(DebugPlugin.PLUGIN_ID, DEFAULT_LAUNCHER));
- if (launcherID != null) {
- launcher= getLauncher(launcherID);
- }
- }
- return launcher;
- }
-
- /**
- * @see ILaunchManager#getDefaultLaunchConfigurationType(IResource)
- */
- public ILaunchConfigurationType getDefaultLaunchConfigurationType(IResource resource, boolean considerResourceOnly) {
-
- try {
- // First check on the resource itself
- String defaultConfigTypeID = resource.getPersistentProperty(fgQualNameDefaultConfigType);
- if (defaultConfigTypeID != null) {
- ILaunchConfigurationType type = getLaunchConfigurationType(defaultConfigTypeID);
- if (type != null) {
- return type;
- }
- } else if (considerResourceOnly) {
- return null;
- }
-
- // Next work up the resource's containment chain looking for a resource that
- // specifies a default config type
- IResource candidateResource = resource.getParent();
- while (!(candidateResource instanceof IWorkspaceRoot)) {
- defaultConfigTypeID = candidateResource.getPersistentProperty(fgQualNameDefaultConfigType);
- if (defaultConfigTypeID != null) {
- return getLaunchConfigurationType(defaultConfigTypeID);
- }
- candidateResource = candidateResource.getParent();
- }
- } catch (CoreException ce) {
- DebugPlugin.log(ce);
- }
-
- // Otherwise, return the default associated with the resource's file extension
- return getDefaultLaunchConfigurationType(resource.getFileExtension());
- }
-
- /**
- * @see ILaunchManager#getDefaultLaunchConfigurationType(String)
- */
- public ILaunchConfigurationType getDefaultLaunchConfigurationType(String fileExtension) {
- return (ILaunchConfigurationType) fDefaultLaunchConfigurationTypes.get(fileExtension);
- }
-
- /**
- * @see ILaunchManager#getAllRegisteredFileExtensions()
- */
- public String[] getAllRegisteredFileExtensions() {
- Object[] objectArray = fLaunchConfigurationTypesByFileExtension.keySet().toArray();
- String[] stringArray = new String[objectArray.length];
- for (int i = 0; i < objectArray.length; i++) {
- stringArray[i] = (String) objectArray[i];
- }
- return stringArray;
- }
-
- /**
- * @see ILaunchManager#getAllLaunchConfigurationTypesFor(String)
- */
- public ILaunchConfigurationType[] getAllLaunchConfigurationTypesFor(String fileExtension) {
- Object[] objectArray = ((List)fLaunchConfigurationTypesByFileExtension.get(fileExtension)).toArray();
- ILaunchConfigurationType[] configTypeArray = new ILaunchConfigurationType[objectArray.length];
- for (int i = 0; i < objectArray.length; i++) {
- configTypeArray[i] = (ILaunchConfigurationType) objectArray[i];
- }
- return configTypeArray;
- }
-
- /**
- * Returns the launcher with the given id, or <code>null</code>.
- */
- public ILauncher getLauncher(String id) {
- ILauncher[] launchers= getLaunchers();
- for (int i= 0; i < launchers.length; i++) {
- if (launchers[i].getIdentifier().equals(id)) {
- return launchers[i];
- }
- }
- return null;
- }
-
- /**
- * @see ILaunchManager#getLaunchers()
- */
- public ILauncher[] getLaunchers() {
- return DebugPlugin.getDefault().getLaunchers();
- }
-
- /**
- * @see ILaunchManager#getLaunchers(String)
- */
- public ILauncher[] getLaunchers(String mode) {
- ILauncher[] launchers = getLaunchers();
- ArrayList list = new ArrayList();
- for (int i = 0; i < launchers.length; i++) {
- if (launchers[i].getModes().contains(mode)) {
- list.add(launchers[i]);
- }
- }
- return (ILauncher[])list.toArray(new ILauncher[list.size()]);
- }
-
- /**
- * @see ILaunchManager#getLaunches()
- */
- public ILaunch[] getLaunches() {
- return (ILaunch[])fLaunches.toArray(new ILaunch[fLaunches.size()]);
- }
-
- /**
- * @see ILaunchManager#getProcesses()
- */
- public IProcess[] getProcesses() {
- List allProcesses= new ArrayList(fLaunches.size());
- Iterator e= fLaunches.iterator();
- while (e.hasNext()) {
- IProcess[] processes= ((ILaunch) e.next()).getProcesses();
- for (int i= 0; i < processes.length; i++) {
- allProcesses.add(processes[i]);
- }
- }
- return (IProcess[])allProcesses.toArray(new IProcess[allProcesses.size()]);
- }
-
- /**
- * @see ILaunchManager#registerLaunch(ILaunch)
- */
- public void registerLaunch(ILaunch launch) {
- addLaunch(launch);
- }
-
- /**
- * @see ILaunchManager#addLaunch(ILaunch)
- */
- public void addLaunch(ILaunch launch) {
- if (fLaunches.contains(launch)) {
- return;
- }
-
- fLaunches.add(launch);
- fireUpdate(launch, ADDED);
- }
-
- /**
- * @see ILaunchManager#removeLaunchListener(ILaunchListener)
- */
- public void removeLaunchListener(ILaunchListener listener) {
- fListeners.remove(listener);
- }
-
- /**
- * @see ILaunchManager#setDefaultLauncher(IProject, ILauncher)
- */
- public void setDefaultLauncher(IProject resource, ILauncher launcher) throws CoreException {
- String id = null;
- if (launcher != null) {
- id = launcher.getIdentifier();
- }
- resource.setPersistentProperty(new QualifiedName(DebugPlugin.PLUGIN_ID, DEFAULT_LAUNCHER), id);
- }
-
- /**
- * @see ILaunchManager#setDefaultLaunchConfigurationType(IResource, String)
- */
- public void setDefaultLaunchConfigurationType(IResource resource, String configTypeID) throws CoreException {
- resource.setPersistentProperty(fgQualNameDefaultConfigType, configTypeID);
- }
-
- /**
- * @see ILaunchManager#setDefaultLaunchConfigurationType(String, String)
- */
- public void setDefaultLaunchConfigurationType(String fileExtension, String configTypeID) {
- fDefaultLaunchConfigurationTypes.put(fileExtension, getLaunchConfigurationType(configTypeID));
- }
-
- /**
- * @see ILaunchManager#setDefaultLaunchConfiguration(IResource, ILaunchConfiguration)
- */
- public void setDefaultLaunchConfiguration(IResource resource, ILaunchConfiguration config) throws CoreException {
- String memento = config.getMemento();
- resource.setPersistentProperty(new QualifiedName(DEFAULT_LAUNCH_CONFIGURATION, config.getType().getIdentifier()), memento);
- setDefaultLaunchConfigurationType(resource, config.getType().getIdentifier());
- }
-
- /**
- * @see ILaunchManager#getDefaultLaunchConfiguration(IResource, String)
- */
- public ILaunchConfiguration getDefaultLaunchConfiguration(IResource resource, String configTypeID) throws CoreException {
- String memento = resource.getPersistentProperty(new QualifiedName(DEFAULT_LAUNCH_CONFIGURATION, configTypeID));
- if (memento != null) {
- ILaunchConfiguration config = getLaunchConfiguration(memento);
- if (config.exists()) {
- return config;
- }
- }
- return null;
- }
-
- /**
- * Return a LaunchConfigurationInfo object initialized from XML contained in
- * the specified stream. Simply pass out any exceptions encountered so that
- * caller can deal with them. This is important since caller may need access to the
- * actual exception.
- */
- protected LaunchConfigurationInfo createInfoFromXML(InputStream stream) throws CoreException,
- ParserConfigurationException,
- IOException,
- SAXException {
- Element root = null;
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- root = parser.parse(new InputSource(stream)).getDocumentElement();
- LaunchConfigurationInfo info = new LaunchConfigurationInfo();
- info.initializeFromXML(root);
- return info;
- }
-
- /**
- * Terminates/Disconnects any active debug targets/processes.
- * Clears launch configuration types.
- */
- public void shutdown() throws CoreException {
- fListeners.removeAll();
- ILaunch[] launches = getLaunches();
- for (int i= 0; i < launches.length; i++) {
- ILaunch launch= launches[i];
- try {
- launch.terminate();
- } catch (DebugException e) {
- DebugPlugin.log(e);
- }
- }
-
- // persist the mapping of file extensions to default config types
- IPath path = DebugPlugin.getDefault().getStateLocation().append(".defaultlaunchconfigs"); //$NON-NLS-1$
- persistDefaultConfigTypeMap(path);
-
- fLaunchConfigurationTypes.clear();
- getAllLaunchConfigurations().clear();
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- }
-
- /**
- * Creates launch configuration types for each defined extension.
- *
- * @exception CoreException if an exception occurs processing
- * the extensions
- */
- public void startup() throws CoreException {
- IPluginDescriptor descriptor= DebugPlugin.getDefault().getDescriptor();
- IExtensionPoint extensionPoint= descriptor.getExtensionPoint(DebugPlugin.EXTENSION_POINT_LAUNCH_CONFIGURATION_TYPES);
- IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
- for (int i= 0; i < infos.length; i++) {
- IConfigurationElement configurationElement = infos[i];
- LaunchConfigurationType configType = new LaunchConfigurationType(configurationElement);
- fLaunchConfigurationTypes.add(configType);
- addFileExtensions(configurationElement, configType);
- }
- ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
-
- // restore the user-specified mapping of file extensions to default config types
- IPath defaultConfigMapPath = DebugPlugin.getDefault().getStateLocation().append(".defaultlaunchconfigs"); //$NON-NLS-1$
- restoreDefaultConfigTypeMap(defaultConfigMapPath);
-
- initializeSourceLocators();
- }
-
- /**
- * For the given configuration element, retrieve all file extensions it has registered,
- * and for each one that claims to be the default, add the config type as the default
- * config type for the file extension.
- */
- protected void addFileExtensions(IConfigurationElement configElement, LaunchConfigurationType configType) {
- IConfigurationElement[] children = configElement.getChildren("fileExtension");
- for (int i = 0; i < children.length; i++) {
- IConfigurationElement fileExtensionElement = children[i];
- String fileExtension = fileExtensionElement.getAttribute("extension");
- String defaultValue = fileExtensionElement.getAttribute("default");
- addOneFileExtension(fileExtension, defaultValue, configType);
- }
- }
-
- /**
- * Populate internal data structures for the given config type and its file extension.
- */
- protected void addOneFileExtension(String fileExtension, String defaultValue, LaunchConfigurationType configType) {
- List configTypeList = (List)fLaunchConfigurationTypesByFileExtension.get(fileExtension);
- if (configTypeList == null) {
- configTypeList = new ArrayList(5);
- fLaunchConfigurationTypesByFileExtension.put(fileExtension, configTypeList);
- }
- configTypeList.add(configType);
-
- if (defaultValue.equalsIgnoreCase("true")) {
- fDefaultLaunchConfigurationTypes.put(fileExtension, configType);
- }
- }
-
- /**
- * Load the user-specified mapping of file extensions to default config types.
- */
- protected void restoreDefaultConfigTypeMap(IPath path) throws CoreException {
- InputStream stream = null;
- try {
- File file = path.toFile();
- if (!file.exists()) {
- // no map to restore
- return;
- }
- stream = new FileInputStream(file);
- Element root = null;
- DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- root = parser.parse(new InputSource(stream)).getDocumentElement();
- updateDefaultConfigTypesFromXML(root);
- } catch (FileNotFoundException e) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while reading default configuration type map", new String[]{e.toString()}), e)
- );
- } catch (SAXException e) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while reading default configuration type map", new String[]{e.toString()}), e)
- );
- } catch (ParserConfigurationException e) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while reading default configuration type map", new String[]{e.toString()}), e)
- );
- } catch (IOException e) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while reading default configuration type map", new String[]{e.toString()}), e)
- );
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- throw new DebugException(
- new Status(Status.ERROR, DebugPlugin.getDefault().getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while reading default configuration type map", new String[]{e.toString()}), e)
- );
- }
- }
- }
- }
-
- /**
- * Update the table of default config types based on the entries underneath the specified root node.
- */
- protected void updateDefaultConfigTypesFromXML(Element root) throws CoreException {
- DebugException invalidFormat =
- new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, "Invalid default configuration type map", null
- )
- );
-
- if (!root.getNodeName().equalsIgnoreCase("defaultLaunchConfigTypes")) { //$NON-NLS-1$
- throw invalidFormat;
- }
-
- // read each default configuration
- NodeList list = root.getChildNodes();
- int length = list.getLength();
- for (int i = 0; i < length; ++i) {
- Node node = list.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String nodeName = entry.getNodeName();
- if (!nodeName.equalsIgnoreCase("defaultLaunchConfigType")) { //$NON-NLS-1$
- throw invalidFormat;
- }
- String fileExtension = entry.getAttribute("fileExtension"); //$NON-NLS-1$
- if (fileExtension == null) {
- throw invalidFormat;
- }
- // Make sure the file extension was registered by some config type
- List configList = (List) fLaunchConfigurationTypesByFileExtension.get(fileExtension);
- if (configList == null) {
- continue;
- }
- String defaultConfigTypeID = entry.getAttribute("launchConfigTypeID"); //$NON-NLS-1$
- if (defaultConfigTypeID == null) {
- throw invalidFormat;
- }
- ILaunchConfigurationType configType = getLaunchConfigurationType(defaultConfigTypeID);
- // Make sure the config type has been registered
- if (configType == null) {
- continue;
- }
- fDefaultLaunchConfigurationTypes.put(fileExtension, configType);
- }
- }
- }
-
- /**
- * Persists the mapping of file extensions to default configuration types in a file at the
- * specified path.
- */
- protected void persistDefaultConfigTypeMap(IPath path) throws CoreException {
- String xml = null;
- try {
- xml = getDefaultConfigTypesAsXML();
- } catch (IOException e) {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred generating default launch configuration map file", new String[]{e.toString()}), null //$NON-NLS-1$
- )
- );
- }
-
- try {
- File file = path.toFile();
- if (!file.exists()) {
- file.createNewFile();
- }
- FileOutputStream stream = new FileOutputStream(file);
- stream.write(xml.getBytes());
- stream.close();
- } catch (IOException e) {
- throw new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred generating default launch configuration map file", new String[]{e.toString()}), null //$NON-NLS-1$
- )
- );
- }
- }
-
- /**
- * Convert the map of file extensions to default config types into an String of XML.
- */
- protected String getDefaultConfigTypesAsXML() throws IOException {
- Document doc = new DocumentImpl();
- Element configRootElement = doc.createElement("defaultLaunchConfigTypes"); //$NON-NLS-1$
- doc.appendChild(configRootElement);
-
- Iterator iterator = fDefaultLaunchConfigurationTypes.keySet().iterator();
- while (iterator.hasNext()) {
- String fileExtension = (String) iterator.next();
- ILaunchConfigurationType configType = getDefaultLaunchConfigurationType(fileExtension);
- Element element = doc.createElement("defaultLaunchConfigType"); //$NON-NLS-1$
- element.setAttribute("fileExtension", fileExtension); //$NON-NLS-1$
- element.setAttribute("launchConfigTypeID", configType.getIdentifier()); //$NON-NLS-1$
- configRootElement.appendChild(element);
- }
-
- // produce a String output
- StringWriter writer = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- writer,
- format);
- serializer.asDOMSerializer().serialize(doc);
- return writer.toString();
- }
-
- /**
- * Returns the info object for the specified launch configuration.
- * If the configuration exists, but is not yet in the cache,
- * an info object is built and added to the cache.
- *
- * @exception CoreException if an exception occurs building
- * the info object
- * @exception DebugException if the config does not exist
- */
- protected LaunchConfigurationInfo getInfo(ILaunchConfiguration config) throws CoreException {
- LaunchConfigurationInfo info = (LaunchConfigurationInfo)fLaunchConfigurations.get(config);
- if (info == null) {
- if (config.exists()) {
- InputStream stream = null;
- try {
- if (config.isLocal()) {
- IPath path = config.getLocation();
- File file = path.toFile();
- stream = new FileInputStream(file);
- } else {
- IFile file = ((LaunchConfiguration) config).getFile();
- stream = file.getContents();
- }
- info = createInfoFromXML(stream);
- fLaunchConfigurations.put(config, info);
- } catch (FileNotFoundException e) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
- } catch (SAXException e) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
- } catch (ParserConfigurationException e) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
- } catch (IOException e) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (IOException e) {
- throw createDebugException(MessageFormat.format(DebugCoreMessages.getString("LaunchManager.{0}_occurred_while_reading_launch_configuration_file._1"), new String[]{e.toString()}), e); //$NON-NLS-1$
- }
- }
- }
-
- } else {
- throw createDebugException(DebugCoreMessages.getString("LaunchManager.Launch_configuration_does_not_exist._6"), null); //$NON-NLS-1$
- }
- }
- return info;
- }
-
- /**
- * Return an instance of DebugException containing the specified message and Throwable.
- */
- protected DebugException createDebugException(String message, Throwable throwable) {
- return new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, message, throwable
- )
- );
- }
-
- /**
- * Removes the given launch configuration from the cache of configurations.
- * When a local configuration is deleted, this method is called, as there will
- * be no resource delta generated to auto-update the cache.
- *
- * @param configuration the configuration to remove
- */
- private void removeInfo(ILaunchConfiguration configuration) {
- fLaunchConfigurations.remove(configuration);
- }
-
- /**
- * @see ILaunchManager#getLaunchConfigurations()
- */
- public ILaunchConfiguration[] getLaunchConfigurations() throws CoreException {
- List allConfigs = getAllLaunchConfigurations();
- return (ILaunchConfiguration[])allConfigs.toArray(new ILaunchConfiguration[allConfigs.size()]);
- }
-
- /**
- * @see ILaunchManager#getLaunchConfigurations(ILaunchConfigurationType)
- */
- public ILaunchConfiguration[] getLaunchConfigurations(ILaunchConfigurationType type) throws CoreException {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- while (iter.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)iter.next();
- if (config.getType().equals(type)) {
- configs.add(config);
- }
- }
- return (ILaunchConfiguration[])configs.toArray(new ILaunchConfiguration[configs.size()]);
- }
-
- /**
- * Returns all launch configurations that are stored as resources
- * in the given project.
- *
- * @param project a project
- * @return collection of launch configurations that are stored as resources
- * in the given project
- */
- protected List getLaunchConfigurations(IProject project) throws CoreException {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- while (iter.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)iter.next();
- IFile file = config.getFile();
- if (file != null && file.getProject().equals(project)) {
- configs.add(config);
- }
- }
- return configs;
- }
-
- /**
- * Returns all launch configurations that are stored locally.
- *
- * @return collection of launch configurations stored lcoally
- */
- protected List getLocalLaunchConfigurations() throws CoreException {
- Iterator iter = getAllLaunchConfigurations().iterator();
- List configs = new ArrayList();
- while (iter.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration)iter.next();
- if (config.isLocal()) {
- configs.add(config);
- }
- }
- return configs;
- }
-
- /**
- * @see ILaunchManager#getLaunchConfiguration(IFile)
- */
- public ILaunchConfiguration getLaunchConfiguration(IFile file) {
- return new LaunchConfiguration(file.getLocation());
- }
-
- /**
- * @see ILaunchManager#getLaunchConfiguration(String)
- */
- public ILaunchConfiguration getLaunchConfiguration(String memento) throws CoreException {
- return new LaunchConfiguration(memento);
- }
-
- /**
- * @see ILaunchManager#getLaunchConfigurationTypes()
- */
- public ILaunchConfigurationType[] getLaunchConfigurationTypes() {
- return (ILaunchConfigurationType[])fLaunchConfigurationTypes.toArray(new ILaunchConfigurationType[fLaunchConfigurationTypes.size()]);
- }
-
- /**
- * @see ILaunchManager#getLaunchConfigurationType(String)
- */
- public ILaunchConfigurationType getLaunchConfigurationType(String id) {
- Iterator iter = fLaunchConfigurationTypes.iterator();
- while (iter.hasNext()) {
- ILaunchConfigurationType type = (ILaunchConfigurationType)iter.next();
- if (type.getIdentifier().equals(id)) {
- return type;
- }
- }
- return null;
- }
-
- /**
- * Notifies the launch manager that a launch configuration
- * has been deleted. The configuration is removed from the
- * cache of info's and from the index of configurations by
- * project, and listeners are notified.
- *
- * @param config the launch configuration that was deleted
- */
- protected void launchConfigurationDeleted(ILaunchConfiguration config) throws CoreException {
- removeInfo(config);
- getAllLaunchConfigurations().remove(config);
- if (fLaunchConfigurationListeners.size() > 0) {
- Object[] listeners = fLaunchConfigurationListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ILaunchConfigurationListener listener = (ILaunchConfigurationListener)listeners[i];
- listener.launchConfigurationRemoved(config);
- }
- }
- clearConfigNameCache();
- }
-
- /**
- * Notifies the launch manager that a launch configuration
- * has been added. The configuration is added to the index of
- * configurations by project, and listeners are notified.
- *
- * @param config the launch configuration that was added
- */
- protected void launchConfigurationAdded(ILaunchConfiguration config) throws CoreException {
- List allConfigs = getAllLaunchConfigurations();
- if (!allConfigs.contains(config)) {
- allConfigs.add(config);
- }
- if (fLaunchConfigurationListeners.size() > 0) {
- Object[] listeners = fLaunchConfigurationListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ILaunchConfigurationListener listener = (ILaunchConfigurationListener)listeners[i];
- listener.launchConfigurationAdded(config);
- }
- }
- clearConfigNameCache();
- }
-
- /**
- * Notifies the launch manager that a launch configuration
- * has been changed. The configuration is removed from the
- * cache of info objects such that the new attributes will
- * be updated on the next access. Listeners are notified of
- * the change.
- *
- * @param config the launch configuration that was changed
- */
- protected void launchConfigurationChanged(ILaunchConfiguration config) {
- removeInfo(config);
- notifyChanged(config);
- clearConfigNameCache();
- }
-
- /**
- * Notifies listeners that the given launch configuration
- * has changed.
- *
- * @param configuration the changed launch configuration
- */
- protected void notifyChanged(ILaunchConfiguration configuration) {
- if (fLaunchConfigurationListeners.size() > 0) {
- Object[] listeners = fLaunchConfigurationListeners.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- ILaunchConfigurationListener listener = (ILaunchConfigurationListener)listeners[i];
- listener.launchConfigurationChanged(configuration);
- }
- }
- }
-
- /**
- * @see ILaunchManager#isExistingLaunchConfigurationName(String)
- */
- public boolean isExistingLaunchConfigurationName(String name) throws CoreException {
- String[] sortedConfigNames = getAllSortedConfigNames();
- int index = Arrays.binarySearch(sortedConfigNames, name);
- if (index < 0) {
- return false;
- }
- return true;
- }
-
- /**
- * Return a sorted array of the names of all <code>ILaunchConfiguration</code>s in
- * the workspace. These are cached, and cache is cleared when a new config is added,
- * deleted or changed.
- */
- protected String[] getAllSortedConfigNames() throws CoreException {
- if (fSortedConfigNames == null) {
- ILaunchConfiguration[] configs = getLaunchConfigurations();
- fSortedConfigNames = new String[configs.length];
- for (int i = 0; i < configs.length; i++) {
- fSortedConfigNames[i] = configs[i].getName();
- }
- Arrays.sort(fSortedConfigNames);
- }
- return fSortedConfigNames;
- }
-
- /**
- * The launch config name cache is cleared when a config is added, deleted or changed.
- */
- protected void clearConfigNameCache() {
- fSortedConfigNames = null;
- }
-
- /**
- * Finds and returns all local launch configurations.
- *
- * @return all local launch configurations
- * @exception CoreException if there is a lower level
- * IO exception
- */
- protected List findLocalLaunchConfigurations() throws CoreException {
- IPath containerPath = LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH;
- List configs = new ArrayList(10);
- final File directory = containerPath.toFile();
- if (directory.isDirectory()) {
- FilenameFilter filter = new FilenameFilter() {
- public boolean accept(File dir, String name) {
- return dir.equals(directory) && name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION);
- }
- };
- File[] files = directory.listFiles(filter);
- for (int i = 0; i < files.length; i++) {
- try {
- LaunchConfiguration config = new LaunchConfiguration(new Path(files[i].getCanonicalPath()));
- configs.add(config);
- } catch (IOException e) {
- throw new CoreException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, MessageFormat.format("{0} occurred while re-building local launch configuration index.", new String[]{e.toString()}), null
- ));
- }
- }
- }
- return configs;
- }
-
- /**
- * Finds and returns all launch configurations in the given
- * container (and subcontainers)
- *
- * @param container the container to search
- * @exception CoreException an exception occurs traversing
- * the container.
- * @return all launch configurations in the given container
- */
- protected List findLaunchConfigurations(IContainer container) throws CoreException {
- List list = new ArrayList(10);
- if (container instanceof IProject && !((IProject)container).isOpen()) {
- return list;
- }
- searchForFiles(container, ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION, list);
- Iterator iter = list.iterator();
- List configs = new ArrayList(list.size());
- while (iter.hasNext()) {
- IFile file = (IFile)iter.next();
- configs.add(getLaunchConfiguration(file));
- }
- return configs;
- }
-
- /**
- * Recursively searches the given container for files with the given
- * extension.
- *
- * @param container the container to search in
- * @param extension the file extension being searched for
- * @param list the list to add the matching files to
- * @exception CoreException if an exception occurs traversing
- * the container
- */
- protected void searchForFiles(IContainer container, String extension, List list) throws CoreException {
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- if (members[i] instanceof IContainer) {
- if (members[i] instanceof IProject && !((IProject)members[i]) .isOpen()) {
- continue;
- }
- searchForFiles((IContainer)members[i], extension, list);
- } else if (members[i] instanceof IFile) {
- IFile file = (IFile)members[i];
- if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equalsIgnoreCase(file.getFileExtension())) {
- list.add(file);
- }
- }
- }
- }
-
- /**
- * Traverses the delta looking for added/removed/changed launch
- * configuration files.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta= event.getDelta();
- if (delta != null) {
- try {
- if (fgVisitor == null) {
- fgVisitor= new LaunchManagerVisitor();
- }
- delta.accept(fgVisitor);
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- }
-
- /**
- * Returns XML that can be used to persist the specified
- * launch configurations.
- *
- * @param configs list of configurations
- * @return XML
- * @exception IOException if an exception occurs creating the XML
- */
- protected String getConfigsAsXML(List configs) throws IOException, CoreException {
-
- Document doc = new DocumentImpl();
- Element configRootElement = doc.createElement("launchConfigurations"); //$NON-NLS-1$
- doc.appendChild(configRootElement);
-
- for (int i = 0; i < configs.size(); i++) {
- ILaunchConfiguration lc = (ILaunchConfiguration)configs.get(i);
- String memento = lc.getMemento();
- Element element = doc.createElement("launchConfiguration"); //$NON-NLS-1$
- element.setAttribute("memento", memento); //$NON-NLS-1$
- configRootElement.appendChild(element);
- }
-
- // produce a String output
- StringWriter writer = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- writer,
- format);
- serializer.asDOMSerializer().serialize(doc);
- return writer.toString();
-
- }
-
- /**
- * Returns the launch configurations specified by the given
- * XML document.
- *
- * @param root XML document
- * @return list of launch configurations
- * @exception IOException if an exception occurs reading the XML
- */
- protected List getConfigsFromXML(Element root) throws CoreException {
- DebugException invalidFormat =
- new DebugException(
- new Status(
- Status.ERROR, DebugPlugin.getDefault().getDescriptor().getUniqueIdentifier(),
- DebugException.REQUEST_FAILED, DebugCoreMessages.getString("Invalid_launch_configuration_index._18"), null //$NON-NLS-1$
- )
- );
-
- if (!root.getNodeName().equalsIgnoreCase("launchConfigurations")) { //$NON-NLS-1$
- throw invalidFormat;
- }
-
- // read each launch configuration
- List configs = new ArrayList(4);
- NodeList list = root.getChildNodes();
- int length = list.getLength();
- for (int i = 0; i < length; ++i) {
- Node node = list.item(i);
- short type = node.getNodeType();
- if (type == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String nodeName = entry.getNodeName();
- if (!nodeName.equals("launchConfiguration")) { //$NON-NLS-1$
- throw invalidFormat;
- }
- String memento = entry.getAttribute("memento"); //$NON-NLS-1$
- if (memento == null) {
- throw invalidFormat;
- }
- configs.add(getLaunchConfiguration(memento));
- }
- }
- return configs;
- }
-
- /**
- * The specified project has just opened - add all launch
- * configs in the project to the index of all configs.
- *
- * @param project the project that has been opened
- * @exception CoreException if reading the index fails
- */
- protected void projectOpened(IProject project) throws CoreException {
- List configs = findLaunchConfigurations(project);
- if (!configs.isEmpty()) {
- List allList = getAllLaunchConfigurations();
- Iterator iterator = configs.iterator();
- while (iterator.hasNext()) {
- ILaunchConfiguration config = (ILaunchConfiguration) iterator.next();
- if (!allList.contains(config)) {
- allList.add(config);
- }
- }
- }
- }
-
- /**
- * The specified project has just closed - remove its
- * launch configurations from the cached index.
- *
- * @param project the project that has been closed
- * @exception CoreException if writing the index fails
- */
- protected void projectClosed(IProject project) throws CoreException {
- List configs = getLaunchConfigurations(project);
- if (!configs.isEmpty()) {
- getAllLaunchConfigurations().removeAll(configs);
- }
- }
-
- /**
- * Visitor for handling resource deltas.
- */
- class LaunchManagerVisitor implements IResourceDeltaVisitor {
- /**
- * @see IResourceDeltaVisitor#visit(IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) {
- if (delta == null) {
- return false;
- }
- if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
- if (delta.getResource() instanceof IProject) {
- IProject project = (IProject)delta.getResource();
- try {
- if (project.isOpen()) {
- LaunchManager.this.projectOpened(project);
- } else {
- LaunchManager.this.projectClosed(project);
- }
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- return false;
- }
- IResource resource = delta.getResource();
- if (resource instanceof IFile) {
- IFile file = (IFile)resource;
- if (ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION.equals(file.getFileExtension())) {
- IPath configPath = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- configPath = configPath.append(file.getFullPath());
- ILaunchConfiguration handle = new LaunchConfiguration(configPath);
- try {
- switch (delta.getKind()) {
- case IResourceDelta.ADDED :
- LaunchManager.this.launchConfigurationAdded(handle);
- break;
- case IResourceDelta.REMOVED :
- LaunchManager.this.launchConfigurationDeleted(handle);
- break;
- case IResourceDelta.CHANGED :
- LaunchManager.this.launchConfigurationChanged(handle);
- break;
- }
- } catch (CoreException e) {
- DebugPlugin.log(e);
- }
- }
- return false;
- } else if (resource instanceof IContainer) {
- return true;
- }
- return true;
- }
- }
-
- /**
- * @see ILaunchManager#addLaunchConfigurationListener(ILaunchConfigurationListener)
- */
- public void addLaunchConfigurationListener(ILaunchConfigurationListener listener) {
- fLaunchConfigurationListeners.add(listener);
- }
-
- /**
- * @see ILaunchManager#removeLaunchConfigurationListener(ILaunchConfigurationListener)
- */
- public void removeLaunchConfigurationListener(ILaunchConfigurationListener listener) {
- fLaunchConfigurationListeners.remove(listener);
- }
-
- /**
- * Register source locators.
- *
- * @exception CoreException if an exception occurrs reading
- * the extensions
- */
- private void initializeSourceLocators() throws CoreException {
- IPluginDescriptor descriptor= DebugPlugin.getDefault().getDescriptor();
- IExtensionPoint extensionPoint= descriptor.getExtensionPoint(DebugPlugin.EXTENSION_POINT_SOURCE_LOCATORS);
- IConfigurationElement[] infos= extensionPoint.getConfigurationElements();
- for (int i= 0; i < infos.length; i++) {
- IConfigurationElement configurationElement = infos[i];
- String id = configurationElement.getAttribute("id"); //$NON-NLS-1$
- if (id != null) {
- fSourceLocators.put(id,configurationElement);
- } else {
- // invalid status handler
- IStatus s = new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
- MessageFormat.format("Invalid source locator extentsion defined by plug-in '{0}': 'id' not specified.", new String[] {configurationElement.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier()} ), null);
- DebugPlugin.getDefault().log(s);
- }
- }
- }
-
- /**
- * @see ILaunchManager#newSourceLocator(String)
- */
- public IPersistableSourceLocator newSourceLocator(String identifier) throws CoreException {
- IConfigurationElement config = (IConfigurationElement)fSourceLocators.get(identifier);
- if (config == null) {
- throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, DebugException.INTERNAL_ERROR,
- MessageFormat.format("Source locator does not exist: {0}", new String[] {identifier} ), null));
- } else {
- return (IPersistableSourceLocator)config.createExecutableExtension("class");
- }
-
- }
-
-}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/Launcher.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/Launcher.java
deleted file mode 100644
index 297a625c2..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/Launcher.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.debug.core.ILauncher;
-import org.eclipse.debug.core.model.ILauncherDelegate;
-
-/**
- * A handle to a launcher extension that instantiates the actual
- * extension lazily.
- */
-public class Launcher implements ILauncher {
-
- /**
- * The configuration element that defines this launcher handle
- */
- private IConfigurationElement fConfigElement = null;
-
- /**
- * The underlying launcher, which is <code>null</code> until
- * it needs to be instantiated.
- */
- private ILauncherDelegate fDelegate = null;
-
- /**
- * Cache of the modes this launcher supports
- */
- private Set fModes;
-
- /**
- * Constructs a handle for a launcher extension.
- */
- public Launcher(IConfigurationElement element) {
- fConfigElement = element;
- }
-
- /**
- * @see ILauncher#getIdentifier()
- */
- public String getIdentifier() {
- return fConfigElement.getAttribute("id"); //$NON-NLS-1$
- }
-
- /**
- * Returns the set of modes specified in the configuration data.
- * The set contains "mode" constants defined in <code>ILaunchManager</code>
- */
- public Set getModes() {
- if (fModes == null) {
- String modes= fConfigElement.getAttribute("modes"); //$NON-NLS-1$
- if (modes == null) {
- return new HashSet(0);
- }
- StringTokenizer tokenizer= new StringTokenizer(modes, ","); //$NON-NLS-1$
- fModes = new HashSet(tokenizer.countTokens());
- while (tokenizer.hasMoreTokens()) {
- fModes.add(tokenizer.nextToken().trim());
- }
- }
- return fModes;
- }
-
- /**
- * @see ILauncher#getLabel()
- */
- public String getLabel() {
- return fConfigElement.getAttribute("label"); //$NON-NLS-1$
- }
-
- /**
- * @see ILauncher#getPerspectiveIdentifier()
- */
- public String getPerspectiveIdentifier() {
- return fConfigElement.getAttribute("perspective"); //$NON-NLS-1$
- }
-
- /**
- * Returns the launcher for this handle, instantiating it if required.
- */
- public ILauncherDelegate getDelegate() {
- if (fDelegate == null) {
- try {
- fDelegate = (ILauncherDelegate)fConfigElement.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (CoreException e) {
- //status logged in the #createExecutableExtension code
- }
- }
- return fDelegate;
- }
-
- /**
- * @see ILauncher#launch(Object[], String)
- */
- public boolean launch(Object[] elements, String mode) {
- return getDelegate().launch(elements, mode, this);
- }
-
- /**
- * Returns the configuration element for this extension
- */
- public IConfigurationElement getConfigurationElement() {
- return fConfigElement;
- }
-
- /**
- * @see ILauncher#getIconPath()
- */
- public String getIconPath() {
- return fConfigElement.getAttribute("icon"); //$NON-NLS-1$
- }
-} \ No newline at end of file
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ListenerList.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ListenerList.java
deleted file mode 100644
index f664e02f1..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ListenerList.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Local version of org.eclipse.jface.util.ListenerList (modified)s
- */
-public class ListenerList {
- /**
- * The current number of listeners.
- * Maintains invariant: 0 <= fSize <= listeners.length.
- */
- private int fSize;
-
- /**
- * The list of listeners. Initially <code>null</code> but initialized
- * to an array of size capacity the first time a listener is added.
- * Maintains invariant: listeners != null if and only if fSize != 0
- */
- private Object[] fListeners= null;
-
- /**
- * The empty array singleton instance, returned by getListeners()
- * when size == 0.
- */
- private static final Object[] EmptyArray= new Object[0];
-
- /**
- * Creates a listener list with the given initial capacity.
- *
- * @param capacity the number of listeners which this list can initially accept
- * without growing its internal representation; must be at least 1
- */
- public ListenerList(int capacity) {
- if (capacity < 1) {
- throw new IllegalArgumentException();
- }
- fListeners= new Object[capacity];
- fSize= 0;
- }
-
- /**
- * Adds a listener to the list.
- * Has no effect if an identical listener is already registered.
- *
- * @param listener a listener
- */
- public synchronized void add(Object listener) {
- if (listener == null) {
- throw new IllegalArgumentException();
- }
- // check for duplicates using identity
- for (int i= 0; i < fSize; ++i) {
- if (fListeners[i] == listener) {
- return;
- }
- }
- // grow array if necessary
- if (fSize == fListeners.length) {
- Object[] temp= new Object[(fSize * 2) + 1];
- System.arraycopy(fListeners, 0, temp, 0, fSize);
- fListeners= temp;
- }
- fListeners[fSize++]= listener;
- }
-
- /**
- * Returns an array containing all the registered listeners.
- * The resulting array is unaffected by subsequent adds or removes.
- * If there are no listeners registered, the result is an empty array
- * singleton instance (no garbage is created).
- * Use this method when notifying listeners, so that any modifications
- * to the listener list during the notification will have no effect on the
- * notification itself.
- */
- public synchronized Object[] getListeners() {
- if (fSize == 0) {
- return EmptyArray;
- }
- Object[] result= new Object[fSize];
- System.arraycopy(fListeners, 0, result, 0, fSize);
- return result;
- }
-
- /**
- * Removes a listener from the list.
- * Has no effect if an identical listener was not already registered.
- *
- * @param listener a listener
- */
- public synchronized void remove(Object listener) {
- if (listener == null) {
- throw new IllegalArgumentException();
- }
-
- for (int i= 0; i < fSize; ++i) {
- if (fListeners[i] == listener) {
- if (--fSize == 0) {
- fListeners= new Object[1];
- } else {
- if (i < fSize) {
- fListeners[i]= fListeners[fSize];
- }
- fListeners[fSize]= null;
- }
- return;
- }
- }
- }
-
- /**
- * Removes all the listeners from the list.
- */
- public void removeAll() {
- fListeners= new Object[0];
- fSize= 0;
- }
-
- /**
- * Returns the number of registered listeners
- *
- * @return the number of registered listeners
- */
- public int size() {
- return fSize;
- }
-}
-
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java
deleted file mode 100644
index 7013afffc..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/OutputStreamMonitor.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IStreamListener;
-import org.eclipse.debug.core.model.IStreamMonitor;
-
-/**
- * Monitors the output stream of a system process and notifies
- * listeners of additions to the stream.
- *
- * The output stream monitor reads system out (or err) via
- * and input stream.
- */
-public class OutputStreamMonitor implements IStreamMonitor {
- /**
- * The stream being monitored (connected system out or err).
- */
- private InputStream fStream;
-
- /**
- * A collection of listeners
- */
- private ListenerList fListeners= new ListenerList(1);
-
- /**
- * The local copy of the stream contents
- */
- private StringBuffer fContents;
-
- /**
- * The thread which reads from the stream
- */
- private Thread fThread;
-
- /**
- * The size of the read buffer
- */
- private static final int BUFFER_SIZE= 8192;
-
- /**
- * Whether or not this monitor has been killed.
- * When the monitor is killed, it stops reading
- * from the stream immediately.
- */
- private boolean fKilled= false;
- /**
- * Creates an output stream monitor on the
- * given stream (connected to system out or err).
- */
- public OutputStreamMonitor(InputStream stream) {
- fStream= stream;
- fContents= new StringBuffer();
- }
-
- /**
- * @see IStreamMonitor#addListener(IStreamListener)
- */
- public void addListener(IStreamListener listener) {
- fListeners.add(listener);
- }
-
- /**
- * Causes the monitor to close all
- * communications between it and the
- * underlying stream by waiting for the thread to terminate.
- */
- protected void close() {
- if (fThread != null) {
- Thread thread= fThread;
- fThread= null;
- try {
- thread.join();
- } catch (InterruptedException ie) {
- }
- fListeners.removeAll();
- }
- }
-
- /**
- * Notifies the listeners that text has
- * been appended to the stream.
- */
- private void fireStreamAppended(String text) {
- if (text == null)
- return;
- Object[] copiedListeners= fListeners.getListeners();
- for (int i= 0; i < copiedListeners.length; i++) {
- ((IStreamListener) copiedListeners[i]).streamAppended(text, this);
- }
- }
-
- /**
- * @see IStreamMonitor#getContents()
- */
- public String getContents() {
- return fContents.toString();
- }
-
- /**
- * Continually reads from the stream.
- * <p>
- * This method, along with the <code>startReading</code>
- * method is used to allow <code>OutputStreamMonitor</code>
- * to implement <code>Runnable</code> without publicly
- * exposing a <code>run</code> method.
- */
- private void read() {
- byte[] bytes= new byte[BUFFER_SIZE];
- int read = 0;
- while (read >= 0) {
- try {
- if (fKilled) {
- break;
- }
- read= fStream.read(bytes);
- if (read > 0) {
- String text= new String(bytes, 0, read);
- fContents.append(text);
- fireStreamAppended(text);
- }
- } catch (IOException ioe) {
- DebugPlugin.log(ioe);
- return;
- }
- }
- }
-
- protected void kill() {
- fKilled= true;
- if (fStream != null) {
- try {
- fStream.close();
- } catch(IOException e) {
- DebugPlugin.log(e);
- }
- }
- }
-
- /**
- * @see IStreamMonitor#removeListener(IStreamListener)
- */
- public void removeListener(IStreamListener listener) {
- fListeners.remove(listener);
- }
-
- /**
- * Starts a thread which reads from the stream
- */
- protected void startMonitoring() {
- if (fThread == null) {
- fThread= new Thread(new Runnable() {
- public void run() {
- read();
- }
- }, DebugCoreMessages.getString("OutputStreamMonitor.label")); //$NON-NLS-1$
- fThread.start();
- }
- }
-}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ProcessMonitor.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ProcessMonitor.java
deleted file mode 100644
index 81f2f0b22..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/ProcessMonitor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-/**
- * Monitors a system process, wiating for it to terminate, and
- * then notifies the associated runtime process.
- */
-public class ProcessMonitor {
- /**
- * The underlying <code>java.lang.Process</code> being monitored.
- */
- protected Process fOSProcess;
- /**
- * The <code>IProcess</code> which will be informed when this
- * monitor detects that the underlying process has terminated.
- */
- protected RuntimeProcess fProcess;
-
- /**
- * The <code>Thread</code> which is monitoring the underlying process.
- */
- protected Thread fThread;
- /**
- * Creates a new process monitor and starts monitoring the process
- * for termination.
- */
- public ProcessMonitor(RuntimeProcess process) {
- fProcess= process;
- fOSProcess= process.getSystemProcess();
- startMonitoring();
- }
-
- /**
- * Monitors the underlying process for termination. When the underlying
- * process terminates (or if the monitoring thread is interrupted),
- * inform the <code>IProcess</code> that it has terminated.
- */
- private void monitorProcess() {
- while (fOSProcess != null) {
- try {
- fOSProcess.waitFor();
- } catch (InterruptedException ie) {
- } finally {
- fOSProcess = null;
- fProcess.terminated();
- }
- }
- }
-
- /**
- * Starts monitoring the underlying process to determine
- * if it has terminated.
- */
- private void startMonitoring() {
- if (fThread == null) {
- fThread= new Thread(new Runnable() {
- public void run() {
- monitorProcess();
- }
- }, DebugCoreMessages.getString("ProcessMonitor.label")); //$NON-NLS-1$
- fThread.start();
- }
- }
-
- /**
- * Kills the monitoring thread.
- *
- * This method is to be useful for dealing with the error
- * case of an underlying process which has not informed this
- * monitor of its termination.
- */
- protected void killMonitoring() {
- fThread.interrupt();
- }
-}
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/RuntimeProcess.java
deleted file mode 100644
index 1ab66ae10..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/RuntimeProcess.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStreamsProxy;
-
-
-/**
- * A runtime process is a wrapper for a non-debuggable
- * system process. The process will appear in the debug UI with
- * console and termination support. The process creates a streams
- * proxy for itself, and a process monitor that monitors the
- * underlying system process for terminataion.
- */
-public class RuntimeProcess extends PlatformObject implements IProcess {
-
- private static final int MAX_WAIT_FOR_DEATH_ATTEMPTS = 10;
- private static final int TIME_TO_WAIT_FOR_THREAD_DEATH = 500; // ms
-
- /**
- * The launch this process is contained in
- */
- private ILaunch fLaunch;
-
- /**
- * The system process
- */
- private Process fProcess;
-
- /**
- * The monitor which listens for this runtime process' system process
- * to terminate.
- */
- private ProcessMonitor fMonitor;
-
- /**
- * The streams proxy for this process
- */
- private StreamsProxy fStreamsProxy;
-
- /**
- * The name of the process
- */
- private String fName;
-
- /**
- * Whether this process has been terminated
- */
- private boolean fTerminated;
-
- /**
- * Table of client defined attributes
- */
- private HashMap fAttributes;
-
- /**
- * Constructs a RuntimeProcess on the given system process
- * with the given name, adding this process to the given
- * launch.
- */
- public RuntimeProcess(ILaunch launch, Process process, String name) {
- setLaunch(launch);
- fProcess= process;
- fName= name;
- fTerminated= true;
- try {
- process.exitValue();
- } catch (IllegalThreadStateException e) {
- fTerminated= false;
- }
- fStreamsProxy = new StreamsProxy(this);
- fMonitor = new ProcessMonitor(this);
- launch.addProcess(this);
- fireCreationEvent();
- }
-
- /**
- * @see ITerminate#canTerminate()
- */
- public boolean canTerminate() {
- return !fTerminated;
- }
-
- /**
- * Returns the error stream of the underlying system process (connected
- * to the standard error of the process).
- */
- protected InputStream getErrorStream() {
- return fProcess.getErrorStream();
- }
-
- /**
- * Returns the input stream of the underlying system process (connected
- * to the standard out of the process).
- */
- protected InputStream getInputStream() {
- return fProcess.getInputStream();
- }
-
- /**
- * Returns the output stream of the underlying system process (connected
- * to the standard in of the process).
- */
- protected OutputStream getOutputStream() {
- return fProcess.getOutputStream();
- }
-
- /**
- * @see IProcess#getLabel()
- */
- public String getLabel() {
- return fName;
- }
-
- /**
- * Sets the launch this process is contained in
- *
- * @param launch the launch this process is contained in
- */
- private void setLaunch(ILaunch launch) {
- fLaunch = launch;
- }
-
- /**
- * @see IProcess#getLaunch()
- */
- public ILaunch getLaunch() {
- return fLaunch;
- }
-
- /**
- * Returns the underlying system process
- */
- protected Process getSystemProcess() {
- return fProcess;
- }
-
- /**
- * @see ITerminate#isTerminated()
- */
- public boolean isTerminated() {
- return fTerminated;
- }
-
- /**
- * @see ITerminate#terminate()
- */
- public void terminate() throws DebugException {
- if (!isTerminated()) {
- fProcess.destroy();
- fStreamsProxy.kill();
- int attempts = 0;
- while (attempts < MAX_WAIT_FOR_DEATH_ATTEMPTS) {
- try {
- if (fProcess != null) {
- fProcess.exitValue(); // throws exception if process not exited
- }
- return;
- } catch (IllegalThreadStateException ie) {
- }
- try {
- Thread.sleep(TIME_TO_WAIT_FOR_THREAD_DEATH);
- } catch (InterruptedException e) {
- }
- attempts++;
- }
- // clean-up
- fMonitor.killMonitoring();
- IStatus status = new Status(IStatus.ERROR, DebugPlugin.PLUGIN_ID, DebugException.TARGET_REQUEST_FAILED, DebugCoreMessages.getString("RuntimeProcess.terminate_failed"), null); //$NON-NLS-1$
- throw new DebugException(status);
- }
- }
-
- /**
- * Notification that the system process associated with this process
- * has terminated.
- */
- protected void terminated() {
- fStreamsProxy.close();
- fTerminated= true;
- fProcess= null;
- fireTerminateEvent();
- }
-
- /**
- * @see IProcess#getStreamsProxy()
- */
- public IStreamsProxy getStreamsProxy() {
- return fStreamsProxy;
- }
-
- /**
- * Fire a debug event marking the creation of this element.
- */
- private void fireCreationEvent() {
- fireEvent(new DebugEvent(this, DebugEvent.CREATE));
- }
-
- /**
- * Fire a debug event
- */
- private void fireEvent(DebugEvent event) {
- DebugPlugin manager= DebugPlugin.getDefault();
- if (manager != null) {
- manager.fireDebugEventSet(new DebugEvent[]{event});
- }
- }
-
- /**
- * Fire a debug event marking the termination of this process.
- */
- private void fireTerminateEvent() {
- fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
- }
-
- /**
- * @see IProcess#setAttribute(String, String)
- */
- public void setAttribute(String key, String value) {
- if (fAttributes == null) {
- fAttributes = new HashMap(5);
- }
- fAttributes.put(key, value);
- }
-
- /**
- * @see IProcess#getAttribute(String)
- */
- public String getAttribute(String key) {
- if (fAttributes == null) {
- return null;
- }
- return (String)fAttributes.get(key);
- }
-
- /**
- * @see IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- if (adapter.equals(IProcess.class)) {
- return this;
- }
- if (adapter.equals(IDebugTarget.class)) {
- ILaunch launch = getLaunch();
- IDebugTarget[] targets = launch.getDebugTargets();
- for (int i = 0; i < targets.length; i++) {
- if (this.equals(targets[i].getProcess())) {
- return targets[i];
- }
- }
- return null;
- }
- return super.getAdapter(adapter);
- }
-} \ No newline at end of file
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java
deleted file mode 100644
index f9486bc01..000000000
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/StreamsProxy.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.eclipse.debug.internal.core;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.debug.core.model.IStreamMonitor;
-import org.eclipse.debug.core.model.IStreamsProxy;
-import java.io.IOException;
-
-public class StreamsProxy implements IStreamsProxy {
- /**
- * The monitor for the output stream (connected to standard out of the process)
- */
- private OutputStreamMonitor fOutputMonitor;
- /**
- * The monitor for the error stream (connected to standard error of the process)
- */
- private OutputStreamMonitor fErrorMonitor;
- /**
- * The monitor for the input stream (connected to standard in of the process)
- */
- private InputStreamMonitor fInputMonitor;
- /**
- * Records the open/closed state of communications with
- * the underlying streams.
- */
- private boolean fClosed= false;
- /**
- * Creates a <code>StreamsProxy</code> on the streams
- * of the given <code>IProcess</code>.
- */
- public StreamsProxy(RuntimeProcess process) {
- if (process == null) {
- return;
- }
- fOutputMonitor= new OutputStreamMonitor(process.getInputStream());
- fErrorMonitor= new OutputStreamMonitor(process.getErrorStream());
- fInputMonitor= new InputStreamMonitor(process.getOutputStream());
- fOutputMonitor.startMonitoring();
- fErrorMonitor.startMonitoring();
- fInputMonitor.startMonitoring();
- }
-
- /**
- * Causes the proxy to close all
- * communications between it and the
- * underlying streams after all remaining data
- * in the streams is read.
- */
- protected void close() {
- fClosed= true;
- fOutputMonitor.close();
- fErrorMonitor.close();
- fInputMonitor.close();
- }
-
- /**
- * Causes the proxy to close all
- * communications between it and the
- * underlying streams immediately.
- * Data remaining in the streams is lost.
- */
- protected void kill() {
- fClosed= true;
- fOutputMonitor.kill();
- fErrorMonitor.kill();
- }
-
- /**
- * @see IStreamsProxy#getErrorStreamMonitor()
- */
- public IStreamMonitor getErrorStreamMonitor() {
- return fErrorMonitor;
- }
-
- /**
- * @see IStreamsProxy#getOutputStreamMonitor()
- */
- public IStreamMonitor getOutputStreamMonitor() {
- return fOutputMonitor;
- }
-
- /**
- * @see IStreamsProxy#write(String)
- */
- public void write(String input) throws IOException {
- if (!fClosed) {
- fInputMonitor.write(input);
- } else {
- throw new IOException();
- }
- }
-
-}

Back to the top