Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fixes for the 'Source' launch configuration tab

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- ChangeLog 18 Feb 2003 20:53:39 -0000 1.25
+++ ChangeLog 20 Feb 2003 21:43:21 -0000
@@ -1,3 +1,8 @@
+2003-02-20 Mikhail Khodjaiants
+ The generation of launch configuration shouldn't fail if project is not set or project name is empty.
+ * DefaultSourceLocator.java
+ * CSourceLookupTab.java
+
 2003-02-18 Mikhail Khodjaiants
  New 'Source Lookup' tab.
  * plugin.xml
Index: src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java,v
retrieving revision 1.3
diff -u -r1.3 DefaultSourceLocator.java
--- src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java 18 Feb 2003 20:53:39 -0000 1.3
+++ src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java 20 Feb 2003 21:43:21 -0000
@@ -178,7 +178,7 @@
  private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
  {
   String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
-  if ( projectName != null )
+  if ( !isEmpty( projectName ) )
   {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
    if ( project.exists() )
Index: src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java,v
retrieving revision 1.1
diff -u -r1.1 CSourceLookupTab.java
--- src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java 18 Feb 2003 20:53:39 -0000 1.1
+++ src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java 20 Feb 2003 21:43:21 -0000
@@ -7,7 +7,6 @@
 
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock;
 import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
 import org.eclipse.core.resources.IProject;
@@ -15,6 +14,8 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 
 /**
@@ -31,10 +32,12 @@
   */
  public void createControl( Composite parent )
  {
+  Composite control = new Composite( parent, SWT.NONE );
+  control.setLayout( new GridLayout() );
   fBlock = new SourceLookupBlock();
-  fBlock.createControl( parent );
+  fBlock.createControl( control );
   fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
-  setControl( fBlock.getControl() );
+  setControl( control );
  }
 
  /* (non-Javadoc)
@@ -43,16 +46,6 @@
  public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
  {
   configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
-  DefaultSourceLocator locator = new DefaultSourceLocator();
-  try
-  {
-   locator.initializeDefaults( configuration );
-   configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
-  }
-  catch( CoreException e )
-  {
-   CDebugUIPlugin.log( e.getStatus() );
-  }
  }
 
  /* (non-Javadoc)
@@ -60,28 +53,33 @@
   */
  public void initializeFrom( ILaunchConfiguration configuration )
  {
-  try
+  IProject project = getProject( configuration );
+  fBlock.setProject( getProject( configuration ) );
+  if ( project != null )
   {
-   String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
-   if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
+   try
    {
-    DefaultSourceLocator locator = new DefaultSourceLocator();
-    String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
-    if ( !isEmpty( memento ) )
-    {
-     locator.initializeFromMemento( memento );    
-    }
-    else
+    String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
+    if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
     {
-     locator.initializeDefaults( configuration );
+     DefaultSourceLocator locator = new DefaultSourceLocator();
+     String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
+     if ( !isEmpty( memento ) )
+     {
+      locator.initializeFromMemento( memento );    
+     }
+     else
+     {
+      locator.initializeDefaults( configuration );
+     }
+     ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
+     if ( clocator != null )
+      fBlock.initialize( clocator );
     }
-    ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
-    if ( clocator != null )
-     fBlock.initialize( clocator.getSourceLocations() );
    }
-  }
-  catch( CoreException e )
-  {
+   catch( CoreException e )
+   {
+   }
   }
  }
 
@@ -90,18 +88,22 @@
   */
  public void performApply( ILaunchConfigurationWorkingCopy configuration )
  {
-  DefaultSourceLocator locator = new DefaultSourceLocator();
-  try
-  {
-   locator.initializeDefaults( configuration );
-   ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
-   if ( clocator != null )
-    clocator.setSourceLocations( fBlock.getSourceLocations() );
-   configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
-   configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
-  }
-  catch( CoreException e )
+  configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
+  IProject project = getProject( configuration );
+  if ( project != null )
   {
+   DefaultSourceLocator locator = new DefaultSourceLocator();
+   try
+   {
+    locator.initializeDefaults( configuration );
+    ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
+    if ( clocator != null )
+     clocator.setSourceLocations( fBlock.getSourceLocations() );
+    configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
+   }
+   catch( CoreException e )
+   {
+   }
   }
  }
 
@@ -110,7 +112,7 @@
   */
  public String getName()
  {
-  return "Source Lookup";
+  return "Source";
  }
 
  private IProject getProject( ILaunchConfiguration configuration )
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- ChangeLog	18 Feb 2003 20:53:39 -0000	1.25
+++ ChangeLog	20 Feb 2003 21:43:11 -0000
@@ -1,3 +1,8 @@
+2003-02-20 Mikhail Khodjaiants
+	The generation of launch configuration shouldn't fail if project is not set or project name is empty.
+	* DefaultSourceLocator.java
+	* CSourceLookupTab.java
+
 2003-02-18 Mikhail Khodjaiants
 	New 'Source Lookup' tab.
 	* plugin.xml
Index: src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java,v
retrieving revision 1.3
diff -u -r1.3 DefaultSourceLocator.java
--- src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java	18 Feb 2003 20:53:39 -0000	1.3
+++ src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java	20 Feb 2003 21:43:11 -0000
@@ -178,7 +178,7 @@
 	private IProject getProject( ILaunchConfiguration configuration ) throws CoreException
 	{
 		String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
-		if ( projectName != null )
+		if ( !isEmpty( projectName ) )
 		{
 			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
 			if ( project.exists() )
Index: src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java,v
retrieving revision 1.1
diff -u -r1.1 CSourceLookupTab.java
--- src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java	18 Feb 2003 20:53:39 -0000	1.1
+++ src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java	20 Feb 2003 21:43:11 -0000
@@ -7,7 +7,6 @@
 
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
 import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
-import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
 import org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupBlock;
 import org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator;
 import org.eclipse.core.resources.IProject;
@@ -15,6 +14,8 @@
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 
 /**
@@ -31,10 +32,12 @@
 	 */
 	public void createControl( Composite parent )
 	{
+		Composite control = new Composite( parent, SWT.NONE );
+		control.setLayout( new GridLayout() );
 		fBlock = new SourceLookupBlock();
-		fBlock.createControl( parent );
+		fBlock.createControl( control );
 		fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
-		setControl( fBlock.getControl() );
+		setControl( control );
 	}
 
 	/* (non-Javadoc)
@@ -43,16 +46,6 @@
 	public void setDefaults( ILaunchConfigurationWorkingCopy configuration )
 	{
 		configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
-		DefaultSourceLocator locator = new DefaultSourceLocator();
-		try
-		{
-			locator.initializeDefaults( configuration );
-			configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
-		}
-		catch( CoreException e )
-		{
-			CDebugUIPlugin.log( e.getStatus() );
-		}
 	}
 
 	/* (non-Javadoc)
@@ -60,28 +53,33 @@
 	 */
 	public void initializeFrom( ILaunchConfiguration configuration )
 	{
-		try
+		IProject project = getProject( configuration );
+		fBlock.setProject( getProject( configuration ) );
+		if ( project != null )
 		{
-			String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
-			if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
+			try
 			{
-				DefaultSourceLocator locator = new DefaultSourceLocator();
-				String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
-				if ( !isEmpty( memento ) )
-				{
-					locator.initializeFromMemento( memento );				
-				}
-				else
+				String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
+				if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
 				{
-					locator.initializeDefaults( configuration );
+					DefaultSourceLocator locator = new DefaultSourceLocator();
+					String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" );
+					if ( !isEmpty( memento ) )
+					{
+						locator.initializeFromMemento( memento );				
+					}
+					else
+					{
+						locator.initializeDefaults( configuration );
+					}
+					ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
+					if ( clocator != null )
+						fBlock.initialize( clocator );
 				}
-				ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
-				if ( clocator != null )
-					fBlock.initialize( clocator.getSourceLocations() );
 			}
-		}
-		catch( CoreException e )
-		{
+			catch( CoreException e )
+			{
+			}
 		}
 	}
 
@@ -90,18 +88,22 @@
 	 */
 	public void performApply( ILaunchConfigurationWorkingCopy configuration )
 	{
-		DefaultSourceLocator locator = new DefaultSourceLocator();
-		try
-		{
-			locator.initializeDefaults( configuration );
-			ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
-			if ( clocator != null )
-				clocator.setSourceLocations( fBlock.getSourceLocations() );
-			configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
-			configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
-		}
-		catch( CoreException e )
+		configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR );
+		IProject project = getProject( configuration );
+		if ( project != null )
 		{
+			DefaultSourceLocator locator = new DefaultSourceLocator();
+			try
+			{
+				locator.initializeDefaults( configuration );
+				ICSourceLocator clocator = (ICSourceLocator)locator.getAdapter( ICSourceLocator.class );
+				if ( clocator != null )
+					clocator.setSourceLocations( fBlock.getSourceLocations() );
+				configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
+			}
+			catch( CoreException e )
+			{
+			}
 		}
 	}
 
@@ -110,7 +112,7 @@
 	 */
 	public String getName()
 	{
-		return "Source Lookup";
+		return "Source";
 	}
 
 	private IProject getProject( ILaunchConfiguration configuration )

Back to the top