From c0bb4d9b2353da5e5ae49ef54860f9233100bc88 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Thu, 20 Feb 2003 22:03:23 +0000 Subject: fix source locator --- launch/org.eclipse.cdt.launch/ChangeLog | 5 ++ .../launch/sourcelookup/DefaultSourceLocator.java | 2 +- .../org/eclipse/cdt/launch/ui/CDebuggerTab.java | 6 +- .../eclipse/cdt/launch/ui/CSourceLookupTab.java | 86 +++++++++++----------- 4 files changed, 52 insertions(+), 47 deletions(-) (limited to 'launch/org.eclipse.cdt.launch') diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog index 834e44e6cd9..2fcdcc180a1 100644 --- a/launch/org.eclipse.cdt.launch/ChangeLog +++ b/launch/org.eclipse.cdt.launch/ChangeLog @@ -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 diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java index dd363a6d4e3..8a3e7f46c34 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java @@ -178,7 +178,7 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab 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() ) diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java index 90508d7e3b1..5e66daca422 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CDebuggerTab.java @@ -106,10 +106,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab { String configPlatform = getPlatform(config); String programCPU = "native"; ICElement ce = getContext(config, configPlatform); - try { + if (ce instanceof IBinary) { IBinary bin = (IBinary) ce; programCPU = bin.getCPU(); - } catch (Exception e) { } fDCombo.removeAll(); debugConfigs = CDebugCorePlugin.getDefault().getDebugConfigurations(); @@ -246,10 +245,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab { String projectPlatform = getPlatform(config); String projectCPU = "native"; if (ce != null) { - try { + if (ce instanceof IBinary) { IBinary bin = (IBinary) ce; projectCPU = bin.getCPU(); - } catch (Exception e) { } } ICDebugConfiguration debugConfig = getDebugConfig(); diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java index 08b07e4fc2c..3b1da503e5f 100644 --- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java +++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java @@ -7,7 +7,6 @@ package org.eclipse.cdt.launch.ui; 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.resources.ResourcesPlugin; 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 class CSourceLookupTab extends CLaunchConfigurationTab */ 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 class CSourceLookupTab extends CLaunchConfigurationTab 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 class CSourceLookupTab extends CLaunchConfigurationTab */ 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 ) ) + String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" ); + if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) ) { - locator.initializeFromMemento( memento ); + 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 ); } - else - { - locator.initializeDefaults( configuration ); - } - 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 class CSourceLookupTab extends CLaunchConfigurationTab */ 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 class CSourceLookupTab extends CLaunchConfigurationTab */ public String getName() { - return "Source Lookup"; + return "Source"; } private IProject getProject( ILaunchConfiguration configuration ) -- cgit v1.2.3