Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Changes for signal action

Index: .classpath
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/.classpath,v
retrieving revision 1.5
diff -u -r1.5 .classpath
--- .classpath 23 Sep 2002 20:46:53 -0000 1.5
+++ .classpath 14 Feb 2003 18:49:34 -0000
@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-    <classpathentry kind="src" path="src/"/>
+    <classpathentry kind="src" path="src"/>
+    <classpathentry kind="src" path="schema"/>
     <classpathentry kind="src" path="/org.eclipse.core.resources"/>
     <classpathentry kind="src" path="/org.eclipse.debug.core"/>
     <classpathentry kind="src" path="/org.eclipse.cdt.core"/>
+    <classpathentry exported="true" kind="src" path="/org.eclipse.cdt.core.win32"/>
+    <classpathentry kind="src" path="/org.apache.xerces"/>
     <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
     <classpathentry kind="src" path="/org.eclipse.core.boot"/>
     <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
Index: .project
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/.project,v
retrieving revision 1.5
diff -u -r1.5 .project
--- .project 23 Sep 2002 20:46:53 -0000 1.5
+++ .project 14 Feb 2003 18:49:34 -0000
@@ -3,7 +3,9 @@
  <name>org.eclipse.cdt.debug.core</name>
  <comment></comment>
  <projects>
+  <project>org.apache.xerces</project>
   <project>org.eclipse.cdt.core</project>
+  <project>org.eclipse.cdt.core.win32</project>
   <project>org.eclipse.core.boot</project>
   <project>org.eclipse.core.resources</project>
   <project>org.eclipse.core.runtime</project>
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/plugin.xml,v
retrieving revision 1.12
diff -u -r1.12 plugin.xml
--- plugin.xml 16 Dec 2002 20:50:29 -0000 1.12
+++ plugin.xml 14 Feb 2003 18:49:34 -0000
@@ -15,6 +15,7 @@
       <import plugin="org.eclipse.core.resources"/>
       <import plugin="org.eclipse.debug.core"/>
       <import plugin="org.eclipse.cdt.core"/>
+      <import plugin="org.apache.xerces"/>
    </requires>
 
 
Index: src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java,v
retrieving revision 1.2
diff -u -r1.2 ICSourceLocation.java
--- src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java 23 Sep 2002 22:44:54 -0000 1.2
+++ src/org/eclipse/cdt/debug/core/sourcelookup/ICSourceLocation.java 14 Feb 2003 18:49:34 -0000
@@ -43,4 +43,22 @@
   * @return the paths associated with this location
   */
  IPath[] getPaths();
+
+ /**
+  * Returns a memento for this source location from which this
+  * source location can be reconstructed.
+  *
+  * @return a memento for this source location
+  * @exception CoreException if unable to create a memento
+  */
+ public String getMemento() throws CoreException;

+ /**
+  * Initializes this source location from the given memento.
+  *
+  * @param memento a memento generated by this source location
+  * @exception CoreException if unable to initialize this source
+  *  location
+  */
+ public void initializeFrom( String memento ) throws CoreException;
 }
Index: src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java,v
retrieving revision 1.8
diff -u -r1.8 CDebugUtils.java
--- src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java 4 Feb 2003 21:29:47 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/CDebugUtils.java 14 Feb 2003 18:49:35 -0000
@@ -5,13 +5,21 @@
  */
 package org.eclipse.cdt.debug.internal.core;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.util.Arrays;
 
