Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/launch
diff options
context:
space:
mode:
authorDavid Inglis2003-02-18 20:53:39 +0000
committerDavid Inglis2003-02-18 20:53:39 +0000
commit03dea5e8ecfa332c648e701eae9598f5dbe65b7e (patch)
treedc6c251f851affd005371f07ea6186782cd640ac /launch
parent92119895bc38768b581d1a2e77989c3a4282686f (diff)
downloadorg.eclipse.cdt-03dea5e8ecfa332c648e701eae9598f5dbe65b7e.tar.gz
org.eclipse.cdt-03dea5e8ecfa332c648e701eae9598f5dbe65b7e.tar.xz
org.eclipse.cdt-03dea5e8ecfa332c648e701eae9598f5dbe65b7e.zip
new source locator ui pages
Diffstat (limited to 'launch')
-rw-r--r--launch/org.eclipse.cdt.launch/.classpath1
-rw-r--r--launch/org.eclipse.cdt.launch/.project1
-rw-r--r--launch/org.eclipse.cdt.launch/ChangeLog14
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.properties2
-rw-r--r--launch/org.eclipse.cdt.launch/plugin.xml9
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java2
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java2
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/sourcelookup/DefaultSourceLocator.java140
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java135
9 files changed, 301 insertions, 5 deletions
diff --git a/launch/org.eclipse.cdt.launch/.classpath b/launch/org.eclipse.cdt.launch/.classpath
index 0f07927fa6c..0bf3d237864 100644
--- a/launch/org.eclipse.cdt.launch/.classpath
+++ b/launch/org.eclipse.cdt.launch/.classpath
@@ -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"/>
diff --git a/launch/org.eclipse.cdt.launch/.project b/launch/org.eclipse.cdt.launch/.project
index 070e320a827..c1a7b1fb1b6 100644
--- a/launch/org.eclipse.cdt.launch/.project
+++ b/launch/org.eclipse.cdt.launch/.project
@@ -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>
diff --git a/launch/org.eclipse.cdt.launch/ChangeLog b/launch/org.eclipse.cdt.launch/ChangeLog
index 8006369b22c..834e44e6cd9 100644
--- a/launch/org.eclipse.cdt.launch/ChangeLog
+++ b/launch/org.eclipse.cdt.launch/ChangeLog
@@ -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
diff --git a/launch/org.eclipse.cdt.launch/plugin.properties b/launch/org.eclipse.cdt.launch/plugin.properties
index ce44493232c..e97b00c8858 100644
--- a/launch/org.eclipse.cdt.launch/plugin.properties
+++ b/launch/org.eclipse.cdt.launch/plugin.properties
@@ -13,3 +13,5 @@ providerName=Eclipse.org
LocalCDTLaunch.name= C/C++ Local
CoreFileCDTLaunch.name= C/C++ Post-mortem debugger
+
+DefaultSourceLocator.name=Default C/C++ Source Locator
diff --git a/launch/org.eclipse.cdt.launch/plugin.xml b/launch/org.eclipse.cdt.launch/plugin.xml
index 9567d0330ab..248360780ba 100644
--- a/launch/org.eclipse.cdt.launch/plugin.xml
+++ b/launch/org.eclipse.cdt.launch/plugin.xml
@@ -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>
@@ -82,5 +83,13 @@
</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>
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
index 3f047ed6ab5..2013c1225fb 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/CoreFileCLaunchConfigurationTabGroup.java
@@ -2,6 +2,7 @@ package org.eclipse.cdt.launch.internal.ui;
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 @@ public class CoreFileCLaunchConfigurationTabGroup extends AbstractLaunchConfigur
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
new CMainTab(),
new CorefileDebuggerTab(),
+ new CSourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
index 8eed7789ade..278af2b4c64 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/internal/ui/LocalCLaunchConfigurationTabGroup.java
@@ -4,6 +4,7 @@ import org.eclipse.cdt.launch.ui.CArgumentsTab;
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 @@ public class LocalCLaunchConfigurationTabGroup extends AbstractLaunchConfigurati
new CArgumentsTab(),
new CEnvironmentTab(),
new CDebuggerTab(),
+ new CSourceLookupTab(),
new CommonTab()
};
setTabs(tabs);
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 1446adf5633..dd363a6d4e3 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
@@ -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.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.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* The wrapper for the CUISourceLocator class.
@@ -29,6 +41,10 @@ import org.eclipse.debug.core.model.IStackFrame;
*/
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 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
{
}
+ /**
+ * 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 class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
*/
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 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
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 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
}
}
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;
}
}
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
new file mode 100644
index 00000000000..08b07e4fc2c
--- /dev/null
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CSourceLookupTab.java
@@ -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;
+ }
+}

Back to the top