mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 11:03:28 +02:00
Automatically update the list of source locations when the list of the referenced projects is modified.
This commit is contained in:
parent
b43dece8ee
commit
0642ccd81b
15 changed files with 792 additions and 153 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2003-07-17 Mikhail Khodjaiants
|
||||||
|
Automatically update the list of source locations when the list of the referenced
|
||||||
|
projects is modified.
|
||||||
|
* ICSourceLocator.java: added new method - 'getProject'
|
||||||
|
* IProjectSourceLocation.java: added new method - 'isGeneric'
|
||||||
|
* SourceLocationFactory.java: new class factory for source locations.
|
||||||
|
* CSourceLocator.java
|
||||||
|
* CDirectorySourceLocation.java
|
||||||
|
* CProjectSourceLocation.java
|
||||||
|
* CSourceManager.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
|
||||||
2003-06-30 Mikhail Khodjaiants
|
2003-06-30 Mikhail Khodjaiants
|
||||||
Fix for PR 39372: Breakpoints don't get activated when symbols are loaded.
|
Fix for PR 39372: Breakpoints don't get activated when symbols are loaded.
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.core.sourcelookup;
|
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.debug.core.model.ISourceLocator;
|
import org.eclipse.debug.core.model.ISourceLocator;
|
||||||
import org.eclipse.debug.core.model.IStackFrame;
|
import org.eclipse.debug.core.model.IStackFrame;
|
||||||
|
@ -18,6 +19,13 @@ import org.eclipse.debug.core.model.IStackFrame;
|
||||||
*/
|
*/
|
||||||
public interface ICSourceLocator extends ISourceLocator
|
public interface ICSourceLocator extends ISourceLocator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Returns the project this source locator is associated with or <code>null</code>.
|
||||||
|
*
|
||||||
|
* @return project this source locator is associated with or <code>null</code>
|
||||||
|
*/
|
||||||
|
IProject getProject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the line number of the instruction pointer in the specified
|
* Returns the line number of the instruction pointer in the specified
|
||||||
* stack frame that corresponds to a line in an associated source element,
|
* stack frame that corresponds to a line in an associated source element,
|
||||||
|
|
|
@ -16,4 +16,6 @@ import org.eclipse.core.resources.IProject;
|
||||||
public interface IProjectSourceLocation extends ICSourceLocation
|
public interface IProjectSourceLocation extends ICSourceLocation
|
||||||
{
|
{
|
||||||
IProject getProject();
|
IProject getProject();
|
||||||
|
|
||||||
|
boolean isGeneric();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.debug.core.sourcelookup;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter type comment.
|
||||||
|
*
|
||||||
|
* @since Jul 14, 2003
|
||||||
|
*/
|
||||||
|
public class SourceLocationFactory
|
||||||
|
{
|
||||||
|
public static IProjectSourceLocation createProjectSourceLocation( IProject project )
|
||||||
|
{
|
||||||
|
return new CProjectSourceLocation( project );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IProjectSourceLocation createProjectSourceLocation( IProject project, boolean generated )
|
||||||
|
{
|
||||||
|
return new CProjectSourceLocation( project, generated );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IDirectorySourceLocation createDirectorySourceLocation( IPath directory )
|
||||||
|
{
|
||||||
|
return new CDirectorySourceLocation( directory );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IDirectorySourceLocation createDirectorySourceLocation( IPath directory, IPath association )
|
||||||
|
{
|
||||||
|
return new CDirectorySourceLocation( directory, association );
|
||||||
|
}
|
||||||
|
}
|
|
@ -87,6 +87,7 @@ import org.eclipse.cdt.debug.internal.core.sourcelookup.DisassemblyManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarkerDelta;
|
import org.eclipse.core.resources.IMarkerDelta;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -303,6 +304,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
initializeBreakpoints();
|
initializeBreakpoints();
|
||||||
initializeRegisters();
|
initializeRegisters();
|
||||||
initializeMemoryManager();
|
initializeMemoryManager();
|
||||||
|
initializeSourceManager();
|
||||||
getLaunch().addDebugTarget( this );
|
getLaunch().addDebugTarget( this );
|
||||||
fireCreationEvent();
|
fireCreationEvent();
|
||||||
}
|
}
|
||||||
|
@ -398,6 +400,17 @@ public class CDebugTarget extends CDebugElement
|
||||||
fMemoryManager = new CMemoryManager( this );
|
fMemoryManager = new CMemoryManager( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void initializeSourceManager()
|
||||||
|
{
|
||||||
|
ISourceLocator locator = getLaunch().getSourceLocator();
|
||||||
|
if ( locator instanceof IAdaptable )
|
||||||
|
{
|
||||||
|
IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
|
||||||
|
if ( listener != null )
|
||||||
|
CCorePlugin.getWorkspace().addResourceChangeListener( listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
|
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
|
||||||
*/
|
*/
|
||||||
|
@ -1183,6 +1196,7 @@ public class CDebugTarget extends CDebugElement
|
||||||
disposeSignalManager();
|
disposeSignalManager();
|
||||||
disposeRegisterManager();
|
disposeRegisterManager();
|
||||||
disposeDisassemblyManager();
|
disposeDisassemblyManager();
|
||||||
|
disposeSourceManager();
|
||||||
removeAllExpressions();
|
removeAllExpressions();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2575,4 +2589,15 @@ public class CDebugTarget extends CDebugElement
|
||||||
{
|
{
|
||||||
return getRegisterManager().getRegisterGroups();
|
return getRegisterManager().getRegisterGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void disposeSourceManager()
|
||||||
|
{
|
||||||
|
ISourceLocator locator = getSourceLocator();
|
||||||
|
if ( locator instanceof IAdaptable )
|
||||||
|
{
|
||||||
|
IResourceChangeListener listener = (IResourceChangeListener)((IAdaptable)locator).getAdapter( IResourceChangeListener.class );
|
||||||
|
if ( listener != null )
|
||||||
|
CCorePlugin.getWorkspace().removeResourceChangeListener( listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,4 +307,27 @@ public class CDirectorySourceLocation implements IDirectorySourceLocation
|
||||||
{
|
{
|
||||||
return string == null || string.length() == 0;
|
return string == null || string.length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals( Object obj )
|
||||||
|
{
|
||||||
|
if ( obj instanceof IDirectorySourceLocation )
|
||||||
|
{
|
||||||
|
IPath dir = ((IDirectorySourceLocation)obj).getDirectory();
|
||||||
|
IPath association = ((IDirectorySourceLocation)obj).getAssociation();
|
||||||
|
if ( dir == null )
|
||||||
|
return false;
|
||||||
|
boolean result = dir.equals( getDirectory() );
|
||||||
|
if ( result )
|
||||||
|
{
|
||||||
|
if ( association == null && getAssociation() == null )
|
||||||
|
return true;
|
||||||
|
if ( association != null )
|
||||||
|
return association.equals( getAssociation() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
{
|
{
|
||||||
private static final String ELEMENT_NAME = "cProjectSourceLocation";
|
private static final String ELEMENT_NAME = "cProjectSourceLocation";
|
||||||
private static final String ATTR_PROJECT = "project";
|
private static final String ATTR_PROJECT = "project";
|
||||||
|
private static final String ATTR_GENERIC = "generic";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The project associated with this source location
|
* The project associated with this source location
|
||||||
|
@ -57,6 +58,8 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
|
|
||||||
private HashSet fNotFoundCache = new HashSet( 20 );
|
private HashSet fNotFoundCache = new HashSet( 20 );
|
||||||
|
|
||||||
|
private boolean fGenerated = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CProjectSourceLocation.
|
* Constructor for CProjectSourceLocation.
|
||||||
*/
|
*/
|
||||||
|
@ -70,6 +73,16 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
public CProjectSourceLocation( IProject project )
|
public CProjectSourceLocation( IProject project )
|
||||||
{
|
{
|
||||||
setProject( project );
|
setProject( project );
|
||||||
|
fGenerated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for CProjectSourceLocation.
|
||||||
|
*/
|
||||||
|
public CProjectSourceLocation( IProject project, boolean generated )
|
||||||
|
{
|
||||||
|
setProject( project );
|
||||||
|
fGenerated = generated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -240,7 +253,7 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
Element node = doc.createElement( ELEMENT_NAME );
|
Element node = doc.createElement( ELEMENT_NAME );
|
||||||
doc.appendChild( node );
|
doc.appendChild( node );
|
||||||
node.setAttribute( ATTR_PROJECT, getProject().getName() );
|
node.setAttribute( ATTR_PROJECT, getProject().getName() );
|
||||||
|
node.setAttribute( ATTR_GENERIC, new Boolean( isGeneric() ).toString() );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return CDebugUtils.serializeDocument( doc, " " );
|
return CDebugUtils.serializeDocument( doc, " " );
|
||||||
|
@ -277,6 +290,10 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( name );
|
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( name );
|
||||||
setProject( project );
|
setProject( project );
|
||||||
}
|
}
|
||||||
|
String isGeneric = root.getAttribute( ATTR_GENERIC );
|
||||||
|
if ( isGeneric == null || isGeneric.trim().length() == 0 )
|
||||||
|
isGeneric = Boolean.FALSE.toString();
|
||||||
|
setGenerated( isGeneric.equals( Boolean.TRUE.toString() ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch( ParserConfigurationException e )
|
catch( ParserConfigurationException e )
|
||||||
|
@ -311,4 +328,27 @@ public class CProjectSourceLocation implements IProjectSourceLocation
|
||||||
{
|
{
|
||||||
return string == null || string.length() == 0;
|
return string == null || string.length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation#isGenerated()
|
||||||
|
*/
|
||||||
|
public boolean isGeneric()
|
||||||
|
{
|
||||||
|
return fGenerated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGenerated( boolean b )
|
||||||
|
{
|
||||||
|
fGenerated = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals( Object obj )
|
||||||
|
{
|
||||||
|
if ( obj instanceof IProjectSourceLocation )
|
||||||
|
return getProject().getName().equals( ((IProjectSourceLocation)obj).getProject().getName() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -20,14 +22,19 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.apache.xerces.dom.DocumentImpl;
|
import org.apache.xerces.dom.DocumentImpl;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
import org.eclipse.cdt.core.resources.FileStorage;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
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.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
|
||||||
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -50,12 +57,20 @@ import org.xml.sax.SAXException;
|
||||||
* @since Aug 19, 2002
|
* @since Aug 19, 2002
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator
|
public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocator, IResourceChangeListener
|
||||||
{
|
{
|
||||||
private static final String ELEMENT_NAME = "cSourceLocator";
|
private static final String SOURCE_LOCATOR_NAME = "cSourceLocator";
|
||||||
private static final String CHILD_NAME = "cSourceLocation";
|
private static final String DISABLED_GENERIC_PROJECT_NAME = "disabledGenericProject";
|
||||||
|
private static final String ADDITIONAL_SOURCE_LOCATION_NAME = "additionalSourceLocation";
|
||||||
|
private static final String SOURCE_LOCATION_NAME = "cSourceLocation";
|
||||||
private static final String ATTR_CLASS = "class";
|
private static final String ATTR_CLASS = "class";
|
||||||
private static final String ATTR_MEMENTO = "memento";
|
private static final String ATTR_MEMENTO = "memento";
|
||||||
|
private static final String ATTR_PROJECT_NAME = "projectName";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The project associated with this locator.
|
||||||
|
*/
|
||||||
|
private IProject fProject = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The array of source locations associated with this locator.
|
* The array of source locations associated with this locator.
|
||||||
|
@ -63,27 +78,17 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
private ICSourceLocation[] fSourceLocations;
|
private ICSourceLocation[] fSourceLocations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CSourceLocator.
|
* The array of projects referenced by main project.
|
||||||
*/
|
*/
|
||||||
public CSourceLocator()
|
private List fReferencedProjects = new ArrayList( 10 );
|
||||||
{
|
|
||||||
setSourceLocations( new ICSourceLocation[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CSourceLocator.
|
* Constructor for CSourceLocator.
|
||||||
*/
|
*/
|
||||||
public CSourceLocator( IProject project )
|
public CSourceLocator( IProject project )
|
||||||
{
|
{
|
||||||
fSourceLocations = getDefaultSourceLocations( project );
|
setProject( project );
|
||||||
}
|
setReferencedProjects();
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for CSourceLocator.
|
|
||||||
*/
|
|
||||||
public CSourceLocator( ICSourceLocation[] locations )
|
|
||||||
{
|
|
||||||
fSourceLocations = locations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -200,7 +205,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
if ( project != null && project.exists() )
|
if ( project != null && project.exists() )
|
||||||
{
|
{
|
||||||
list.add( new CProjectSourceLocation( project ) );
|
list.add( SourceLocationFactory.createProjectSourceLocation( project ) );
|
||||||
addReferencedSourceLocations( list, project );
|
addReferencedSourceLocations( list, project );
|
||||||
}
|
}
|
||||||
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
||||||
|
@ -217,7 +222,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
{
|
{
|
||||||
if ( projects[i].exists() && !containsProject( list, projects[i] ) )
|
if ( projects[i].exists() && !containsProject( list, projects[i] ) )
|
||||||
{
|
{
|
||||||
list.add( new CProjectSourceLocation( projects[i] ) );
|
list.add( SourceLocationFactory.createProjectSourceLocation( projects[i] ) );
|
||||||
addReferencedSourceLocations( list, projects[i] );
|
addReferencedSourceLocations( list, projects[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,17 +298,13 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
public String getMemento() throws CoreException
|
public String getMemento() throws CoreException
|
||||||
{
|
{
|
||||||
Document doc = new DocumentImpl();
|
Document doc = new DocumentImpl();
|
||||||
Element node = doc.createElement( ELEMENT_NAME );
|
Element node = doc.createElement( SOURCE_LOCATOR_NAME );
|
||||||
doc.appendChild( node );
|
doc.appendChild( node );
|
||||||
|
|
||||||
ICSourceLocation[] locations = getSourceLocations();
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
for ( int i = 0; i < locations.length; i++ )
|
saveDisabledGenericSourceLocations( locations, doc, node );
|
||||||
{
|
saveAdditionalSourceLocations( locations, doc, node );
|
||||||
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
|
try
|
||||||
{
|
{
|
||||||
return CDebugUtils.serializeDocument( doc, " " );
|
return CDebugUtils.serializeDocument( doc, " " );
|
||||||
|
@ -321,15 +322,7 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
*/
|
*/
|
||||||
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
|
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException
|
||||||
{
|
{
|
||||||
IProject project = getProject( configuration );
|
setSourceLocations( getDefaultSourceLocations() );
|
||||||
if ( project != null )
|
|
||||||
{
|
|
||||||
setSourceLocations( getDefaultSourceLocations( project ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setSourceLocations( new ICSourceLocation[0] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -346,63 +339,22 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
InputSource source = new InputSource( reader );
|
InputSource source = new InputSource( reader );
|
||||||
root = parser.parse( source ).getDocumentElement();
|
root = parser.parse( source ).getDocumentElement();
|
||||||
|
|
||||||
if ( !root.getNodeName().equalsIgnoreCase( ELEMENT_NAME ) )
|
if ( !root.getNodeName().equalsIgnoreCase( SOURCE_LOCATOR_NAME ) )
|
||||||
{
|
{
|
||||||
abort( "Unable to restore C/C++ source locator - invalid format.", null );
|
abort( "Unable to restore C/C++ source locator - invalid format.", null );
|
||||||
}
|
}
|
||||||
|
|
||||||
List sourceLocations = new ArrayList();
|
List sourceLocations = new ArrayList();
|
||||||
ClassLoader classLoader = CDebugCorePlugin.getDefault() .getDescriptor().getPluginClassLoader();
|
|
||||||
|
|
||||||
NodeList list = root.getChildNodes();
|
// Add locations based on referenced projects
|
||||||
int length = list.getLength();
|
IProject project = getProject();
|
||||||
for ( int i = 0; i < length; ++i )
|
if ( project != null && project.exists() && project.isOpen() )
|
||||||
{
|
sourceLocations.addAll( Arrays.asList( getDefaultSourceLocations() ) );
|
||||||
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 = entry.getAttribute( 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;
|
removeDisabledLocations( root, sourceLocations );
|
||||||
try
|
addAdditionalLocations( root, sourceLocations );
|
||||||
{
|
// To support old launch configuration
|
||||||
location = (ICSourceLocation)clazz.newInstance();
|
addOldLocations( root, sourceLocations );
|
||||||
}
|
|
||||||
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()] ) );
|
setSourceLocations( (ICSourceLocation[])sourceLocations.toArray( new ICSourceLocation[sourceLocations.size()] ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -421,6 +373,154 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
abort( "Exception occurred initializing source locator.", ex );
|
abort( "Exception occurred initializing source locator.", ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeDisabledLocations( Element root, List sourceLocations ) throws CoreException
|
||||||
|
{
|
||||||
|
NodeList list = root.getChildNodes();
|
||||||
|
int length = list.getLength();
|
||||||
|
HashSet disabledProjects = new HashSet( length );
|
||||||
|
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( DISABLED_GENERIC_PROJECT_NAME ) )
|
||||||
|
{
|
||||||
|
String projectName = entry.getAttribute( ATTR_PROJECT_NAME );
|
||||||
|
if ( isEmpty( projectName ) )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
|
||||||
|
}
|
||||||
|
disabledProjects.add( projectName.trim() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Iterator it = sourceLocations.iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
ICSourceLocation location = (ICSourceLocation)it.next();
|
||||||
|
if ( location instanceof IProjectSourceLocation &&
|
||||||
|
disabledProjects.contains( ((IProjectSourceLocation)location).getProject().getName() ) )
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAdditionalLocations( Element root, List sourceLocations ) throws CoreException
|
||||||
|
{
|
||||||
|
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( ADDITIONAL_SOURCE_LOCATION_NAME ) )
|
||||||
|
{
|
||||||
|
String className = entry.getAttribute( ATTR_CLASS );
|
||||||
|
String data = entry.getAttribute( ATTR_MEMENTO );
|
||||||
|
if ( isEmpty( className ) )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Class clazz = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clazz = classLoader.loadClass( className );
|
||||||
|
}
|
||||||
|
catch( ClassNotFoundException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICSourceLocation location = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
location = (ICSourceLocation)clazz.newInstance();
|
||||||
|
}
|
||||||
|
catch( IllegalAccessException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore source location." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch( InstantiationException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore source location." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
location.initializeFrom( data );
|
||||||
|
sourceLocations.add( location );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOldLocations( Element root, List sourceLocations ) throws CoreException
|
||||||
|
{
|
||||||
|
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( SOURCE_LOCATION_NAME ) )
|
||||||
|
{
|
||||||
|
String className = entry.getAttribute( ATTR_CLASS );
|
||||||
|
String data = entry.getAttribute( ATTR_MEMENTO );
|
||||||
|
if ( isEmpty( className ) )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore C/C++ source locator - invalid format." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Class clazz = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clazz = classLoader.loadClass( className );
|
||||||
|
}
|
||||||
|
catch( ClassNotFoundException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( MessageFormat.format( "Unable to restore source location - class not found {0}", new String[] { className } ) );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICSourceLocation location = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
location = (ICSourceLocation)clazz.newInstance();
|
||||||
|
}
|
||||||
|
catch( IllegalAccessException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore source location." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch( InstantiationException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( "Unable to restore source location." );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
location.initializeFrom( data );
|
||||||
|
if ( !sourceLocations.contains( location ) )
|
||||||
|
{
|
||||||
|
if ( location instanceof CProjectSourceLocation )
|
||||||
|
((CProjectSourceLocation)location).setGenerated( isReferencedProject( ((CProjectSourceLocation)location).getProject() ) );
|
||||||
|
sourceLocations.add( location );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws an internal error exception
|
* Throws an internal error exception
|
||||||
*/
|
*/
|
||||||
|
@ -437,21 +537,209 @@ public class CSourceLocator implements ICSourceLocator, IPersistableSourceLocato
|
||||||
|
|
||||||
private boolean isEmpty( String string )
|
private boolean isEmpty( String string )
|
||||||
{
|
{
|
||||||
return string == null || string.length() == 0;
|
return string == null || string.trim().length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IProject getProject( ILaunchConfiguration configuration )
|
public void resourceChanged( IResourceChangeEvent event )
|
||||||
{
|
{
|
||||||
IProject project = null;
|
if ( event.getSource() instanceof IWorkspace && event.getDelta() != null )
|
||||||
try
|
|
||||||
{
|
{
|
||||||
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" );
|
IResourceDelta[] deltas = event.getDelta().getAffectedChildren();
|
||||||
if ( !isEmpty( projectName ) )
|
if ( deltas != null )
|
||||||
project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
|
{
|
||||||
|
ArrayList list = new ArrayList( deltas.length );
|
||||||
|
for ( int i = 0; i < deltas.length; ++i )
|
||||||
|
if ( deltas[i].getResource() instanceof IProject )
|
||||||
|
list.add( deltas[i].getResource() );
|
||||||
|
resetSourceLocations( list );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( CoreException e )
|
}
|
||||||
|
|
||||||
|
private void saveDisabledGenericSourceLocations( ICSourceLocation[] locations, Document doc, Element node )
|
||||||
|
{
|
||||||
|
IProject project = getProject();
|
||||||
|
if ( project != null && project.exists() && project.isOpen() )
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IProject[] refs = project.getReferencedProjects();
|
||||||
|
HashSet names = new HashSet( refs.length + 1 );
|
||||||
|
names.add( project.getName() );
|
||||||
|
for ( int i = 0; i < refs.length; ++i )
|
||||||
|
{
|
||||||
|
names.add( refs[i].getName() );
|
||||||
|
}
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
if ( locations[i] instanceof IProjectSourceLocation &&
|
||||||
|
((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
names.remove( ((IProjectSourceLocation)locations[i]).getProject().getName() );
|
||||||
|
|
||||||
|
Iterator it = names.iterator();
|
||||||
|
while ( it.hasNext() )
|
||||||
|
{
|
||||||
|
Element child = doc.createElement( DISABLED_GENERIC_PROJECT_NAME );
|
||||||
|
child.setAttribute( ATTR_PROJECT_NAME, (String)it.next() );
|
||||||
|
node.appendChild( child );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return project;
|
}
|
||||||
|
|
||||||
|
private void saveAdditionalSourceLocations( ICSourceLocation[] locations, Document doc, Element node )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < locations.length; i++ )
|
||||||
|
{
|
||||||
|
if ( locations[i] instanceof IProjectSourceLocation &&
|
||||||
|
((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
continue;
|
||||||
|
Element child = doc.createElement( SOURCE_LOCATION_NAME );
|
||||||
|
child.setAttribute( ATTR_CLASS, locations[i].getClass().getName() );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
child.setAttribute( ATTR_MEMENTO, locations[i].getMemento() );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( e );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
node.appendChild( child );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject()
|
||||||
|
*/
|
||||||
|
public IProject getProject()
|
||||||
|
{
|
||||||
|
return fProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setProject( IProject project )
|
||||||
|
{
|
||||||
|
fProject = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isReferencedProject( IProject ref )
|
||||||
|
{
|
||||||
|
if ( getProject() != null )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Arrays.asList( getProject().getReferencedProjects() ).contains( ref );
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
CDebugCorePlugin.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setReferencedProjects()
|
||||||
|
{
|
||||||
|
fReferencedProjects.clear();
|
||||||
|
fReferencedProjects = getReferencedProjects( getProject() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private List getReferencedProjects( IProject project )
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList( 10 );
|
||||||
|
if ( project != null && project.exists() && project.isOpen() )
|
||||||
|
{
|
||||||
|
IProject[] refs = new IProject[0];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
refs = project.getReferencedProjects();
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
list.addAll( Arrays.asList( refs ) );
|
||||||
|
for ( int i = 0; i < refs.length; ++i )
|
||||||
|
list.addAll( getReferencedProjects( refs[i] ) );
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ICSourceLocation[] getDefaultSourceLocations()
|
||||||
|
{
|
||||||
|
Iterator it = fReferencedProjects.iterator();
|
||||||
|
ArrayList list = new ArrayList( fReferencedProjects.size() );
|
||||||
|
if ( getProject() != null && getProject().exists() && getProject().isOpen() )
|
||||||
|
list.add( SourceLocationFactory.createProjectSourceLocation( getProject() ) );
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
IProject project = (IProject)it.next();
|
||||||
|
if ( project != null && project.exists() && project.isOpen() )
|
||||||
|
list.add( SourceLocationFactory.createProjectSourceLocation( project ) );
|
||||||
|
}
|
||||||
|
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetSourceLocations( List affectedProjects )
|
||||||
|
{
|
||||||
|
if ( affectedProjects.size() != 0 && getProject() != null )
|
||||||
|
{
|
||||||
|
if ( !getProject().exists() || !getProject().isOpen() )
|
||||||
|
{
|
||||||
|
removeGenericSourceLocations();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateGenericSourceLocations( affectedProjects );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeGenericSourceLocations()
|
||||||
|
{
|
||||||
|
fReferencedProjects.clear();
|
||||||
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
|
ArrayList newLocations = new ArrayList( locations.length );
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
newLocations.add( locations[i] );
|
||||||
|
setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGenericSourceLocations( List affectedProjects )
|
||||||
|
{
|
||||||
|
List newRefs = getReferencedProjects( getProject() );
|
||||||
|
ICSourceLocation[] locations = getSourceLocations();
|
||||||
|
ArrayList newLocations = new ArrayList( locations.length );
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
{
|
||||||
|
if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
{
|
||||||
|
newLocations.add( locations[i] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IProject project = ((IProjectSourceLocation)locations[i]).getProject();
|
||||||
|
if ( project.exists() && project.isOpen() )
|
||||||
|
{
|
||||||
|
if ( newRefs.contains( project ) || project.equals( getProject() ) )
|
||||||
|
{
|
||||||
|
newLocations.add( locations[i] );
|
||||||
|
newRefs.remove( project );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Iterator it = newRefs.iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
IProject project = (IProject)it.next();
|
||||||
|
if ( !fReferencedProjects.contains( project ) )
|
||||||
|
newLocations.add( SourceLocationFactory.createProjectSourceLocation( project ) );
|
||||||
|
}
|
||||||
|
fReferencedProjects = newRefs;
|
||||||
|
setSourceLocations( (ICSourceLocation[])newLocations.toArray( new ICSourceLocation[newLocations.size()] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,9 @@ import org.eclipse.cdt.debug.core.model.IStackFrameInfo;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
import org.eclipse.cdt.debug.core.sourcelookup.ISourceMode;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.debug.core.ILaunch;
|
import org.eclipse.debug.core.ILaunch;
|
||||||
|
@ -130,6 +132,9 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
*/
|
*/
|
||||||
public Object getAdapter( Class adapter )
|
public Object getAdapter( Class adapter )
|
||||||
{
|
{
|
||||||
|
if ( adapter.equals( IResourceChangeListener.class ) &&
|
||||||
|
fSourceLocator instanceof IResourceChangeListener )
|
||||||
|
return fSourceLocator;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,4 +248,12 @@ public class CSourceManager implements ICSourceLocator,
|
||||||
return (IPersistableSourceLocator)fSourceLocator;
|
return (IPersistableSourceLocator)fSourceLocator;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator#getProject()
|
||||||
|
*/
|
||||||
|
public IProject getProject()
|
||||||
|
{
|
||||||
|
return ( getCSourceLocator() != null ) ? getCSourceLocator().getProject() : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
2003-07-17 Mikhail Khodjaiants
|
||||||
|
Automatically update the list of source locations when the list of the referenced
|
||||||
|
projects is modified.
|
||||||
|
* CheckedListDialogField.java
|
||||||
|
* AddDirectorySourceLocationBlock.java
|
||||||
|
* AddProjectSourceLocationBlock.java
|
||||||
|
* CUISourceLocator.java
|
||||||
|
* SourceLookupBlock.java
|
||||||
|
|
||||||
2003-06-29 Mikhail Khodjaiants
|
2003-06-29 Mikhail Khodjaiants
|
||||||
Fix for PR 39101: No hilight when changing the value of register.
|
Fix for PR 39101: No hilight when changing the value of register.
|
||||||
* RegistersView.java
|
* RegistersView.java
|
||||||
|
|
|
@ -141,8 +141,15 @@ public class CheckedListDialogField extends ListDialogField {
|
||||||
* Sets the checked state of an element. no dialog changed listener informed
|
* Sets the checked state of an element. no dialog changed listener informed
|
||||||
*/
|
*/
|
||||||
public void setCheckedWithoutUpdate(Object object, boolean state) {
|
public void setCheckedWithoutUpdate(Object object, boolean state) {
|
||||||
if (!fCheckElements.contains(object)) {
|
if (state) {
|
||||||
fCheckElements.add(object);
|
if (!fCheckElements.contains(object)) {
|
||||||
|
fCheckElements.add(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (fCheckElements.contains(object)) {
|
||||||
|
fCheckElements.remove(object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (fTable != null) {
|
if (fTable != null) {
|
||||||
((CheckboxTableViewer)fTable).setChecked(object, state);
|
((CheckboxTableViewer)fTable).setChecked(object, state);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.wizards;
|
package org.eclipse.cdt.debug.internal.ui.wizards;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
|
||||||
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
||||||
import org.eclipse.cdt.debug.internal.ui.SWTUtil;
|
import org.eclipse.cdt.debug.internal.ui.SWTUtil;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -177,7 +177,7 @@ public class AddDirectorySourceLocationBlock
|
||||||
if ( isLocationPathValid() )
|
if ( isLocationPathValid() )
|
||||||
{
|
{
|
||||||
Path association = ( isAssociationPathValid() ) ? new Path( getAssociationPath() ) : null;
|
Path association = ( isAssociationPathValid() ) ? new Path( getAssociationPath() ) : null;
|
||||||
return new CDirectorySourceLocation( new Path( getLocationPath() ), association );
|
return SourceLocationFactory.createDirectorySourceLocation( new Path( getLocationPath() ), association );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.wizards;
|
package org.eclipse.cdt.debug.internal.ui.wizards;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CProjectSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
|
@ -92,7 +92,7 @@ public class AddProjectSourceLocationBlock
|
||||||
{
|
{
|
||||||
if ( !((IStructuredSelection)fViewer.getSelection()).isEmpty() )
|
if ( !((IStructuredSelection)fViewer.getSelection()).isEmpty() )
|
||||||
{
|
{
|
||||||
return new CProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement() );
|
return SourceLocationFactory.createProjectSourceLocation( (IProject)((IStructuredSelection)fViewer.getSelection()).getFirstElement(), false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.internal.ui.wizards.AddDirectorySourceLocationWizar
|
||||||
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -121,6 +122,8 @@ public class CUISourceLocator implements IAdaptable
|
||||||
{
|
{
|
||||||
if ( adapter.equals( ICSourceLocator.class ) )
|
if ( adapter.equals( ICSourceLocator.class ) )
|
||||||
return fSourceLocator;
|
return fSourceLocator;
|
||||||
|
if ( adapter.equals( IResourceChangeListener.class ) && fSourceLocator instanceof IAdaptable )
|
||||||
|
return ((IAdaptable)fSourceLocator).getAdapter( IResourceChangeListener.class );
|
||||||
if ( adapter.equals( ISourceMode.class ) )
|
if ( adapter.equals( ISourceMode.class ) )
|
||||||
return fSourceLocator;
|
return fSourceLocator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,28 +5,39 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.ui.sourcelookup;
|
package org.eclipse.cdt.debug.ui.sourcelookup;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.IDirectorySourceLocation;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.IProjectSourceLocation;
|
||||||
|
import org.eclipse.cdt.debug.core.sourcelookup.SourceLocationFactory;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
|
||||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
|
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLocator;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||||
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
import org.eclipse.cdt.debug.internal.ui.PixelConverter;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.CheckedListDialogField;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.DialogField;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.IDialogFieldListener;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.LayoutUtil;
|
||||||
import org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField;
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.ListDialogField;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.dialogfields.Separator;
|
||||||
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
import org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
|
||||||
import org.eclipse.jface.resource.JFaceResources;
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
import org.eclipse.jface.viewers.CellEditor;
|
import org.eclipse.jface.viewers.CellEditor;
|
||||||
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
import org.eclipse.jface.viewers.ICellModifier;
|
import org.eclipse.jface.viewers.ICellModifier;
|
||||||
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
@ -95,19 +106,6 @@ public class SourceLookupBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SourceLookupAdapter implements IListAdapter
|
|
||||||
{
|
|
||||||
public void customButtonPressed( DialogField field, int index )
|
|
||||||
{
|
|
||||||
doButtonPressed( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectionChanged( DialogField field )
|
|
||||||
{
|
|
||||||
doSelectionChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SourceLookupLabelProvider extends LabelProvider implements ITableLabelProvider
|
private static class SourceLookupLabelProvider extends LabelProvider implements ITableLabelProvider
|
||||||
{
|
{
|
||||||
public Image getColumnImage( Object element, int columnIndex )
|
public Image getColumnImage( Object element, int columnIndex )
|
||||||
|
@ -156,7 +154,9 @@ public class SourceLookupBlock
|
||||||
|
|
||||||
private Composite fControl = null;
|
private Composite fControl = null;
|
||||||
private Shell fShell = null;
|
private Shell fShell = null;
|
||||||
private SourceListDialogField fSourceListField;
|
private CheckedListDialogField fGeneratedSourceListField;
|
||||||
|
private SourceListDialogField fAddedSourceListField;
|
||||||
|
// private SelectionButtonDialogField fSearchForDuplicateFiles;
|
||||||
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
|
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
|
||||||
private boolean fIsDirty = false;
|
private boolean fIsDirty = false;
|
||||||
private ICSourceLocator fLocator = null;
|
private ICSourceLocator fLocator = null;
|
||||||
|
@ -167,7 +167,13 @@ public class SourceLookupBlock
|
||||||
*/
|
*/
|
||||||
public SourceLookupBlock()
|
public SourceLookupBlock()
|
||||||
{
|
{
|
||||||
String[] buttonLabels = new String[]
|
String[] generatedSourceButtonLabels = new String[]
|
||||||
|
{
|
||||||
|
/* 0 */ "Select All",
|
||||||
|
/* 1 */ "Deselect All",
|
||||||
|
};
|
||||||
|
|
||||||
|
String[] addedSourceButtonLabels = new String[]
|
||||||
{
|
{
|
||||||
/* 0 */ "Add...",
|
/* 0 */ "Add...",
|
||||||
/* 1 */ null,
|
/* 1 */ null,
|
||||||
|
@ -175,17 +181,55 @@ public class SourceLookupBlock
|
||||||
/* 3 */ "Down",
|
/* 3 */ "Down",
|
||||||
/* 4 */ null,
|
/* 4 */ null,
|
||||||
/* 5 */ "Remove",
|
/* 5 */ "Remove",
|
||||||
/* 6 */ null,
|
|
||||||
/* 7 */ "Restore Defaults",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SourceLookupAdapter adapter = new SourceLookupAdapter();
|
IListAdapter generatedSourceAdapter = new IListAdapter()
|
||||||
|
{
|
||||||
|
public void customButtonPressed( DialogField field, int index )
|
||||||
|
{
|
||||||
|
doGeneratedSourceButtonPressed( index );
|
||||||
|
}
|
||||||
|
|
||||||
fSourceListField = new SourceListDialogField( adapter, buttonLabels, new SourceLookupLabelProvider() );
|
public void selectionChanged( DialogField field )
|
||||||
fSourceListField.setLabelText( "Source Locations" );
|
{
|
||||||
fSourceListField.setUpButtonIndex( 2 );
|
doGeneratedSourceSelectionChanged();
|
||||||
fSourceListField.setDownButtonIndex( 3 );
|
}
|
||||||
fSourceListField.setRemoveButtonIndex( 5 );
|
};
|
||||||
|
|
||||||
|
fGeneratedSourceListField = new CheckedListDialogField( generatedSourceAdapter, generatedSourceButtonLabels, new SourceLookupLabelProvider() );
|
||||||
|
fGeneratedSourceListField.setLabelText( "Generic Source Locations" );
|
||||||
|
fGeneratedSourceListField.setCheckAllButtonIndex( 0 );
|
||||||
|
fGeneratedSourceListField.setUncheckAllButtonIndex( 1 );
|
||||||
|
fGeneratedSourceListField.setDialogFieldListener( new IDialogFieldListener()
|
||||||
|
{
|
||||||
|
public void dialogFieldChanged( DialogField field )
|
||||||
|
{
|
||||||
|
doCheckStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
|
IListAdapter addedSourceAdapter = new IListAdapter()
|
||||||
|
{
|
||||||
|
public void customButtonPressed( DialogField field, int index )
|
||||||
|
{
|
||||||
|
doAddedSourceButtonPressed( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged( DialogField field )
|
||||||
|
{
|
||||||
|
doAddedSourceSelectionChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fAddedSourceListField = new SourceListDialogField( addedSourceAdapter, addedSourceButtonLabels, new SourceLookupLabelProvider() );
|
||||||
|
fAddedSourceListField.setLabelText( "Additional Source Locations" );
|
||||||
|
fAddedSourceListField.setUpButtonIndex( 2 );
|
||||||
|
fAddedSourceListField.setDownButtonIndex( 3 );
|
||||||
|
fAddedSourceListField.setRemoveButtonIndex( 5 );
|
||||||
|
/*
|
||||||
|
fSearchForDuplicateFiles = new SelectionButtonDialogField( SWT.CHECK );
|
||||||
|
fSearchForDuplicateFiles.setLabelText( "Search for duplicate files" );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl( Composite parent )
|
public void createControl( Composite parent )
|
||||||
|
@ -202,17 +246,38 @@ public class SourceLookupBlock
|
||||||
|
|
||||||
PixelConverter converter = new PixelConverter( fControl );
|
PixelConverter converter = new PixelConverter( fControl );
|
||||||
|
|
||||||
fSourceListField.doFillIntoGrid( fControl, 3 );
|
fGeneratedSourceListField.doFillIntoGrid( fControl, 3 );
|
||||||
LayoutUtil.setHorizontalSpan( fSourceListField.getLabelControl( null ), 2 );
|
LayoutUtil.setHorizontalSpan( fGeneratedSourceListField.getLabelControl( null ), 2 );
|
||||||
LayoutUtil.setWidthHint( fSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
|
LayoutUtil.setWidthHint( fGeneratedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
|
||||||
LayoutUtil.setHorizontalGrabbing( fSourceListField.getListControl( null ) );
|
LayoutUtil.setHorizontalGrabbing( fGeneratedSourceListField.getListControl( null ) );
|
||||||
|
((CheckboxTableViewer)fGeneratedSourceListField.getTableViewer()).
|
||||||
|
addCheckStateListener( new ICheckStateListener()
|
||||||
|
{
|
||||||
|
public void checkStateChanged( CheckStateChangedEvent event )
|
||||||
|
{
|
||||||
|
if ( event.getElement() instanceof IProjectSourceLocation )
|
||||||
|
doCheckStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
TableViewer viewer = fSourceListField.getTableViewer();
|
} );
|
||||||
|
|
||||||
|
new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
|
||||||
|
|
||||||
|
fAddedSourceListField.doFillIntoGrid( fControl, 3 );
|
||||||
|
LayoutUtil.setHorizontalSpan( fAddedSourceListField.getLabelControl( null ), 2 );
|
||||||
|
LayoutUtil.setWidthHint( fAddedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
|
||||||
|
LayoutUtil.setHorizontalGrabbing( fAddedSourceListField.getListControl( null ) );
|
||||||
|
|
||||||
|
TableViewer viewer = fAddedSourceListField.getTableViewer();
|
||||||
Table table = viewer.getTable();
|
Table table = viewer.getTable();
|
||||||
CellEditor cellEditor = new TextCellEditor( table );
|
CellEditor cellEditor = new TextCellEditor( table );
|
||||||
viewer.setCellEditors( new CellEditor[]{ null, cellEditor } );
|
viewer.setCellEditors( new CellEditor[]{ null, cellEditor } );
|
||||||
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
|
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION } );
|
||||||
viewer.setCellModifier( createCellModifier() );
|
viewer.setCellModifier( createCellModifier() );
|
||||||
|
|
||||||
|
new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
|
||||||
|
|
||||||
|
// fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICellModifier createCellModifier()
|
private ICellModifier createCellModifier()
|
||||||
|
@ -245,7 +310,7 @@ public class SourceLookupBlock
|
||||||
if ( association.isValidPath( (String)value ) )
|
if ( association.isValidPath( (String)value ) )
|
||||||
{
|
{
|
||||||
((CDirectorySourceLocation)entry).setAssociation( association );
|
((CDirectorySourceLocation)entry).setAssociation( association );
|
||||||
getSourceListField().refresh();
|
getAddedSourceListField().refresh();
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,22 +326,61 @@ public class SourceLookupBlock
|
||||||
public void initialize( ICSourceLocator locator )
|
public void initialize( ICSourceLocator locator )
|
||||||
{
|
{
|
||||||
fLocator = locator;
|
fLocator = locator;
|
||||||
ICSourceLocation[] locations = new ICSourceLocation[0];
|
|
||||||
if ( fLocator != null )
|
if ( fLocator != null )
|
||||||
locations = fLocator.getSourceLocations();
|
|
||||||
resetLocations( locations );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetLocations( ICSourceLocation[] locations )
|
|
||||||
{
|
|
||||||
fSourceListField.removeAllElements();
|
|
||||||
for ( int i = 0; i < locations.length; ++i )
|
|
||||||
{
|
{
|
||||||
fSourceListField.addElement( locations[i] );
|
ICSourceLocation[] locations = fLocator.getSourceLocations();
|
||||||
|
initializeGeneratedLocations( fLocator.getProject(), locations );
|
||||||
|
resetAdditionalLocations( locations );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doButtonPressed( int index )
|
private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations )
|
||||||
|
{
|
||||||
|
fGeneratedSourceListField.removeAllElements();
|
||||||
|
if ( project == null && project.exists() && project.isOpen() )
|
||||||
|
return;
|
||||||
|
List list = getReferencedProjects( project );
|
||||||
|
IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] );
|
||||||
|
ICSourceLocation loc = getLocationForProject( project, locations );
|
||||||
|
boolean checked = ( loc != null );
|
||||||
|
if ( loc == null )
|
||||||
|
loc = SourceLocationFactory.createProjectSourceLocation( project, true );
|
||||||
|
fGeneratedSourceListField.addElement( loc );
|
||||||
|
fGeneratedSourceListField.setChecked( loc, checked );
|
||||||
|
|
||||||
|
for ( int i = 0; i < refs.length; ++i )
|
||||||
|
{
|
||||||
|
loc = getLocationForProject( refs[i], locations );
|
||||||
|
checked = ( loc != null );
|
||||||
|
if ( loc == null )
|
||||||
|
loc = SourceLocationFactory.createProjectSourceLocation( refs[i], true );
|
||||||
|
fGeneratedSourceListField.addElement( loc );
|
||||||
|
fGeneratedSourceListField.setChecked( loc, checked );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetGeneratedLocations( ICSourceLocation[] locations )
|
||||||
|
{
|
||||||
|
fGeneratedSourceListField.checkAll( false );
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
{
|
||||||
|
if ( locations[i] instanceof IProjectSourceLocation &&
|
||||||
|
((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
fGeneratedSourceListField.setChecked( locations[i], true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetAdditionalLocations( ICSourceLocation[] locations )
|
||||||
|
{
|
||||||
|
fAddedSourceListField.removeAllElements();
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
{
|
||||||
|
if ( !( locations[i] instanceof IProjectSourceLocation ) || !((IProjectSourceLocation)locations[i]).isGeneric() )
|
||||||
|
fAddedSourceListField.addElement( locations[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doAddedSourceButtonPressed( int index )
|
||||||
{
|
{
|
||||||
switch( index )
|
switch( index )
|
||||||
{
|
{
|
||||||
|
@ -284,11 +388,9 @@ public class SourceLookupBlock
|
||||||
if ( addSourceLocation() )
|
if ( addSourceLocation() )
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 2: // Up
|
||||||
restoreDefaults();
|
case 3: // Down
|
||||||
case 2:
|
case 5: // Remove
|
||||||
case 3:
|
|
||||||
case 5:
|
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -296,13 +398,45 @@ public class SourceLookupBlock
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSelectionChanged()
|
protected void doAddedSourceSelectionChanged()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doCheckStateChanged()
|
||||||
|
{
|
||||||
|
fIsDirty = true;
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doGeneratedSourceButtonPressed( int index )
|
||||||
|
{
|
||||||
|
switch( index )
|
||||||
|
{
|
||||||
|
case 0: // Select All
|
||||||
|
case 1: // Deselect All
|
||||||
|
fIsDirty = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( isDirty() )
|
||||||
|
updateLaunchConfigurationDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doGeneratedSourceSelectionChanged()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICSourceLocation[] getSourceLocations()
|
public ICSourceLocation[] getSourceLocations()
|
||||||
{
|
{
|
||||||
return (ICSourceLocation[])fSourceListField.getElements().toArray( new ICSourceLocation[fSourceListField.getElements().size()] );
|
ArrayList list = new ArrayList( getGeneratedSourceListField().getElements().size() + getAddedSourceListField().getElements().size() );
|
||||||
|
Iterator it = getGeneratedSourceListField().getElements().iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
IProjectSourceLocation location = (IProjectSourceLocation)it.next();
|
||||||
|
if ( getGeneratedSourceListField().isChecked( location ) )
|
||||||
|
list.add( location );
|
||||||
|
}
|
||||||
|
list.addAll( getAddedSourceListField().getElements() );
|
||||||
|
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addSourceLocation()
|
private boolean addSourceLocation()
|
||||||
|
@ -311,7 +445,7 @@ public class SourceLookupBlock
|
||||||
WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard );
|
WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard );
|
||||||
if ( dialog.open() == Window.OK )
|
if ( dialog.open() == Window.OK )
|
||||||
{
|
{
|
||||||
fSourceListField.addElement( wizard.getSourceLocation() );
|
fAddedSourceListField.addElement( wizard.getSourceLocation() );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -344,7 +478,7 @@ public class SourceLookupBlock
|
||||||
|
|
||||||
protected Object getSelection()
|
protected Object getSelection()
|
||||||
{
|
{
|
||||||
List list = fSourceListField.getSelectedElements();
|
List list = fAddedSourceListField.getSelectedElements();
|
||||||
return ( list.size() > 0 ) ? list.get( 0 ) : null;
|
return ( list.size() > 0 ) ? list.get( 0 ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +487,8 @@ public class SourceLookupBlock
|
||||||
ICSourceLocation[] locations = new ICSourceLocation[0];
|
ICSourceLocation[] locations = new ICSourceLocation[0];
|
||||||
if ( getProject() != null )
|
if ( getProject() != null )
|
||||||
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
locations = CSourceLocator.getDefaultSourceLocations( getProject() );
|
||||||
resetLocations( locations );
|
resetGeneratedLocations( locations );
|
||||||
|
resetAdditionalLocations( locations );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProject getProject()
|
public IProject getProject()
|
||||||
|
@ -366,8 +501,42 @@ public class SourceLookupBlock
|
||||||
fProject = project;
|
fProject = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceListDialogField getSourceListField()
|
public SourceListDialogField getAddedSourceListField()
|
||||||
{
|
{
|
||||||
return fSourceListField;
|
return fAddedSourceListField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CheckedListDialogField getGeneratedSourceListField()
|
||||||
|
{
|
||||||
|
return fGeneratedSourceListField;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICSourceLocation getLocationForProject( IProject project, ICSourceLocation[] locations )
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < locations.length; ++i )
|
||||||
|
if ( locations[i] instanceof IProjectSourceLocation &&
|
||||||
|
project.equals( ((IProjectSourceLocation)locations[i]).getProject() ) )
|
||||||
|
return locations[i];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List getReferencedProjects( IProject project )
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList( 10 );
|
||||||
|
if ( project != null && project.exists() && project.isOpen() )
|
||||||
|
{
|
||||||
|
IProject[] refs = new IProject[0];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
refs = project.getReferencedProjects();
|
||||||
|
}
|
||||||
|
catch( CoreException e )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
list.addAll( Arrays.asList( refs ) );
|
||||||
|
for ( int i = 0; i < refs.length; ++i )
|
||||||
|
list.addAll( getReferencedProjects( refs[i] ) );
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue