Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2003-02-18 14:35:24 -0500
committerMikhail Khodjaiants2003-02-18 14:35:24 -0500
commitacf0c44f7ace2a76f84d748cf2f1a00adb7c0b82 (patch)
treeea5401d5c6d308c3eae0e98e8bbe216e331bd000 /debug
parentfcdfb49342cc8c8ea260632fe169093de8308ee4 (diff)
downloadorg.eclipse.cdt-acf0c44f7ace2a76f84d748cf2f1a00adb7c0b82.tar.gz
org.eclipse.cdt-acf0c44f7ace2a76f84d748cf2f1a00adb7c0b82.tar.xz
org.eclipse.cdt-acf0c44f7ace2a76f84d748cf2f1a00adb7c0b82.zip
Added persistency to the source locator.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/ChangeLog1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java38
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java62
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java41
4 files changed, 131 insertions, 11 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index f7a6d20f3ab..3a2721acb09 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -1,6 +1,7 @@
2003-02-18 Mikhail Khodjaiants
Added persistency to the source locator.
* CUISourceLocator.java
+ * SourceLookupBlock.java
* SourcePropertyPage.java
2003-02-14 Mikhail Khodjaiants
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java
index b4354671fa1..a817ac209dc 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/CUISourceLocator.java
@@ -16,9 +16,15 @@ import org.eclipse.cdt.debug.internal.ui.wizards.AddDirectorySourceLocationWizar
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 @@ public class CUISourceLocator implements IAdaptable
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 @@ public class CUISourceLocator implements IAdaptable
* @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 @@ public class CUISourceLocator implements IAdaptable
SourceLookupDialog dialog = new SourceLookupDialog( CDebugUIPlugin.getActiveWorkbenchShell(), fileName );
if ( dialog.open() == SourceLookupDialog.ATTACH )
{
- attachSourceLocation( fileName );
+ attachSourceLocation( launch, fileName );
}
fAllowedToAsk = !dialog.isNotAskAgain();
}
@@ -246,7 +252,7 @@ public class CUISourceLocator implements IAdaptable
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 @@ public class CUISourceLocator implements IAdaptable
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;
}
}
@@ -281,4 +292,23 @@ public class CUISourceLocator implements IAdaptable
}
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 );
+ }
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java
index 9a467a5f3a1..e0d38150b6e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourceLookupBlock.java
@@ -15,7 +15,9 @@ 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.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 @@ import org.eclipse.swt.widgets.Shell;
*/
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 @@ public class SourceLookupBlock
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 @@ public class SourceLookupBlock
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 @@ public class SourceLookupBlock
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 @@ public class SourceLookupBlock
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 @@ public class SourceLookupBlock
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;
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java
index 0005f663a0f..f9467267cac 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/sourcelookup/SourcePropertyPage.java
@@ -8,7 +8,14 @@ package org.eclipse.cdt.debug.ui.sourcelookup;
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 class SourcePropertyPage extends PropertyPage
*/
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 @@ public class SourcePropertyPage extends PropertyPage
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 );
+ }
+ }
}

Back to the top