Index:
ChangeLog =================================================================== RCS
file: /home/tools/org.eclipse.cdt.debug.ui/ChangeLog,v retrieving revision
1.101 diff -u -r1.101 ChangeLog --- ChangeLog 14 Feb 2003 18:51:38
-0000 1.101 +++ ChangeLog 18 Feb 2003 19:26:37 -0000 @@ -1,3
+1,8 @@ +2003-02-18 Mikhail Khodjaiants + Added persistency to the
source locator. + * CUISourceLocator.java + *
SourcePropertyPage.java + 2003-02-14 Mikhail
Khodjaiants Enable the 'Resume With Signal' action only if target
is suspended. * SignalActionDelegate.java Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java,v retrieving
revision 1.5 diff -u -r1.5 CUISourceLocator.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 6 Feb 2003
21:26:20 -0000 1.5 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java 18 Feb 2003
19:26:38 -0000 @@ -16,9 +16,15 @@ import
org.eclipse.cdt.debug.internal.ui.wizards.AddSourceLocationWizard; import
org.eclipse.cdt.debug.ui.CDebugUIPlugin; import
org.eclipse.core.resources.IProject; +import
org.eclipse.core.runtime.CoreException; import
org.eclipse.core.runtime.IAdaptable; import
org.eclipse.core.runtime.IPath; +import
org.eclipse.core.runtime.IStatus; import
org.eclipse.core.runtime.Path; +import
org.eclipse.debug.core.ILaunch; +import
org.eclipse.debug.core.ILaunchConfiguration; +import
org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import
org.eclipse.debug.core.model.IPersistableSourceLocator; import
org.eclipse.debug.core.model.IStackFrame; import
org.eclipse.jface.dialogs.Dialog; import
org.eclipse.jface.window.Window; @@ -213,7 +219,7
@@ IStackFrameInfo frameInfo =
(IStackFrameInfo)stackFrame.getAdapter( IStackFrameInfo.class
); if ( frameInfo != null &&
frameInfo.getFile() != null && frameInfo.getFile().length() > 0
) { - showDebugSourcePage(
frameInfo.getFile() ); + showDebugSourcePage(
stackFrame.getLaunch(), frameInfo.getFile()
); if ( fNewLocationAttached
) { res
= fSourceLocator.getSourceElement( stackFrame ); @@ -229,7 +235,7
@@ * @param frameInfo the frame information for which
source * could not be located
*/ - private void showDebugSourcePage( final String fileName
) + private void showDebugSourcePage( final ILaunch launch, final String
fileName ) { Runnable prompter = new
Runnable() { @@
-238,7 +244,7
@@ SourceLookupDialog
dialog = new SourceLookupDialog( CDebugUIPlugin.getActiveWorkbenchShell(),
fileName
); if (
dialog.open() == SourceLookupDialog.ATTACH
) { - attachSourceLocation(
fileName
); + attachSourceLocation(
launch, fileName
); } fAllowedToAsk
=
!dialog.isNotAskAgain(); } @@
-246,7 +252,7
@@ CDebugUIPlugin.getStandardDisplay().syncExec( prompter
); } - protected void attachSourceLocation(
String fileName ) + protected void attachSourceLocation( ILaunch launch,
String fileName ) { IPath path = new Path(
fileName ); INewSourceLocationWizard wizard = null; @@
-263,6 +269,11 @@ if ( dialog.open() == Window.OK
) { fSourceLocator.addSourceLocation(
wizard.getSourceLocation() ); + if (
launch.getSourceLocator() instanceof IPersistableSourceLocator
) + { + ILaunchConfiguration
configuration =
launch.getLaunchConfiguration(); + saveChanges(
configuration, (IPersistableSourceLocator)launch.getSourceLocator()
); + } fNewLocationAttached =
true; } } @@ -280,5 +291,24
@@ return
fSourceLocator; } return
null; + } + + public IProject
getProject() + { + return
fProject; + } + + protected void saveChanges(
ILaunchConfiguration configuration, IPersistableSourceLocator locator
) + { + try + { + ILaunchConfigurationWorkingCopy
copy = configuration.copy( configuration.getName()
); + copy.setAttribute(
ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento()
); + copy.doSave(); + } + catch(
CoreException e
) + { + CDebugUIPlugin.errorDialog(
e.getMessage(), (IStatus)null
); + } } } Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java,v retrieving
revision 1.4 diff -u -r1.4 SourceLookupBlock.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 6 Feb 2003
21:26:20 -0000 1.4 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java 18 Feb
2003 19:26:37 -0000 @@ -15,7 +15,9 @@ 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.wizards.AddSourceLocationWizard; +import
org.eclipse.debug.ui.ILaunchConfigurationDialog; import
org.eclipse.jface.resource.JFaceResources; +import
org.eclipse.jface.viewers.ILabelProvider; import
org.eclipse.jface.viewers.LabelProvider; import
org.eclipse.jface.window.Window; import
org.eclipse.jface.wizard.WizardDialog; @@ -35,6 +37,20 @@
*/ public class SourceLookupBlock { + private class
SourceListDialogField extends ListDialogField + { + public
SourceListDialogField( IListAdapter adapter, String[] buttonLabels,
ILabelProvider lprovider ) + { + super(
adapter, buttonLabels, lprovider
); + } + + protected boolean
managedButtonPressed( int index
) + { + super.managedButtonPressed( index
); + return
false; + } + } + private class
SourceLookupAdapter implements
IListAdapter { public void
customButtonPressed( DialogField field, int index ) @@ -79,7 +95,9
@@ private Composite fControl =
null; private Shell fShell = null; - private
ListDialogField fSourceListField; + private SourceListDialogField
fSourceListField; + private ILaunchConfigurationDialog
fLaunchConfigurationDialog = null; + private boolean fIsDirty =
false; /** * Constructor for
SourceLookupBlock. @@ -98,7 +116,7
@@ SourceLookupAdapter adapter = new
SourceLookupAdapter(); - fSourceListField = new
ListDialogField( adapter, buttonLabels, new SourceLookupLabelProvider()
); + fSourceListField = new SourceListDialogField( adapter,
buttonLabels, new SourceLookupLabelProvider()
); fSourceListField.setLabelText( "Source Locations"
); fSourceListField.setUpButtonIndex( 2
); fSourceListField.setDownButtonIndex( 3 ); @@ -130,7
+148,7 @@ return
fControl; } - protected void initialize(
ICSourceLocation[] locations ) + public void initialize(
ICSourceLocation[] locations
) { fSourceListField.removeAllElements(); for
( int i = 0; i < locations.length; ++i ) @@ -144,9 +162,17
@@ switch( index
) { case 0: //
Add... - addSourceLocation(); + if
( addSourceLocation() ) + fIsDirty =
true; + break; + case
2: + case 3: + case
5: + fIsDirty =
true; break; } + if
( isDirty()
) + updateLaunchConfigurationDialog(); } protected
void doSelectionChanged() @@ -158,13 +184,39 @@ return
(ICSourceLocation[])fSourceListField.getElements().toArray( new
ICSourceLocation[fSourceListField.getElements().size()]
); } - private void
addSourceLocation() + private boolean
addSourceLocation() { AddSourceLocationWizard
wizard = new AddSourceLocationWizard( getSourceLocations()
); WizardDialog dialog = new WizardDialog(
fControl.getShell(), wizard ); if ( dialog.open() ==
Window.OK
) { fSourceListField.addElement(
wizard.getSourceLocation() ); + return
true; } + return
false; + } + + private void
updateLaunchConfigurationDialog() + { + if (
getLaunchConfigurationDialog() != null
) + { + getLaunchConfigurationDialog().updateMessage(); + getLaunchConfigurationDialog().updateButtons(); + } + } + + public
ILaunchConfigurationDialog
getLaunchConfigurationDialog() + { + return
fLaunchConfigurationDialog; + } + + public void
setLaunchConfigurationDialog( ILaunchConfigurationDialog
launchConfigurationDialog
) + { + fLaunchConfigurationDialog =
launchConfigurationDialog; + } + + public boolean
isDirty() + { + return
fIsDirty; } } Index:
src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java =================================================================== RCS
file:
/home/tools/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java,v retrieving
revision 1.2 diff -u -r1.2 SourcePropertyPage.java ---
src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java 20 Dec
2002 22:30:00 -0000 1.2 +++
src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java 18 Feb
2003 19:26:38 -0000 @@ -8,7 +8,14 @@ import
org.eclipse.cdt.debug.core.model.ICDebugTarget; import
org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import
org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; +import
org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import
org.eclipse.core.runtime.CoreException; import
org.eclipse.core.runtime.IAdaptable; +import
org.eclipse.core.runtime.IStatus; +import
org.eclipse.debug.core.DebugException; +import
org.eclipse.debug.core.ILaunchConfiguration; +import
org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import
org.eclipse.debug.core.model.IPersistableSourceLocator; import
org.eclipse.swt.SWT; import
org.eclipse.swt.widgets.Composite; import
org.eclipse.swt.widgets.Control; @@ -96,11 +103,22 @@
*/ public boolean
performOk() { - setSourceLocations(
fBlock.getSourceLocations() ); + if ( fBlock.isDirty()
) + { + try + { + setSourceLocations(
fBlock.getSourceLocations()
); + } + catch( DebugException e
) + { + CDebugUIPlugin.errorDialog(
e.getMessage(), (IStatus)null ); + return
false; + } + } return
true; } - private void
setSourceLocations( ICSourceLocation[] locations ) + private void
setSourceLocations( ICSourceLocation[] locations ) throws
DebugException { ICDebugTarget target =
getDebugTarget(); if ( target != null ) @@ -111,8
+129,27 @@ if ( locator != null
) { locator.setSourceLocations(
locations ); + if (
target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator
) + { + ILaunchConfiguration
configuration =
target.getLaunch().getLaunchConfiguration(); + saveChanges(
configuration, (IPersistableSourceLocator)target.getLaunch().getSourceLocator()
); + } } } + } + } + + protected
void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator
locator
) + { + try + { + ILaunchConfigurationWorkingCopy
copy = configuration.copy( configuration.getName()
); + copy.setAttribute(
ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento()
); + copy.doSave(); + } + catch(
CoreException e
) + { + CDebugUIPlugin.errorDialog(
e.getMessage(), (IStatus)null
); } } }
|