[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] New 'Source Lookup' tab
|
The 'Source Lookup' tab is added to the launch
configuration group. It allows to set the source search path for the launch
configuration.
|
Index: .classpath
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/.classpath,v
retrieving revision 1.2
diff -u -r1.2 .classpath
--- .classpath 15 Aug 2002 14:43:02 -0000 1.2
+++ .classpath 18 Feb 2003 20:36:56 -0000
@@ -9,6 +9,7 @@
<classpathentry kind="src" path="/org.eclipse.cdt.ui"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.core"/>
<classpathentry kind="src" path="/org.eclipse.cdt.debug.ui"/>
+ <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.launch/.project,v
retrieving revision 1.2
diff -u -r1.2 .project
--- .project 15 Aug 2002 14:43:02 -0000 1.2
+++ .project 18 Feb 2003 20:36:56 -0000
@@ -3,6 +3,7 @@
<name>org.eclipse.cdt.launch</name>
<comment></comment>
<projects>
+ <project>org.apache.xerces</project>
<project>org.eclipse.cdt.core</project>
<project>org.eclipse.cdt.debug.core</project>
<project>org.eclipse.cdt.debug.ui</project>
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/ChangeLog,v
retrieving revision 1.24
diff -u -r1.24 ChangeLog
--- ChangeLog 7 Feb 2003 20:22:03 -0000 1.24
+++ ChangeLog 18 Feb 2003 20:36:56 -0000
@@ -1,3 +1,17 @@
+2003-02-18 Mikhail Khodjaiants
+ New 'Source Lookup' tab.
+ * plugin.xml
+ Added dependency on the 'org.apache.xerces' plugin and the 'sourceLocator' extension.
+ * plugin.properties
+ Name for the source locator.
+ * CoreFileCLaunchConfigurationTabGroup.java
+ * LocalCLaunchConfigurationTabGroup.java
+ Added the 'Source Lookup' tab.
+ * DefaultSourceLocator.java
+ Implementation of 'IPersistableSourceLocator'.
+ * CSourceLookupTab.java
+ Implementation of 'ILaunchConfiguartionTab'.
+
2003-02-07 David Inglis
Refactor LaunchConstants into debug.core and make setting source locator happen before
Index: plugin.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/plugin.properties,v
retrieving revision 1.6
diff -u -r1.6 plugin.properties
--- plugin.properties 26 Nov 2002 13:49:03 -0000 1.6
+++ plugin.properties 18 Feb 2003 20:36:56 -0000
@@ -13,3 +13,5 @@
LocalCDTLaunch.name= C/C++ Local
CoreFileCDTLaunch.name= C/C++ Post-mortem debugger
+
+DefaultSourceLocator.name=Default C/C++ Source Locator
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/plugin.xml,v
retrieving revision 1.9
diff -u -r1.9 plugin.xml
--- plugin.xml 16 Dec 2002 20:50:27 -0000 1.9
+++ plugin.xml 18 Feb 2003 20:36:56 -0000
@@ -20,6 +20,7 @@
<import plugin="org.eclipse.cdt.ui"/>
<import plugin="org.eclipse.cdt.debug.core"/>
<import plugin="org.eclipse.cdt.debug.ui"/>
+ <import plugin="org.apache.xerces"/>
</requires>
@@ -81,6 +82,14 @@
id="org.eclipse.debug.ui.DebugPerspective">
</perspective>
</shortcut>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.sourceLocators">
+ <sourceLocator
+ name="%DefaultSourceLocator.name"
+ class="org.eclipse.cdt.launch.sourcelookup.DefaultSourceLocator"
+ id="org.eclipse.cdt.launch.DefaultSourceLocator">
+ </sourceLocator>
</extension>
</plugin>
Index: src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java,v
retrieving revision 1.2
diff -u -r1.2 CoreFileCLaunchConfigurationTabGroup.java
--- src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java 7 Feb 2003 20:22:03 -0000 1.2
+++ src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java 18 Feb 2003 20:36:56 -0000
@@ -2,6 +2,7 @@
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.cdt.launch.ui.CSourceLookupTab;
import org.eclipse.cdt.launch.ui.CorefileDebuggerTab;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
@@ -23,6 +24,7 @@
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(),
new CorefileDebuggerTab(),
+ new CSourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
Index: src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java,v
retrieving revision 1.3
diff -u -r1.3 LocalCLaunchConfigurationTabGroup.java
--- src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java 4 Nov 2002 20:01:11 -0000 1.3
+++ src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java 18 Feb 2003 20:36:56 -0000
@@ -4,6 +4,7 @@
import org.eclipse.cdt.launch.ui.CDebuggerTab;
import org.eclipse.cdt.launch.ui.CEnvironmentTab;
import org.eclipse.cdt.launch.ui.CMainTab;
+import org.eclipse.cdt.launch.ui.CSourceLookupTab;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
import org.eclipse.debug.ui.CommonTab;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
@@ -25,6 +26,7 @@
new CArgumentsTab(),
new CEnvironmentTab(),
new CDebuggerTab(),
+ new CSourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
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.2
diff -u -r1.2 DefaultSourceLocator.java
--- src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java 7 Feb 2003 20:22:03 -0000 1.2
+++ src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java 18 Feb 2003 20:36:56 -0000
@@ -5,11 +5,19 @@
*/
package org.eclipse.cdt.launch.sourcelookup;
+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.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
+import org.eclipse.cdt.debug.internal.core.CDebugUtils;
import org.eclipse.cdt.debug.ui.sourcelookup.CUISourceLocator;
import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IProject;
@@ -21,6 +29,10 @@
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.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* The wrapper for the CUISourceLocator class.
@@ -29,6 +41,10 @@
*/
public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptable
{
+ private static final String ELEMENT_NAME = "PromptingSourceLocator";
+ private static final String ATTR_PROJECT = "project";
+ private static final String ATTR_MEMENTO = "memento";
+
/**
* Identifier for the 'Default C/C++ Source Locator' extension
* (value <code>"org.eclipse.cdt.launch.DefaultSourceLocator"</code>).
@@ -45,11 +61,40 @@
{
}
+ /**
+ * Constructor for DefaultSourceLocator.
+ */
+ public DefaultSourceLocator( CUISourceLocator locator )
+ {
+ fSourceLocator = locator;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
*/
public String getMemento() throws CoreException
{
+ if ( fSourceLocator != null )
+ {
+ Document doc = new DocumentImpl();
+ Element node = doc.createElement( ELEMENT_NAME );
+ doc.appendChild( node );
+ node.setAttribute( ATTR_PROJECT, fSourceLocator.getProject().getName() );
+
+ IPersistableSourceLocator psl = getPersistableSourceLocator();
+ if ( psl != null )
+ {
+ node.setAttribute( ATTR_MEMENTO, psl.getMemento() );
+ }
+ try
+ {
+ return CDebugUtils.serializeDocument( doc, " " );
+ }
+ catch( IOException e )
+ {
+ abort( "Unable to create memento for C/C++ source locator.", e );
+ }
+ }
return null;
}
@@ -58,6 +103,60 @@
*/
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 prompting source locator - invalid format.", null );
+ }
+
+ String projectName = root.getAttribute( ATTR_PROJECT );
+ String data = root.getAttribute( ATTR_MEMENTO );
+ if ( isEmpty( projectName ) )
+ {
+ abort( "Unable to restore prompting source locator - invalid format.", null );
+ }
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
+ if ( project != null )
+ {
+ fSourceLocator = new CUISourceLocator( project );
+ }
+ else
+ {
+ abort( MessageFormat.format( "Unable to restore prompting source locator - project {0} not found.", new String[] { projectName } ), null );
+ }
+
+ IPersistableSourceLocator psl = getPersistableSourceLocator();
+ if ( psl != null )
+ {
+ psl.initializeFromMemento( data );
+ }
+ else
+ {
+ abort( "Unable to restore C/C++ source locator - invalid format.", null );
+ }
+ return;
+ }
+ catch( ParserConfigurationException e )
+ {
+ ex = e;
+ }
+ catch( SAXException e )
+ {
+ ex = e;
+ }
+ catch( IOException e )
+ {
+ ex = e;
+ }
+ abort( "Exception occurred initializing source locator.", ex );
}
/* (non-Javadoc)
@@ -87,11 +186,8 @@
return project;
}
}
- throw new CoreException( new Status( IStatus.ERROR,
- LaunchUIPlugin.getUniqueIdentifier(),
- ERROR,
- MessageFormat.format( "Project \"{0}\" does not exist.", new String[] { projectName } ),
- null ) );
+ abort( MessageFormat.format( "Project \"{0}\" does not exist.", new String[] { projectName } ), null );
+ return null;
}
/* (non-Javadoc)
@@ -111,5 +207,39 @@
}
}
return null;
+ }
+
+ private ICSourceLocator getCSourceLocator()
+ {
+ if ( fSourceLocator != null )
+ {
+ return (ICSourceLocator)fSourceLocator.getAdapter( ICSourceLocator.class );
+ }
+ return null;
+ }
+
+ private IPersistableSourceLocator getPersistableSourceLocator()
+ {
+ ICSourceLocator sl = getCSourceLocator();
+ return ( sl instanceof IPersistableSourceLocator ) ? (IPersistableSourceLocator)sl : null;
+ }
+
+ /**
+ * Throws an internal error exception
+ */
+ private void abort( String message, Throwable e ) throws CoreException
+ {
+ IStatus s = new Status( IStatus.ERROR,
+ LaunchUIPlugin.getUniqueIdentifier(),
+ ERROR,
+ message,
+ e );
+ throw new CoreException( s );
+ }
+
+
+ private boolean isEmpty( String string )
+ {
+ return string == null || string.length() == 0;
}
}
Index: src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
===================================================================
RCS file: src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
diff -N src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java 18 Feb 2003 20:36:56 -0000
@@ -0,0 +1,135 @@
+/*
+ *(c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ *
+ */
+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;
+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.widgets.Composite;
+
+/**
+ * Enter type comment.
+ *
+ * @since: Feb 13, 2003
+ */
+public class CSourceLookupTab extends CLaunchConfigurationTab
+{
+ private SourceLookupBlock fBlock = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl( Composite parent )
+ {
+ fBlock = new SourceLookupBlock();
+ fBlock.createControl( parent );
+ fBlock.setLaunchConfigurationDialog( getLaunchConfigurationDialog() );
+ setControl( fBlock.getControl() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ 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)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom( ILaunchConfiguration configuration )
+ {
+ try
+ {
+ String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" );
+ if ( isEmpty( id )|| DefaultSourceLocator.ID_DEFAULT_SOURCE_LOCATOR.equals( id ) )
+ {
+ 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.getSourceLocations() );
+ }
+ }
+ catch( CoreException e )
+ {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ 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 )
+ {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName()
+ {
+ return "Source Lookup";
+ }
+
+ 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;
+ }
+
+ private boolean isEmpty( String string )
+ {
+ return string == null || string.length() == 0;
+ }
+}