+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.IProject;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.IStatusHandler;
+import org.w3c.dom.Document;
 
 /**
  *
@@ -244,4 +252,22 @@
   }
   return false;
  }  
+
+ /**
+  * Serializes a XML document into a string - encoded in UTF8 format,
+  * with platform line separators.
+  *
+  * @param doc document to serialize
+  * @return the document as a string
+  */
+ public static String serializeDocument( Document doc) throws IOException
+ {
+  ByteArrayOutputStream s = new ByteArrayOutputStream();
+  OutputFormat format = new OutputFormat();
+  format.setIndenting( true );
+  format.setLineSeparator( System.getProperty( "line.separator" ) ); //$NON-NLS-1$
+  Serializer serializer = SerializerFactory.getSerializerFactory( Method.XML ).makeSerializer( new OutputStreamWriter( s, "UTF8" ), format );
+  serializer.asDOMSerializer().serialize( doc );
+  return s.toString( "UTF8" ); //$NON-NLS-1$  
+ }
 }
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java,v
retrieving revision 1.4
diff -u -r1.4 CDirectorySourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 29 Dec 2002 23:55:53 -0000 1.4
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceLocation.java 14 Feb 2003 18:49:35 -0000
@@ -6,16 +6,32 @@
 package org.eclipse.cdt.debug.internal.core.sourcelookup;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 
+import org.apache.xerces.dom.DocumentImpl;
 import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
 import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
+import org.eclipse.cdt.debug.internal.core.CDebugUtils;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IStorage;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /**
  *
@@ -26,6 +42,10 @@
  */
 public class CDirectorySourceLocation implements IDirectorySourceLocation
 {
+ private static final String ELEMENT_NAME = "cDirectorySourceLocation";
+ private static final String ATTR_DIRECTORY = "directory";
+ private static final String ATTR_ASSOCIATION = "association";
+
  /**
   * The root directory of this source location
   */
@@ -103,6 +123,11 @@
   return fDirectory;
  }
 
+ public void getDirectory( IPath path )
+ {
+  fDirectory = path;
+ }
+
  private void setAssociation( IPath association )
  {
   fAssociation = association;
@@ -176,5 +201,111 @@
  public IPath[] getPaths()
  {
   return new IPath[] { fDirectory };
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#getMemento()
+  */
+ public String getMemento() throws CoreException
+ {
+  Document doc = new DocumentImpl();
+  Element node = doc.createElement( ELEMENT_NAME );
+  doc.appendChild( node );
+  node.setAttribute( ATTR_DIRECTORY, getDirectory().toOSString() );
+  if ( getAssociation() != null )
+   node.setAttribute( ATTR_ASSOCIATION, getAssociation().toOSString() );
+  try
+  {
+   return CDebugUtils.serializeDocument( doc );
+  }
+  catch( IOException e )
+  {
+   abort( MessageFormat.format( "Unable to create memento for C/C++ directory source location {0}", new String[] { getDirectory().toOSString() } ), e );
+  }
+  // execution will not reach here
+  return null;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#initializeFrom(java.lang.String)
+  */
+ public void initializeFrom( 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 dir = root.getAttribute( ATTR_DIRECTORY );
+   if ( isEmpty( dir ) )
+   {
+    abort( "Unable to initialize source location - missing directory path", null );
+   }
+   else
+   {
+    IPath path = new Path( dir );
+    if ( path.isValidPath( dir ) && path.toFile().isDirectory() )
+    {
+     setDirectory( path );
+    }
+    else
+    {
+     abort( MessageFormat.format( "Unable to initialize source location - invalid directory path {0}", new String[] { dir } ), null );
+    }
+   }
+   dir = root.getAttribute( ATTR_ASSOCIATION );
+   if ( isEmpty( dir ) )
+   {
+    setAssociation( null );
+   }
+   else
+   {
+    IPath path = new Path( dir );
+    if ( path.isValidPath( dir ) && path.toFile().isDirectory() )
+    {
+     setAssociation( path );
+    }
+    else
+    {
+     setAssociation( null );
+    }
+   }
+   return;
+  }
+  catch( ParserConfigurationException e )
+  {
+   ex = e;
+  }
+  catch( SAXException e )
+  {
+   ex = e;
+  }
+  catch( IOException e )
+  {
+   ex = e;
+  }
+  abort( "Exception occurred initializing source location.", ex );
+ }
+
+ /**
+  * Throws an internal error exception
+  */
+ private void abort( String message, Throwable e ) throws CoreException
+ {
+  IStatus s = new Status( IStatus.ERROR,
+        CDebugCorePlugin.getUniqueIdentifier(),
+        CDebugCorePlugin.INTERNAL_ERROR,
+        message,
+        e );
+  throw new CoreException( s );
+ }
+
+ private boolean isEmpty( String string )
+ {
+  return string == null || string.length() == 0;
  }
 }
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java,v
retrieving revision 1.6
diff -u -r1.6 CProjectSourceLocation.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 29 Dec 2002 23:55:53 -0000 1.6
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CProjectSourceLocation.java 14 Feb 2003 18:49:35 -0000
@@ -6,19 +6,36 @@
 package org.eclipse.cdt.debug.internal.core.sourcelookup;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.HashSet;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xerces.dom.DocumentImpl;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
 import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
+import org.eclipse.cdt.debug.internal.core.CDebugUtils;
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 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.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /**
  *
@@ -28,6 +45,9 @@
  */
 public class CProjectSourceLocation implements IProjectSourceLocation
 {
+ private static final String ELEMENT_NAME = "cProjectSourceLocation";
+ private static final String ATTR_PROJECT = "project";
+
  /**
   * The project associated with this source location
   */
@@ -40,6 +60,13 @@
  /**
   * Constructor for CProjectSourceLocation.
   */
+ public CProjectSourceLocation()
+ {
+ }
+
+ /**
+  * Constructor for CProjectSourceLocation.
+  */
  public CProjectSourceLocation( IProject project )
  {
   setProject( project );
@@ -219,5 +246,86 @@
  {
   fCache.clear();
   fNotFoundCache.clear();
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#getMemento()
+  */
+ public String getMemento() throws CoreException
+ {
+  Document doc = new DocumentImpl();
+  Element node = doc.createElement( ELEMENT_NAME );
+  doc.appendChild( node );
+  node.setAttribute( ATTR_PROJECT, getProject().getName() );
+  
+  try
+  {
+   return CDebugUtils.serializeDocument( doc );
+  }
+  catch( IOException e )
+  {
+   abort( MessageFormat.format( "Unable to create memento for C/C++ project source location {0}.", new String[] { getProject().getName() } ), e );
+  }
+  // execution will not reach here
+  return null;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation#initializeFrom(java.lang.String)
+  */
+ public void initializeFrom( 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 name = root.getAttribute( ATTR_PROJECT );
+   if ( isEmpty( name ) )
+   {
+    abort( "Unable to initialize source location - missing project name", null );
+   }
+   else
+   {
+    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( name );
+    setProject( project );
+   }
+   return;
+  }
+  catch( ParserConfigurationException e )
+  {
+   ex = e;
+  }
+  catch( SAXException e )
+  {
+   ex = e;
+  }
+  catch( IOException e )
+  {
+   ex = e;
+  }
+  abort( "Exception occurred initializing source location.", ex );
+ }
+
+ /**
+  * Throws an internal error exception
+  */
+ private void abort( String message, Throwable e ) throws CoreException
+ {
+  IStatus s = new Status( IStatus.ERROR,
+        CDebugCorePlugin.getUniqueIdentifier(),
+        CDebugCorePlugin.INTERNAL_ERROR,
+        message,
+        e );
+  throw new CoreException( s );
+ }
+
+ private boolean isEmpty( String string )
+ {
+  return string == null || string.length() == 0;
  }
 }
Index: src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java,v
retrieving revision 1.8
diff -u -r1.8 CSourceLocator.java
--- src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 27 Jan 2003 22:28:13 -0000 1.8
+++ src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLocator.java 14 Feb 2003 18:49:35 -0000
@@ -6,20 +6,41 @@
 
 package org.eclipse.cdt.debug.internal.core.sourcelookup;
 
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xerces.dom.DocumentImpl;
 import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
+import org.eclipse.cdt.debug.internal.core.CDebugUtils;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.IPersistableSourceLocator;
 import org.eclipse.debug.core.model.IStackFrame;
+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;
 
 /**
  *
@@ -27,8 +48,13 @@
  *
  * @since Aug 19, 2002
  */
-public class CSourceLocator implements ICSourceLocator
+public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator
 {
+ private static final String ELEMENT_NAME = "cSourceLocator";
+ private static final String CHILD_NAME = "cSourceLocation";
+ private static final String ATTR_CLASS = "class";
+ private static final String ATTR_MEMENTO = "memento";
+
  /**
   * The array of source locations associated with this locator.
   */
@@ -245,5 +271,173 @@
    }
   }
   return result;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
+  */
+ public String getMemento() throws CoreException
+ {
+  Document doc = new DocumentImpl();
+  Element node = doc.createElement( ELEMENT_NAME );
+  doc.appendChild( node );
+
+  ICSourceLocation[] locations = getSourceLocations();
+  for ( int i = 0; i < locations.length; i++ )
+  {
+   Element child = doc.createElement( CHILD_NAME );
+   child.setAttribute( ATTR_CLASS, locations[i].getClass().getName() );
+   child.setAttribute( ATTR_MEMENTO, locations[i].getMemento() );
+   node.appendChild( child );
+  }
+  try
+  {
+   return CDebugUtils.serializeDocument( doc );
+  }
+  catch( IOException e )
+  {
+   abort( "Unable to create memento for C/C++ source locator.", e );
+  }
+  // execution will not reach here
+  return null;
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration)
+  */
+ public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
+ {
+  IProject project = getProject( configuration );
+  if ( project != null )
+  {
+   setSourceLocations( getDefaultSourceLocations( project ) );
+  }
+  else
+  {
+   setSourceLocations( new ICSourceLocation[0] );
+  }
+ }
+
+ /* (non-Javadoc)
+  * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String)
+  */
+ public void initializeFromMemento( 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();
+
+   if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) )
+   {
+    abort( "Unable to restore C/C++ source locator - invalid format.", null );
+   }
+
+   List sourceLocations = new ArrayList();
+   ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader();
+
+   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;
+     if ( entry.getNodeName().equalsIgnoreCase( CHILD_NAME ) )
+     {
+      String className = entry.getAttribute( ATTR_CLASS );
+      String data = "" ATTR_MEMENTO );
+      if ( isEmpty( className ) )
+      {
+       abort( "Unable to restore C/C++ source locator - invalid format.", null );
+      }
+      Class clazz = null;
+      try
+      {
+       clazz = classLoader.loadClass( className );
+      }
+      catch( ClassNotFoundException e )
+      {
+       abort( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ), e );
+      }
+
+      ICSourceLocation location = null;
+      try
+      {
+       location = (ICSourceLocation)clazz.newInstance();
+      }
+      catch( IllegalAccessException e )
+      {
+       abort( "Unable to restore source location.", e );
+      }
+      catch( InstantiationException e )
+      {
+       abort( "Unable to restore source location.", e );
+      }
+      location.initializeFrom( data );
+      sourceLocations.add( location );
+     }
+     else
+     {
+      abort( "Unable to restore C/C++ source locator - invalid format.", null );
+     }
+    }
+   }
+   setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
+   return;
+  }
+  catch( ParserConfigurationException e )
+  {
+   ex = e;
+  }
+  catch( SAXException e )
+  {
+   ex = e;
+  }
+  catch( IOException e )
+  {
+   ex = e;
+  }
+  abort( "Exception occurred initializing source locator.", ex );
+ }
+
+ /**
+  * Throws an internal error exception
+  */
+ private void abort( String message, Throwable e ) throws CoreException
+ {
+  IStatus s = new Status( IStatus.ERROR,
+        CDebugCorePlugin.getUniqueIdentifier(),
+        CDebugCorePlugin.INTERNAL_ERROR,
+        message,
+        e );
+  throw new CoreException( s );
+ }
+
+
+ private boolean isEmpty( String string )
+ {
+  return string == null || string.length() == 0;
+ }

+ private IProject getProject( ILaunchConfiguration configuration )
+ {
+  IProject project = null;
+  try
+  {
+   String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" );
+   if ( !isEmpty( projectName ) )
+    project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
+  }
+  catch( CoreException e )
+  {
+  }
+  return project;
  }
 }

Back to the top