1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 03:15:33 +02:00

String externalization.

This commit is contained in:
Mikhail Khodjaiants 2004-06-21 20:24:56 +00:00
parent 58d2390a65
commit b776463efa
30 changed files with 1605 additions and 1746 deletions

View file

@ -1,3 +1,6 @@
2004-06-21 Mikhail Khodjaiants
String externalization.
2004-06-16 Mikhail Khodjaiants 2004-06-16 Mikhail Khodjaiants
Deleted the "C/C++ Debugger Appearance" theme. Deleted the "C/C++ Debugger Appearance" theme.
Moved the diassembly color preferences to the "C/C++ Debug" preference page. Moved the diassembly color preferences to the "C/C++ Debug" preference page.

View file

@ -1,13 +1,17 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert; import org.eclipse.jface.util.Assert;
@ -15,33 +19,28 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
/** /**
*
* A registry that maps <code>ImageDescriptors</code> to <code>Image</code>. * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>.
*
* @since Aug 30, 2002
*/ */
public class CDebugImageDescriptorRegistry public class CDebugImageDescriptorRegistry {
{
private HashMap fRegistry = new HashMap(10); private HashMap fRegistry = new HashMap( 10 );
private Display fDisplay; private Display fDisplay;
/** /**
* Creates a new image descriptor registry for the current or default display, * Creates a new image descriptor registry for the current or default display, respectively.
* respectively.
*/ */
public CDebugImageDescriptorRegistry() public CDebugImageDescriptorRegistry() {
{
this( CDebugUIPlugin.getStandardDisplay() ); this( CDebugUIPlugin.getStandardDisplay() );
} }
/** /**
* Creates a new image descriptor registry for the given display. All images * Creates a new image descriptor registry for the given display. All images managed by this registry will be disposed when the display gets disposed.
* managed by this registry will be disposed when the display gets disposed.
* *
* @param diaplay the display the images managed by this registry are allocated for * @param diaplay
* the display the images managed by this registry are allocated for
*/ */
public CDebugImageDescriptorRegistry( Display display ) public CDebugImageDescriptorRegistry( Display display ) {
{
fDisplay = display; fDisplay = display;
Assert.isNotNull( fDisplay ); Assert.isNotNull( fDisplay );
hookDisplay(); hookDisplay();
@ -50,20 +49,17 @@ public class CDebugImageDescriptorRegistry
/** /**
* Returns the image associated with the given image descriptor. * Returns the image associated with the given image descriptor.
* *
* @param descriptor the image descriptor for which the registry manages an image * @param descriptor
* @return the image associated with the image descriptor or <code>null</code> * the image descriptor for which the registry manages an image
* if the image descriptor can't create the requested image. * @return the image associated with the image descriptor or <code>null</code> if the image descriptor can't create the requested image.
*/ */
public Image get( ImageDescriptor descriptor ) public Image get( ImageDescriptor descriptor ) {
{
if ( descriptor == null ) if ( descriptor == null )
descriptor = ImageDescriptor.getMissingImageDescriptor(); descriptor = ImageDescriptor.getMissingImageDescriptor();
Image result = (Image)fRegistry.get( descriptor ); Image result = (Image)fRegistry.get( descriptor );
if ( result != null ) if ( result != null )
return result; return result;
Assert.isTrue( fDisplay == CDebugUIPlugin.getStandardDisplay(), CDebugUIMessages.getString( "CDebugImageDescriptorRegistry.0" ) ); //$NON-NLS-1$
Assert.isTrue( fDisplay == CDebugUIPlugin.getStandardDisplay(), CDebugUIPlugin.getResourceString("internal.ui.CDebugImageDescriptorRegistry.Allocating_image_for_wrong_display") ); //$NON-NLS-1$
result = descriptor.createImage(); result = descriptor.createImage();
if ( result != null ) if ( result != null )
fRegistry.put( descriptor, result ); fRegistry.put( descriptor, result );
@ -73,22 +69,21 @@ public class CDebugImageDescriptorRegistry
/** /**
* Disposes all images managed by this registry. * Disposes all images managed by this registry.
*/ */
public void dispose() public void dispose() {
{ for( Iterator iter = fRegistry.values().iterator(); iter.hasNext(); ) {
for ( Iterator iter = fRegistry.values().iterator(); iter.hasNext(); )
{
Image image = (Image)iter.next(); Image image = (Image)iter.next();
image.dispose(); image.dispose();
} }
fRegistry.clear(); fRegistry.clear();
} }
private void hookDisplay() private void hookDisplay() {
{ fDisplay.asyncExec( new Runnable() {
fDisplay.asyncExec(new Runnable() {
public void run() { public void run() {
getDisplay().disposeExec( new Runnable() { getDisplay().disposeExec( new Runnable() {
public void run() {
public void run() {
dispose(); dispose();
} }
} ); } );
@ -99,4 +94,4 @@ public class CDebugImageDescriptorRegistry
protected Display getDisplay() { protected Display getDisplay() {
return fDisplay; return fDisplay;
} }
} }

View file

@ -11,20 +11,22 @@
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class CDebugUIMessages { public class CDebugUIMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.CDebugUIMessages"; //$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.CDebugUIMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private CDebugUIMessages() { private CDebugUIMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -1,3 +1,33 @@
CDebugUIPlugin.Error_1=Error
CDebugModelPresentation.unknown_1=unknown CDebugModelPresentation.unknown_1=unknown
CDebugImageDescriptorRegistry.0=Allocating image for wrong display.
CDebugModelPresentation.not_available_1=<not available> CDebugModelPresentation.not_available_1=<not available>
CDTDebugModelPresentation.0=<terminated>
CDTDebugModelPresentation.1=<disconnected>
CDTDebugModelPresentation.2=<not_responding>
CDTDebugModelPresentation.3={0} (Exited.{1})
CDTDebugModelPresentation.5=Signal ''{0}'' received. Description: {1}.
CDTDebugModelPresentation.6=Exit code = {0}.
CDTDebugModelPresentation.7={0} (Suspended)
CDTDebugModelPresentation.8=Thread [{0}]
CDTDebugModelPresentation.9=Thread [{0}] (Terminated)
CDTDebugModelPresentation.10=Thread [{0}] (Stepping)
CDTDebugModelPresentation.11=Thread [{0}] (Running)
CDTDebugModelPresentation.13=: Signal ''{0}'' received. Description: {1}.
CDTDebugModelPresentation.14=: Watchpoint triggered. Old value: ''{0}''. New value: ''{1}''.
CDTDebugModelPresentation.15=: Watchpoint is out of scope.
CDTDebugModelPresentation.16=: Breakpoint hit.
CDTDebugModelPresentation.17=: Shared library event.
CDTDebugModelPresentation.18=Thread [{0}] (Suspended{1})
CDTDebugModelPresentation.19=Thread [{0}]
CDTDebugModelPresentation.20=at
CDTDebugModelPresentation.21=<symbol is not available>
CDTDebugModelPresentation.22=(disabled)
CDTDebugModelPresentation.23=Infinity
CDTDebugModelPresentation.24=-Infinity
CDTDebugModelPresentation.25=(disabled)
CDTDebugModelPresentation.26=[line: {0}]
CDTDebugModelPresentation.27=[address: {0}]
CDTDebugModelPresentation.28=[function: {0}]
CDTDebugModelPresentation.29=[ignore count: {0}]
CDTDebugModelPresentation.30=if
CDTDebugModelPresentation.31=at

View file

@ -1,31 +1,32 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/**
* Enter type comment.
*
* @since: Feb 23, 2004
*/
public class ActionMessages { public class ActionMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.actions.ActionMessages"; //$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.actions.ActionMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private ActionMessages() { private ActionMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -11,24 +11,22 @@
package org.eclipse.cdt.debug.internal.ui.editors; package org.eclipse.cdt.debug.internal.ui.editors;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/**
* Comment for .
*/
public class EditorMessages { public class EditorMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.editors.EditorMessages";//$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.editors.EditorMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private EditorMessages() { private EditorMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
// TODO Auto-generated method stub
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -7,21 +7,22 @@
package org.eclipse.cdt.debug.internal.ui.preferences; package org.eclipse.cdt.debug.internal.ui.preferences;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class PreferenceMessages { public class PreferenceMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.preferences.PreferenceMessages";//$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.preferences.PreferenceMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private PreferenceMessages() { private PreferenceMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
// TODO Auto-generated method stub
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -11,20 +11,22 @@
package org.eclipse.cdt.debug.internal.ui.views.disassembly; package org.eclipse.cdt.debug.internal.ui.views.disassembly;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class DisassemblyMessages { public class DisassemblyMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyMessages"; //$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private DisassemblyMessages() { private DisassemblyMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -1,9 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory; package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugModel;
@ -39,43 +43,47 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
/** /**
*
* The tab content in the memory view. * The tab content in the memory view.
*
* @since Jul 25, 2002
*/ */
public class MemoryControlArea extends Composite implements ITextOperationTarget public class MemoryControlArea extends Composite implements ITextOperationTarget {
{
private MemoryView fMemoryView; private MemoryView fMemoryView;
private MemoryPresentation fPresentation; private MemoryPresentation fPresentation;
private int fIndex = 0; private int fIndex = 0;
private ICMemoryManager fMemoryManager = null; private ICMemoryManager fMemoryManager = null;
private Text fAddressText; private Text fAddressText;
private Button fEvaluateButton; private Button fEvaluateButton;
private MemoryText fMemoryText; private MemoryText fMemoryText;
private int fFormat = ICMemoryManager.MEMORY_FORMAT_HEX; private int fFormat = ICMemoryManager.MEMORY_FORMAT_HEX;
private int fWordSize = ICMemoryManager.MEMORY_SIZE_BYTE; private int fWordSize = ICMemoryManager.MEMORY_SIZE_BYTE;
private int fNumberOfRows = 40; private int fNumberOfRows = 40;
private int fNumberOfColumns = 16; private int fNumberOfColumns = 16;
private char fPaddingChar = '.'; private char fPaddingChar = '.';
/** /**
* Constructor for MemoryControlArea. * Constructor for MemoryControlArea.
*
* @param parent * @param parent
* @param style * @param style
*/ */
public MemoryControlArea( Composite parent, int style, int index, MemoryView view ) public MemoryControlArea( Composite parent, int style, int index, MemoryView view ) {
{
super( parent, style ); super( parent, style );
fMemoryView = view; fMemoryView = view;
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.marginHeight = 0; layout.marginHeight = 0;
layout.marginWidth = 0; layout.marginWidth = 0;
GridData gridData = new GridData( GridData.FILL_BOTH | GridData gridData = new GridData( GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL );
GridData.GRAB_HORIZONTAL |
GridData.GRAB_VERTICAL );
setLayout( layout ); setLayout( layout );
setLayoutData( gridData ); setLayoutData( gridData );
setIndex( index ); setIndex( index );
@ -86,236 +94,185 @@ public class MemoryControlArea extends Composite implements ITextOperationTarget
updateToolTipText(); updateToolTipText();
} }
private void setDefaultPreferences() private void setDefaultPreferences() {
{
char[] paddingCharStr = CDebugUIPlugin.getDefault().getPreferenceStore().getString( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ).toCharArray(); char[] paddingCharStr = CDebugUIPlugin.getDefault().getPreferenceStore().getString( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ).toCharArray();
setPaddingChar( ( paddingCharStr.length > 0 ) ? paddingCharStr[0] : '.' ); setPaddingChar( (paddingCharStr.length > 0) ? paddingCharStr[0] : '.' );
fPresentation.setDisplayAscii( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) ); fPresentation.setDisplayAscii( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) );
} }
private MemoryPresentation createPresentation() private MemoryPresentation createPresentation() {
{
return new MemoryPresentation(); return new MemoryPresentation();
} }
public MemoryPresentation getPresentation() public MemoryPresentation getPresentation() {
{
return fPresentation; return fPresentation;
} }
private Text createAddressText( Composite parent ) private Text createAddressText( Composite parent ) {
{
Composite composite = new Composite( parent, SWT.NONE ); Composite composite = new Composite( parent, SWT.NONE );
composite.setLayout( new GridLayout( 3, false ) ); composite.setLayout( new GridLayout( 3, false ) );
composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); composite.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
// create label // create label
Label label = new Label( composite, SWT.RIGHT ); Label label = new Label( composite, SWT.RIGHT );
label.setText( CDebugUIPlugin.getResourceString("MemoryControlArea.Address") ); //$NON-NLS-1$ label.setText( MemoryViewMessages.getString( "MemoryControlArea.0" ) ); //$NON-NLS-1$
label.pack(); label.pack();
// create address text // create address text
Text text = new Text( composite, SWT.BORDER ); Text text = new Text( composite, SWT.BORDER );
text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); text.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
text.addTraverseListener( new TraverseListener() text.addTraverseListener( new TraverseListener() {
{
public void keyTraversed( TraverseEvent e )
{
if ( e.detail == SWT.TRAVERSE_RETURN && e.stateMask == 0 )
{
e.doit = false;
handleAddressEnter();
}
}
} );
text.addFocusListener( new FocusListener()
{
public void focusGained( FocusEvent e )
{
getMemoryView().updateObjects();
}
public void focusLost( FocusEvent e ) public void keyTraversed( TraverseEvent e ) {
{ if ( e.detail == SWT.TRAVERSE_RETURN && e.stateMask == 0 ) {
getMemoryView().updateObjects(); e.doit = false;
} handleAddressEnter();
} ); }
text.addModifyListener( new ModifyListener() }
{ } );
public void modifyText( ModifyEvent e ) text.addFocusListener( new FocusListener() {
{
handleAddressModification();
}
} );
text.addKeyListener( new KeyListener()
{
public void keyPressed( KeyEvent e )
{
getMemoryView().updateObjects();
}
public void keyReleased( KeyEvent e ) public void focusGained( FocusEvent e ) {
{ getMemoryView().updateObjects();
getMemoryView().updateObjects(); }
}
} );
text.addMouseListener( new MouseListener()
{
public void mouseDoubleClick( MouseEvent e )
{
getMemoryView().updateObjects();
}
public void mouseDown( MouseEvent e ) public void focusLost( FocusEvent e ) {
{ getMemoryView().updateObjects();
getMemoryView().updateObjects(); }
} } );
text.addModifyListener( new ModifyListener() {
public void mouseUp( MouseEvent e ) public void modifyText( ModifyEvent e ) {
{ handleAddressModification();
getMemoryView().updateObjects(); }
} } );
} ); text.addKeyListener( new KeyListener() {
public void keyPressed( KeyEvent e ) {
getMemoryView().updateObjects();
}
public void keyReleased( KeyEvent e ) {
getMemoryView().updateObjects();
}
} );
text.addMouseListener( new MouseListener() {
public void mouseDoubleClick( MouseEvent e ) {
getMemoryView().updateObjects();
}
public void mouseDown( MouseEvent e ) {
getMemoryView().updateObjects();
}
public void mouseUp( MouseEvent e ) {
getMemoryView().updateObjects();
}
} );
fEvaluateButton = new Button( composite, SWT.PUSH ); fEvaluateButton = new Button( composite, SWT.PUSH );
fEvaluateButton.setText( CDebugUIPlugin.getResourceString("MemoryControlArea.Evaluate") ); //$NON-NLS-1$ fEvaluateButton.setText( MemoryViewMessages.getString( "MemoryControlArea.1" ) ); //$NON-NLS-1$
fEvaluateButton.setToolTipText( CDebugUIPlugin.getResourceString("MemoryControlArea.Evaluate_Expression") ); //$NON-NLS-1$ fEvaluateButton.setToolTipText( MemoryViewMessages.getString( "MemoryControlArea.2" ) ); //$NON-NLS-1$
fEvaluateButton.addSelectionListener( new SelectionAdapter() fEvaluateButton.addSelectionListener( new SelectionAdapter() {
{
public void widgetSelected( SelectionEvent e ) public void widgetSelected( SelectionEvent e ) {
{ evaluateAddressExpression();
evaluateAddressExpression(); }
} } );
} );
return text; return text;
} }
private MemoryText createMemoryText( Composite parent, private MemoryText createMemoryText( Composite parent, int styles, MemoryPresentation presentation ) {
int styles,
MemoryPresentation presentation )
{
return new MemoryText( parent, SWT.BORDER | SWT.HIDE_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL, presentation ); return new MemoryText( parent, SWT.BORDER | SWT.HIDE_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL, presentation );
} }
protected void handleAddressEnter() protected void handleAddressEnter() {
{ if ( getMemoryManager() != null ) {
if ( getMemoryManager() != null )
{
String address = fAddressText.getText().trim(); String address = fAddressText.getText().trim();
try try {
{
removeBlock(); removeBlock();
if ( address.length() > 0 ) if ( address.length() > 0 ) {
{
createBlock( address ); createBlock( address );
} }
} }
catch( DebugException e ) catch( DebugException e ) {
{ CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.3" ), e.getStatus() ); //$NON-NLS-1$
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("MemoryControlArea.Error_memoryBlock"), e.getStatus() ); //$NON-NLS-1$
} }
refresh(); refresh();
getMemoryView().updateObjects(); getMemoryView().updateObjects();
} }
} }
public void propertyChange( PropertyChangeEvent event ) public void propertyChange( PropertyChangeEvent event ) {
{ if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB ) ) {
if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_BACKGROUND_RGB ) )
{
fMemoryText.setBackgroundColor(); fMemoryText.setBackgroundColor();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FOREGROUND_RGB ) ) {
{
fMemoryText.setForegroundColor(); fMemoryText.setForegroundColor();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FONT ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_FONT ) ) {
{
fMemoryText.changeFont(); fMemoryText.changeFont();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_ADDRESS_RGB ) ) {
{
fMemoryText.setAddressColor(); fMemoryText.setAddressColor();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_CHANGED_RGB ) ) {
{
fMemoryText.setChangedColor(); fMemoryText.setChangedColor();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_DIRTY_RGB ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.MEMORY_DIRTY_RGB ) ) {
{
fMemoryText.setDirtyColor(); fMemoryText.setDirtyColor();
} }
else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ) ) else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_MEMORY_PADDING_CHAR ) ) {
{
String paddingCharString = (String)event.getNewValue(); String paddingCharString = (String)event.getNewValue();
setPaddingChar( ( paddingCharString.length() > 0 ) ? paddingCharString.charAt( 0 ) : '.' ); setPaddingChar( (paddingCharString.length() > 0) ? paddingCharString.charAt( 0 ) : '.' );
refresh(); refresh();
} }
} }
public void setInput( Object input ) public void setInput( Object input ) {
{ setMemoryManager( (input instanceof ICMemoryManager) ? (ICMemoryManager)input : null );
setMemoryManager( ( input instanceof ICMemoryManager ) ? (ICMemoryManager)input : null );
getPresentation().setMemoryBlock( getMemoryBlock() ); getPresentation().setMemoryBlock( getMemoryBlock() );
setState(); setState();
refresh(); refresh();
} }
protected void refresh() protected void refresh() {
{ fAddressText.setText( (getPresentation() != null) ? getPresentation().getAddressExpression() : "" ); //$NON-NLS-1$
fAddressText.setText( ( getPresentation() != null ) ? getPresentation().getAddressExpression() : "" ); //$NON-NLS-1$
fMemoryText.refresh(); fMemoryText.refresh();
getMemoryView().updateObjects(); getMemoryView().updateObjects();
updateToolTipText(); updateToolTipText();
} }
protected void setMemoryManager( ICMemoryManager mm ) protected void setMemoryManager( ICMemoryManager mm ) {
{
fMemoryManager = mm; fMemoryManager = mm;
} }
protected ICMemoryManager getMemoryManager() protected ICMemoryManager getMemoryManager() {
{
return fMemoryManager; return fMemoryManager;
} }
protected IFormattedMemoryBlock getMemoryBlock() protected IFormattedMemoryBlock getMemoryBlock() {
{ return (getMemoryManager() != null) ? getMemoryManager().getBlock( getIndex() ) : null;
return ( getMemoryManager() != null ) ? getMemoryManager().getBlock( getIndex() ) : null;
} }
protected int getIndex() protected int getIndex() {
{
return fIndex; return fIndex;
} }
protected void setIndex( int index ) protected void setIndex( int index ) {
{
fIndex = index; fIndex = index;
} }
private void createBlock( String address ) throws DebugException private void createBlock( String address ) throws DebugException {
{ if ( getMemoryManager() != null ) {
if ( getMemoryManager() != null ) getMemoryManager().setBlockAt( getIndex(), CDebugModel.createFormattedMemoryBlock( (IDebugTarget)getMemoryManager().getAdapter( IDebugTarget.class ), address, getFormat(), getWordSize(), getNumberOfRows(), getNumberOfColumns(), getPaddingChar() ) );
{ getMemoryBlock().setFrozen( !CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) );
getMemoryManager().setBlockAt( getIndex(),
CDebugModel.createFormattedMemoryBlock( (IDebugTarget)getMemoryManager().getAdapter( IDebugTarget.class ),
address,
getFormat(),
getWordSize(),
getNumberOfRows(),
getNumberOfColumns(),
getPaddingChar() ) );
getMemoryBlock().setFrozen( !CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) );
getPresentation().setMemoryBlock( getMemoryBlock() ); getPresentation().setMemoryBlock( getMemoryBlock() );
} }
setMemoryTextState(); setMemoryTextState();
updateToolTipText(); updateToolTipText();
} }
private void removeBlock() throws DebugException private void removeBlock() throws DebugException {
{ if ( getMemoryManager() != null ) {
if ( getMemoryManager() != null )
{
getMemoryManager().removeBlock( getIndex() ); getMemoryManager().removeBlock( getIndex() );
getPresentation().setMemoryBlock( null ); getPresentation().setMemoryBlock( null );
} }
@ -323,94 +280,72 @@ public class MemoryControlArea extends Composite implements ITextOperationTarget
updateToolTipText(); updateToolTipText();
} }
public int getFormat() public int getFormat() {
{
return fFormat; return fFormat;
} }
public int getNumberOfColumns() public int getNumberOfColumns() {
{
return fNumberOfColumns; return fNumberOfColumns;
} }
public int getNumberOfRows() public int getNumberOfRows() {
{
return fNumberOfRows; return fNumberOfRows;
} }
public char getPaddingChar() public char getPaddingChar() {
{
return fPaddingChar; return fPaddingChar;
} }
public int getWordSize() public int getWordSize() {
{
return fWordSize; return fWordSize;
} }
public void setFormat(int format) public void setFormat( int format ) {
{
fFormat = format; fFormat = format;
} }
public void setNumberOfColumns( int numberOfColumns ) public void setNumberOfColumns( int numberOfColumns ) {
{
fNumberOfColumns = numberOfColumns; fNumberOfColumns = numberOfColumns;
} }
public void setNumberOfRows( int numberOfRows ) public void setNumberOfRows( int numberOfRows ) {
{
fNumberOfRows = numberOfRows; fNumberOfRows = numberOfRows;
} }
public void setPaddingChar( char paddingChar ) public void setPaddingChar( char paddingChar ) {
{
fPaddingChar = paddingChar; fPaddingChar = paddingChar;
if ( getMemoryBlock() != null ) if ( getMemoryBlock() != null ) {
{ try {
try getMemoryBlock().reformat( getMemoryBlock().getFormat(), getMemoryBlock().getWordSize(), getMemoryBlock().getNumberOfRows(), getMemoryBlock().getNumberOfColumns(), fPaddingChar );
{
getMemoryBlock().reformat( getMemoryBlock().getFormat(),
getMemoryBlock().getWordSize(),
getMemoryBlock().getNumberOfRows(),
getMemoryBlock().getNumberOfColumns(),
fPaddingChar );
} }
catch( DebugException e ) catch( DebugException e ) {
{
// ignore // ignore
} }
} }
} }
public void setWordSize( int wordSize ) public void setWordSize( int wordSize ) {
{
fWordSize = wordSize; fWordSize = wordSize;
} }
private void enableAddressText( boolean enable ) private void enableAddressText( boolean enable ) {
{
fAddressText.setEnabled( enable ); fAddressText.setEnabled( enable );
} }
protected void setState() protected void setState() {
{
enableAddressText( getMemoryManager() != null ); enableAddressText( getMemoryManager() != null );
setMemoryTextState(); setMemoryTextState();
} }
private void setMemoryTextState() private void setMemoryTextState() {
{
fMemoryText.setEditable( getMemoryManager() != null && getMemoryBlock() != null ); fMemoryText.setEditable( getMemoryManager() != null && getMemoryBlock() != null );
} }
protected MemoryText getMemoryText() protected MemoryText getMemoryText() {
{
return fMemoryText; return fMemoryText;
} }
protected void clear() protected void clear() {
{
fAddressText.setText( "" ); //$NON-NLS-1$ fAddressText.setText( "" ); //$NON-NLS-1$
handleAddressEnter(); handleAddressEnter();
updateToolTipText(); updateToolTipText();
@ -419,137 +354,112 @@ public class MemoryControlArea extends Composite implements ITextOperationTarget
/** /**
* @see org.eclipse.swt.widgets.Widget#dispose() * @see org.eclipse.swt.widgets.Widget#dispose()
*/ */
public void dispose() public void dispose() {
{ if ( getPresentation() != null ) {
if ( getPresentation() != null )
{
getPresentation().dispose(); getPresentation().dispose();
} }
super.dispose(); super.dispose();
} }
protected String getTitle() protected String getTitle() {
{ if ( getParent() instanceof CTabFolder ) {
if ( getParent() instanceof CTabFolder )
{
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems(); CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
return tabItems[fIndex].getText(); return tabItems[fIndex].getText();
} }
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
} }
protected void setTitle( String title ) protected void setTitle( String title ) {
{ if ( getParent() instanceof CTabFolder ) {
if ( getParent() instanceof CTabFolder )
{
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems(); CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
tabItems[fIndex].setText( title ); tabItems[fIndex].setText( title );
} }
} }
protected void setTabItemToolTipText( String text ) protected void setTabItemToolTipText( String text ) {
{
String newText = replaceMnemonicCharacters( text ); String newText = replaceMnemonicCharacters( text );
if ( getParent() instanceof CTabFolder ) if ( getParent() instanceof CTabFolder ) {
{
CTabItem[] tabItems = ((CTabFolder)getParent()).getItems(); CTabItem[] tabItems = ((CTabFolder)getParent()).getItems();
tabItems[fIndex].setToolTipText( CDebugUIPlugin.getResourceString("MemoryControlArea.Memory_view") + (fIndex + 1) + ( ( newText.length() > 0 ) ? ( ": " + newText ) : "" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tabItems[fIndex].setToolTipText( MemoryViewMessages.getString( "MemoryControlArea.4" ) + (fIndex + 1) + ((newText.length() > 0) ? (": " + newText) : "") ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
} }
protected void refreshMemoryBlock() protected void refreshMemoryBlock() {
{ if ( getMemoryBlock() != null ) {
if ( getMemoryBlock() != null ) try {
{
try
{
getMemoryBlock().refresh(); getMemoryBlock().refresh();
} }
catch( DebugException e ) catch( DebugException e ) {
{ CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.7" ), e.getStatus() ); //$NON-NLS-1$
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("MemoryControlArea.Error_memoryRefresh"), e.getStatus() ); //$NON-NLS-1$
} }
} }
} }
private void updateToolTipText() private void updateToolTipText() {
{
setTabItemToolTipText( fAddressText.getText().trim() ); setTabItemToolTipText( fAddressText.getText().trim() );
} }
private String replaceMnemonicCharacters( String text ) private String replaceMnemonicCharacters( String text ) {
{
StringBuffer sb = new StringBuffer( text.length() ); StringBuffer sb = new StringBuffer( text.length() );
for ( int i = 0; i < text.length(); ++i ) for( int i = 0; i < text.length(); ++i ) {
{
char ch = text.charAt( i ); char ch = text.charAt( i );
sb.append( ch ); sb.append( ch );
if ( ch == '&' ) if ( ch == '&' ) {
{
sb.append( ch ); sb.append( ch );
} }
} }
return sb.toString(); return sb.toString();
} }
protected void handleAddressModification() protected void handleAddressModification() {
{
fEvaluateButton.setEnabled( fAddressText.getText().trim().length() > 0 ); fEvaluateButton.setEnabled( fAddressText.getText().trim().length() > 0 );
} }
protected void evaluateAddressExpression() protected void evaluateAddressExpression() {
{ if ( getMemoryManager() != null ) {
if ( getMemoryManager() != null ) if ( getMemoryBlock() == null ) {
{
if ( getMemoryBlock() == null )
{
String expression = fAddressText.getText().trim(); String expression = fAddressText.getText().trim();
try try {
{
removeBlock(); removeBlock();
if ( expression.length() > 0 ) if ( expression.length() > 0 ) {
{
createBlock( expression ); createBlock( expression );
} }
} }
catch( DebugException e ) catch( DebugException e ) {
{ CDebugUIPlugin.errorDialog( MemoryViewMessages.getString( "MemoryControlArea.8" ), e.getStatus() ); //$NON-NLS-1$
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString("MemoryControlArea.Error_memoryBlock"), e.getStatus() ); //$NON-NLS-1$
} }
} }
if ( getMemoryBlock() != null ) if ( getMemoryBlock() != null ) {
{
fAddressText.setText( CDebugUIUtils.toHexAddressString( getMemoryBlock().getStartAddress() ) ); fAddressText.setText( CDebugUIUtils.toHexAddressString( getMemoryBlock().getStartAddress() ) );
handleAddressEnter(); handleAddressEnter();
} }
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.ITextOperationTarget#canDoOperation(int) * @see org.eclipse.jface.text.ITextOperationTarget#canDoOperation(int)
*/ */
public boolean canDoOperation( int operation ) public boolean canDoOperation( int operation ) {
{ switch( operation ) {
switch( operation )
{
case CUT: case CUT:
case COPY: case COPY:
return ( fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() && fAddressText.getSelectionCount() > 0 ); return (fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() && fAddressText.getSelectionCount() > 0);
case PASTE: case PASTE:
case SELECT_ALL: case SELECT_ALL:
return ( fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled() ); return (fAddressText != null && fAddressText.isFocusControl() && fAddressText.isEnabled());
} }
return false; return false;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int) * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
*/ */
public void doOperation( int operation ) public void doOperation( int operation ) {
{ switch( operation ) {
switch( operation )
{
case CUT: case CUT:
fAddressText.cut(); fAddressText.cut();
break; break;
@ -565,8 +475,7 @@ public class MemoryControlArea extends Composite implements ITextOperationTarget
} }
} }
protected MemoryView getMemoryView() protected MemoryView getMemoryView() {
{
return fMemoryView; return fMemoryView;
} }
} }

View file

@ -1,8 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory; package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.ICMemoryManager; import org.eclipse.cdt.debug.core.ICMemoryManager;
@ -48,266 +53,231 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.texteditor.IUpdate;
/** /**
* * This view shows the content of the memory blocks associated with the selected debug target.
* This view shows the content of the memory blocks associated
* with the selected debug target.
*
* @since Jul 24, 2002
*/ */
public class MemoryView extends AbstractDebugEventHandlerView public class MemoryView extends AbstractDebugEventHandlerView implements ISelectionListener, IPropertyChangeListener, IDebugExceptionHandler {
implements ISelectionListener,
IPropertyChangeListener,
IDebugExceptionHandler
{
private IDebugModelPresentation fModelPresentation = null; private IDebugModelPresentation fModelPresentation = null;
private MemoryActionSelectionGroup fMemoryFormatGroup = null; private MemoryActionSelectionGroup fMemoryFormatGroup = null;
private MemoryActionSelectionGroup fMemorySizeGroup = null; private MemoryActionSelectionGroup fMemorySizeGroup = null;
private MemoryActionSelectionGroup fMemoryNumberOfColumnsGroup = null; private MemoryActionSelectionGroup fMemoryNumberOfColumnsGroup = null;
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite) * @see org.eclipse.debug.ui.AbstractDebugView#createViewer(Composite)
*/ */
protected Viewer createViewer( Composite parent ) protected Viewer createViewer( Composite parent ) {
{
CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this ); CDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( this );
final MemoryViewer viewer = new MemoryViewer( parent, this ); final MemoryViewer viewer = new MemoryViewer( parent, this );
viewer.setContentProvider( createContentProvider() ); viewer.setContentProvider( createContentProvider() );
viewer.setLabelProvider( getModelPresentation() ); viewer.setLabelProvider( getModelPresentation() );
getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
setEventHandler( createEventHandler( viewer ) ); setEventHandler( createEventHandler( viewer ) );
return viewer; return viewer;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createActions() * @see org.eclipse.debug.ui.AbstractDebugView#createActions()
*/ */
protected void createActions() protected void createActions() {
{ IAction action = null;
IAction action = null;
action = new MemoryViewAction( this, ITextOperationTarget.CUT ); action = new MemoryViewAction( this, ITextOperationTarget.CUT );
String cutStr = CDebugUIPlugin.getResourceString("MemoryView.Cut"); //$NON-NLS-1$ String cutStr = MemoryViewMessages.getString( "MemoryView.0" ); //$NON-NLS-1$
action.setText( cutStr ); action.setText( cutStr );
action.setToolTipText( cutStr ); action.setToolTipText( cutStr );
action.setDescription( cutStr ); action.setDescription( cutStr );
setGlobalAction( ITextEditorActionConstants.CUT, (MemoryViewAction)action ); setGlobalAction( ITextEditorActionConstants.CUT, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.COPY ); action = new MemoryViewAction( this, ITextOperationTarget.COPY );
String copyStr = CDebugUIPlugin.getResourceString("MemoryView.Copy"); //$NON-NLS-1$ String copyStr = MemoryViewMessages.getString( "MemoryView.1" ); //$NON-NLS-1$
action.setText( copyStr ); action.setText( copyStr );
action.setToolTipText( copyStr ); action.setToolTipText( copyStr );
action.setDescription( copyStr ); action.setDescription( copyStr );
setGlobalAction( ITextEditorActionConstants.COPY, (MemoryViewAction)action ); setGlobalAction( ITextEditorActionConstants.COPY, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.PASTE ); action = new MemoryViewAction( this, ITextOperationTarget.PASTE );
String pasteStr = CDebugUIPlugin.getResourceString("MemoryView.Paste"); //$NON-NLS-1$ String pasteStr = MemoryViewMessages.getString( "MemoryView.2" ); //$NON-NLS-1$
action.setText( pasteStr ); action.setText( pasteStr );
action.setToolTipText( pasteStr ); action.setToolTipText( pasteStr );
action.setDescription( pasteStr ); action.setDescription( pasteStr );
setGlobalAction( ITextEditorActionConstants.PASTE, (MemoryViewAction)action ); setGlobalAction( ITextEditorActionConstants.PASTE, (MemoryViewAction)action );
action = new MemoryViewAction( this, ITextOperationTarget.SELECT_ALL ); action = new MemoryViewAction( this, ITextOperationTarget.SELECT_ALL );
String selectAllStr = CDebugUIPlugin.getResourceString("MemoryView.Select_All"); //$NON-NLS-1$ String selectAllStr = MemoryViewMessages.getString( "MemoryView.3" ); //$NON-NLS-1$
action.setText( selectAllStr ); action.setText( selectAllStr );
action.setToolTipText( selectAllStr ); action.setToolTipText( selectAllStr );
action.setDescription( selectAllStr ); action.setDescription( selectAllStr );
setGlobalAction( ITextEditorActionConstants.SELECT_ALL, (MemoryViewAction)action ); setGlobalAction( ITextEditorActionConstants.SELECT_ALL, (MemoryViewAction)action );
action = new RefreshMemoryAction( (MemoryViewer)getViewer() ); action = new RefreshMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false ); action.setEnabled( false );
setAction( "RefreshMemory", action ); //$NON-NLS-1$ setAction( "RefreshMemory", action ); //$NON-NLS-1$
add( (RefreshMemoryAction)action ); add( (RefreshMemoryAction)action );
action = new AutoRefreshMemoryAction( (MemoryViewer)getViewer() ); action = new AutoRefreshMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false ); action.setEnabled( false );
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) ); action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_AUTO_REFRESH ) );
setAction( "AutoRefreshMemory", action ); //$NON-NLS-1$ setAction( "AutoRefreshMemory", action ); //$NON-NLS-1$
add( (AutoRefreshMemoryAction)action ); add( (AutoRefreshMemoryAction)action );
action = new ClearMemoryAction( (MemoryViewer)getViewer() ); action = new ClearMemoryAction( (MemoryViewer)getViewer() );
action.setEnabled( false ); action.setEnabled( false );
setAction( "ClearMemory", action ); //$NON-NLS-1$ setAction( "ClearMemory", action ); //$NON-NLS-1$
add( (ClearMemoryAction)action ); add( (ClearMemoryAction)action );
action = new ShowAsciiAction( (MemoryViewer)getViewer() ); action = new ShowAsciiAction( (MemoryViewer)getViewer() );
action.setEnabled( false ); action.setEnabled( false );
action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) ); action.setChecked( CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_MEMORY_SHOW_ASCII ) );
setAction( "ShowAscii", action ); //$NON-NLS-1$ setAction( "ShowAscii", action ); //$NON-NLS-1$
add( (ShowAsciiAction)action ); add( (ShowAsciiAction)action );
fMemoryFormatGroup = new MemoryActionSelectionGroup(); fMemoryFormatGroup = new MemoryActionSelectionGroup();
createFormatActionGroup( fMemoryFormatGroup ); createFormatActionGroup( fMemoryFormatGroup );
fMemorySizeGroup = new MemoryActionSelectionGroup(); fMemorySizeGroup = new MemoryActionSelectionGroup();
createSizeActionGroup( fMemorySizeGroup ); createSizeActionGroup( fMemorySizeGroup );
fMemoryNumberOfColumnsGroup = new MemoryActionSelectionGroup(); fMemoryNumberOfColumnsGroup = new MemoryActionSelectionGroup();
createNumberOfColumnsActionGroup( fMemoryNumberOfColumnsGroup ); createNumberOfColumnsActionGroup( fMemoryNumberOfColumnsGroup );
// set initial content here, as viewer has to be set // set initial content here, as viewer has to be set
setInitialContent(); setInitialContent();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId() * @see org.eclipse.debug.ui.AbstractDebugView#getHelpContextId()
*/ */
protected String getHelpContextId() protected String getHelpContextId() {
{
return ICDebugHelpContextIds.MEMORY_VIEW; return ICDebugHelpContextIds.MEMORY_VIEW;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager) * @see org.eclipse.debug.ui.AbstractDebugView#fillContextMenu(IMenuManager)
*/ */
protected void fillContextMenu( IMenuManager menu ) protected void fillContextMenu( IMenuManager menu ) {
{
menu.add( new Separator( ICDebugUIConstants.EMPTY_MEMORY_GROUP ) ); menu.add( new Separator( ICDebugUIConstants.EMPTY_MEMORY_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) ); menu.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.EMPTY_FORMAT_GROUP ) ); menu.add( new Separator( ICDebugUIConstants.EMPTY_FORMAT_GROUP ) );
menu.add( new Separator( ICDebugUIConstants.FORMAT_GROUP ) ); menu.add( new Separator( ICDebugUIConstants.FORMAT_GROUP ) );
menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) ); menu.add( new Separator( IDebugUIConstants.EMPTY_RENDER_GROUP ) );
menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) ); menu.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$ menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "RefreshMemory" ) ); //$NON-NLS-1$ menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "RefreshMemory" ) ); //$NON-NLS-1$
menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "ClearMemory" ) ); //$NON-NLS-1$ menu.appendToGroup( ICDebugUIConstants.MEMORY_GROUP, getAction( "ClearMemory" ) ); //$NON-NLS-1$
MenuManager subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.4" ) ); //$NON-NLS-1$
MenuManager subMenu = new MenuManager( CDebugUIPlugin.getResourceString("MemoryView.Format") ); //$NON-NLS-1$
{ {
IAction[] actions = fMemoryFormatGroup.getActions(); IAction[] actions = fMemoryFormatGroup.getActions();
for ( int i = 0; i < actions.length; ++i ) for( int i = 0; i < actions.length; ++i ) {
{
subMenu.add( actions[i] ); subMenu.add( actions[i] );
} }
} }
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu ); menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.5" ) ); //$NON-NLS-1$
subMenu = new MenuManager( CDebugUIPlugin.getResourceString("MemoryView.Memory_Unit_Size") ); //$NON-NLS-1$
{ {
IAction[] actions = fMemorySizeGroup.getActions(); IAction[] actions = fMemorySizeGroup.getActions();
for ( int i = 0; i < actions.length; ++i ) for( int i = 0; i < actions.length; ++i ) {
{
subMenu.add( actions[i] ); subMenu.add( actions[i] );
} }
} }
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu ); menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
subMenu = new MenuManager( MemoryViewMessages.getString( "MemoryView.6" ) ); //$NON-NLS-1$
subMenu = new MenuManager( CDebugUIPlugin.getResourceString("MemoryView.Number_of_Columns") ); //$NON-NLS-1$
{ {
IAction[] actions = fMemoryNumberOfColumnsGroup.getActions(); IAction[] actions = fMemoryNumberOfColumnsGroup.getActions();
for ( int i = 0; i < actions.length; ++i ) for( int i = 0; i < actions.length; ++i ) {
{
subMenu.add( actions[i] ); subMenu.add( actions[i] );
} }
} }
menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu ); menu.appendToGroup( ICDebugUIConstants.FORMAT_GROUP, subMenu );
menu.appendToGroup( IDebugUIConstants.RENDER_GROUP, getAction( "ShowAscii" ) ); //$NON-NLS-1$ menu.appendToGroup( IDebugUIConstants.RENDER_GROUP, getAction( "ShowAscii" ) ); //$NON-NLS-1$
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager) * @see org.eclipse.debug.ui.AbstractDebugView#configureToolBar(IToolBarManager)
*/ */
protected void configureToolBar( IToolBarManager tbm ) protected void configureToolBar( IToolBarManager tbm ) {
{
tbm.add( new Separator( this.getClass().getName() ) ); tbm.add( new Separator( this.getClass().getName() ) );
tbm.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) ); tbm.add( new Separator( ICDebugUIConstants.MEMORY_GROUP ) );
tbm.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$ tbm.add( getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$ tbm.add( getAction( "RefreshMemory" ) ); //$NON-NLS-1$
tbm.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$ tbm.add( getAction( "ClearMemory" ) ); //$NON-NLS-1$
tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) ); tbm.add( new Separator( IDebugUIConstants.RENDER_GROUP ) );
tbm.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$ tbm.add( getAction( "ShowAscii" ) ); //$NON-NLS-1$
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/ */
public void selectionChanged( IWorkbenchPart part, ISelection selection ) public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
{ if ( selection instanceof IStructuredSelection ) {
if ( selection instanceof IStructuredSelection )
{
setViewerInput( (IStructuredSelection)selection ); setViewerInput( (IStructuredSelection)selection );
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
*/ */
public void propertyChange( PropertyChangeEvent event ) public void propertyChange( PropertyChangeEvent event ) {
{ ((MemoryViewer)getViewer()).propertyChange( event );
((MemoryViewer)getViewer()).propertyChange( event );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler#handleException(DebugException) * @see org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler#handleException(DebugException)
*/ */
public void handleException( DebugException e ) public void handleException( DebugException e ) {
{
} }
/** /**
* Remove myself as a selection listener and preference change * Remove myself as a selection listener and preference change listener.
* listener. *
*
* @see IWorkbenchPart#dispose() * @see IWorkbenchPart#dispose()
*/ */
public void dispose() public void dispose() {
{
removeActionGroup( fMemoryFormatGroup ); removeActionGroup( fMemoryFormatGroup );
fMemoryFormatGroup.dispose(); fMemoryFormatGroup.dispose();
removeActionGroup( fMemorySizeGroup ); removeActionGroup( fMemorySizeGroup );
fMemorySizeGroup.dispose(); fMemorySizeGroup.dispose();
removeActionGroup( fMemoryNumberOfColumnsGroup ); removeActionGroup( fMemoryNumberOfColumnsGroup );
fMemoryNumberOfColumnsGroup.dispose(); fMemoryNumberOfColumnsGroup.dispose();
remove( (ShowAsciiAction)getAction( "ShowAscii" ) ); //$NON-NLS-1$ remove( (ShowAsciiAction)getAction( "ShowAscii" ) ); //$NON-NLS-1$
remove( (ClearMemoryAction)getAction( "ClearMemory" ) ); //$NON-NLS-1$ remove( (ClearMemoryAction)getAction( "ClearMemory" ) ); //$NON-NLS-1$
remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) ); //$NON-NLS-1$ remove( (RefreshMemoryAction)getAction( "RefreshMemory" ) ); //$NON-NLS-1$
remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$ remove( (AutoRefreshMemoryAction)getAction( "AutoRefreshMemory" ) ); //$NON-NLS-1$
getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); getSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this ); CDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener( this );
super.dispose(); super.dispose();
} }
protected void setViewerInput( IStructuredSelection ssel ) protected void setViewerInput( IStructuredSelection ssel ) {
{
ICMemoryManager mm = null; ICMemoryManager mm = null;
if ( ssel != null && ssel.size() == 1 ) if ( ssel != null && ssel.size() == 1 ) {
{
Object input = ssel.getFirstElement(); Object input = ssel.getFirstElement();
if ( input instanceof IDebugElement ) if ( input instanceof IDebugElement ) {
{
mm = (ICMemoryManager)((IDebugElement)input).getDebugTarget().getAdapter( ICMemoryManager.class ); mm = (ICMemoryManager)((IDebugElement)input).getDebugTarget().getAdapter( ICMemoryManager.class );
} }
} }
Object current = getViewer().getInput(); Object current = getViewer().getInput();
if ( current != null && current.equals( mm ) ) if ( current != null && current.equals( mm ) ) {
{
return; return;
} }
showViewer(); showViewer();
getViewer().setInput( mm ); getViewer().setInput( mm );
updateObjects(); updateObjects();
} }
private IContentProvider createContentProvider() private IContentProvider createContentProvider() {
{
return new MemoryViewContentProvider(); return new MemoryViewContentProvider();
} }
private IDebugModelPresentation getModelPresentation() private IDebugModelPresentation getModelPresentation() {
{ if ( fModelPresentation == null ) {
if ( fModelPresentation == null )
{
fModelPresentation = CDebugUIPlugin.getDebugModelPresentation(); fModelPresentation = CDebugUIPlugin.getDebugModelPresentation();
} }
return fModelPresentation; return fModelPresentation;
@ -316,50 +286,42 @@ public class MemoryView extends AbstractDebugEventHandlerView
/** /**
* Creates this view's event handler. * Creates this view's event handler.
* *
* @param viewer the viewer associated with this view * @param viewer
* the viewer associated with this view
* @return an event handler * @return an event handler
*/ */
protected AbstractDebugEventHandler createEventHandler( Viewer viewer ) protected AbstractDebugEventHandler createEventHandler( Viewer viewer ) {
{
return new MemoryViewEventHandler( this ); return new MemoryViewEventHandler( this );
} }
/** /**
* Initializes the viewer input on creation * Initializes the viewer input on creation
*/ */
protected void setInitialContent() protected void setInitialContent() {
{ ISelection selection = getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
ISelection selection = if ( selection instanceof IStructuredSelection && !selection.isEmpty() ) {
getSite().getPage().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
if ( selection instanceof IStructuredSelection && !selection.isEmpty() )
{
setViewerInput( (IStructuredSelection)selection ); setViewerInput( (IStructuredSelection)selection );
} }
else else {
{
setViewerInput( null ); setViewerInput( null );
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.ui.AbstractDebugView#createContextMenu(Control) * @see org.eclipse.debug.ui.AbstractDebugView#createContextMenu(Control)
*/ */
protected void createContextMenu( Control menuControl ) protected void createContextMenu( Control menuControl ) {
{
CTabItem[] items = ((MemoryViewer)getViewer()).getTabFolder().getItems(); CTabItem[] items = ((MemoryViewer)getViewer()).getTabFolder().getItems();
for ( int i = 0; i < items.length; ++i ) for( int i = 0; i < items.length; ++i ) {
{
super.createContextMenu( ((MemoryControlArea)items[i].getControl()).getMemoryText().getControl() ); super.createContextMenu( ((MemoryControlArea)items[i].getControl()).getMemoryText().getControl() );
} }
} }
private void createFormatActionGroup( MemoryActionSelectionGroup group ) private void createFormatActionGroup( MemoryActionSelectionGroup group ) {
{ int[] formats = new int[]{ IFormattedMemoryBlock.MEMORY_FORMAT_HEX, IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL, IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL };
int[] formats = new int[] { IFormattedMemoryBlock.MEMORY_FORMAT_HEX, for( int i = 0; i < formats.length; ++i ) {
IFormattedMemoryBlock.MEMORY_FORMAT_SIGNED_DECIMAL,
IFormattedMemoryBlock.MEMORY_FORMAT_UNSIGNED_DECIMAL };
for ( int i = 0; i < formats.length; ++i )
{
MemoryFormatAction action = new MemoryFormatAction( group, (MemoryViewer)getViewer(), formats[i] ); MemoryFormatAction action = new MemoryFormatAction( group, (MemoryViewer)getViewer(), formats[i] );
action.setEnabled( false ); action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$ setAction( action.getActionId(), action ); //$NON-NLS-1$
@ -367,15 +329,10 @@ public class MemoryView extends AbstractDebugEventHandlerView
group.addAction( action ); group.addAction( action );
} }
} }
private void createSizeActionGroup( MemoryActionSelectionGroup group ) private void createSizeActionGroup( MemoryActionSelectionGroup group ) {
{ int[] ids = new int[]{ IFormattedMemoryBlock.MEMORY_SIZE_BYTE, IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD, IFormattedMemoryBlock.MEMORY_SIZE_WORD, IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD };
int[] ids = new int[] { IFormattedMemoryBlock.MEMORY_SIZE_BYTE, for( int i = 0; i < ids.length; ++i ) {
IFormattedMemoryBlock.MEMORY_SIZE_HALF_WORD,
IFormattedMemoryBlock.MEMORY_SIZE_WORD,
IFormattedMemoryBlock.MEMORY_SIZE_DOUBLE_WORD };
for ( int i = 0; i < ids.length; ++i )
{
MemorySizeAction action = new MemorySizeAction( group, (MemoryViewer)getViewer(), ids[i] ); MemorySizeAction action = new MemorySizeAction( group, (MemoryViewer)getViewer(), ids[i] );
action.setEnabled( false ); action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$ setAction( action.getActionId(), action ); //$NON-NLS-1$
@ -383,16 +340,10 @@ public class MemoryView extends AbstractDebugEventHandlerView
group.addAction( action ); group.addAction( action );
} }
} }
private void createNumberOfColumnsActionGroup( MemoryActionSelectionGroup group ) private void createNumberOfColumnsActionGroup( MemoryActionSelectionGroup group ) {
{ int[] nocs = new int[]{ IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_1, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_2, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_4, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_8, IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_16 };
int[] nocs = new int[] { IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_1, for( int i = 0; i < nocs.length; ++i ) {
IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_2,
IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_4,
IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_8,
IFormattedMemoryBlock.MEMORY_NUMBER_OF_COLUMNS_16 };
for ( int i = 0; i < nocs.length; ++i )
{
MemoryNumberOfColumnAction action = new MemoryNumberOfColumnAction( group, (MemoryViewer)getViewer(), nocs[i] ); MemoryNumberOfColumnAction action = new MemoryNumberOfColumnAction( group, (MemoryViewer)getViewer(), nocs[i] );
action.setEnabled( false ); action.setEnabled( false );
setAction( action.getActionId(), action ); //$NON-NLS-1$ setAction( action.getActionId(), action ); //$NON-NLS-1$
@ -400,32 +351,28 @@ public class MemoryView extends AbstractDebugEventHandlerView
group.addAction( action ); group.addAction( action );
} }
} }
private void removeActionGroup( MemoryActionSelectionGroup group ) private void removeActionGroup( MemoryActionSelectionGroup group ) {
{
IAction[] actions = group.getActions(); IAction[] actions = group.getActions();
for ( int i = 0; i < actions.length; ++i ) for( int i = 0; i < actions.length; ++i ) {
{
remove( (IUpdate)actions[i] ); remove( (IUpdate)actions[i] );
} }
} }
private void setGlobalAction( String actionId, MemoryViewAction action ) private void setGlobalAction( String actionId, MemoryViewAction action ) {
{
add( action ); add( action );
getViewSite().getActionBars().setGlobalActionHandler( actionId, action ); getViewSite().getActionBars().setGlobalActionHandler( actionId, action );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
public Object getAdapter( Class adapter ) public Object getAdapter( Class adapter ) {
{ if ( ITextOperationTarget.class.equals( adapter ) ) {
if (ITextOperationTarget.class.equals( adapter ) )
{
return ((MemoryViewer)getViewer()).getTextOperationTarget(); return ((MemoryViewer)getViewer()).getTextOperationTarget();
} }
return super.getAdapter( adapter );
return super.getAdapter(adapter);
} }
} }

View file

@ -0,0 +1,35 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory;
import java.util.MissingResourceException;
//import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class MemoryViewMessages {
// private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.memory.MemoryViewMessages";//$NON-NLS-1$
// private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private MemoryViewMessages() {
}
public static String getString( String key ) {
try {
return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,15 @@
MemoryViewer.0=Memory
MemoryView.0=Cut
MemoryView.1=Copy
MemoryView.2=Paste
MemoryView.3=Select All
MemoryView.4=Format
MemoryView.5=Memory Unit Size
MemoryView.6=Number Of Columns
MemoryControlArea.0=Address:
MemoryControlArea.1=Evaluate
MemoryControlArea.2=Evaluate expression to address
MemoryControlArea.3=Unable to get the memory block.
MemoryControlArea.4=Memory View
MemoryControlArea.7=Unable to refresh the memory block.
MemoryControlArea.8=Unable to get the memory block.

View file

@ -1,8 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.memory; package org.eclipse.cdt.debug.internal.ui.views.memory;
import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock; import org.eclipse.cdt.debug.core.model.IFormattedMemoryBlock;
@ -20,41 +25,40 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/** /**
* * The viewer of the Memory view.
* Memory viewer.
*
* @since Jul 24, 2002
*/ */
public class MemoryViewer extends ContentViewer public class MemoryViewer extends ContentViewer {
{
static final private int NUMBER_OF_TABS = 4; static final private int NUMBER_OF_TABS = 4;
protected MemoryView fView = null; protected MemoryView fView = null;
protected Composite fParent = null; protected Composite fParent = null;
protected CTabFolder fTabFolder = null; protected CTabFolder fTabFolder = null;
private Composite fControl = null; private Composite fControl = null;
private MemoryControlArea[] fMemoryControlAreas = new MemoryControlArea[NUMBER_OF_TABS]; private MemoryControlArea[] fMemoryControlAreas = new MemoryControlArea[NUMBER_OF_TABS];
/** /**
* Constructor for MemoryViewer. * Constructor for MemoryViewer.
*/ */
public MemoryViewer( Composite parent, MemoryView view ) public MemoryViewer( Composite parent, MemoryView view ) {
{
super(); super();
fParent = parent; fParent = parent;
fView = view; fView = view;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#getControl() * @see org.eclipse.jface.viewers.Viewer#getControl()
*/ */
public Control getControl() public Control getControl() {
{ if ( fControl == null ) {
if ( fControl == null )
{
fControl = new Composite( fParent, SWT.NONE ); fControl = new Composite( fParent, SWT.NONE );
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.marginHeight = 0; layout.marginHeight = 0;
@ -63,227 +67,190 @@ public class MemoryViewer extends ContentViewer
fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) ); fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fTabFolder = new CTabFolder( fControl, SWT.TOP ); fTabFolder = new CTabFolder( fControl, SWT.TOP );
fTabFolder.setLayoutData( new GridData( GridData.FILL_BOTH | GridData.GRAB_VERTICAL ) ); fTabFolder.setLayoutData( new GridData( GridData.FILL_BOTH | GridData.GRAB_VERTICAL ) );
for ( int i = 0; i < NUMBER_OF_TABS; ++i ) for( int i = 0; i < NUMBER_OF_TABS; ++i ) {
{
CTabItem tabItem = new CTabItem( fTabFolder, SWT.NONE ); CTabItem tabItem = new CTabItem( fTabFolder, SWT.NONE );
tabItem.setText( CDebugUIPlugin.getResourceString("MemoryViewer.Memory") + (i + 1) ); //$NON-NLS-1$ tabItem.setText( MemoryViewMessages.getString( "MemoryViewer.0" ) + ' ' + (i + 1) ); //$NON-NLS-1$
fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i, fView ); fMemoryControlAreas[i] = new MemoryControlArea( fTabFolder, SWT.NONE, i, fView );
tabItem.setControl( fMemoryControlAreas[i] ); tabItem.setControl( fMemoryControlAreas[i] );
} }
fTabFolder.addSelectionListener( new SelectionListener() fTabFolder.addSelectionListener( new SelectionListener() {
{
public void widgetSelected( SelectionEvent e ) public void widgetSelected( SelectionEvent e ) {
{ fView.updateObjects();
fView.updateObjects(); }
}
public void widgetDefaultSelected( SelectionEvent e ) {
public void widgetDefaultSelected( SelectionEvent e ) fView.updateObjects();
{ }
fView.updateObjects(); } );
} fTabFolder.setSelection( 0 );
} );
fTabFolder.setSelection( 0 );
} }
return fControl; return fControl;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
*/ */
public ISelection getSelection() public ISelection getSelection() {
{
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#refresh() * @see org.eclipse.jface.viewers.Viewer#refresh()
*/ */
public void refresh() public void refresh() {
{ if ( fTabFolder != null ) {
if ( fTabFolder != null )
{
CTabItem[] tabItems = fTabFolder.getItems(); CTabItem[] tabItems = fTabFolder.getItems();
for ( int i = 0; i < tabItems.length; ++i ) for( int i = 0; i < tabItems.length; ++i )
if ( tabItems[i].getControl() instanceof MemoryControlArea ) if ( tabItems[i].getControl() instanceof MemoryControlArea )
((MemoryControlArea)tabItems[i].getControl()).refresh(); ((MemoryControlArea)tabItems[i].getControl()).refresh();
} }
} }
public void refresh( Object element ) public void refresh( Object element ) {
{ if ( element instanceof IFormattedMemoryBlock ) {
if ( element instanceof IFormattedMemoryBlock )
{
MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element ); MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element );
if ( mca != null ) if ( mca != null ) {
{
mca.refresh(); mca.refresh();
} }
} }
} }
public void remove( Object element ) public void remove( Object element ) {
{ if ( element instanceof IFormattedMemoryBlock ) {
if ( element instanceof IFormattedMemoryBlock )
{
MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element ); MemoryControlArea mca = getMemoryControlArea( (IFormattedMemoryBlock)element );
if ( mca != null ) if ( mca != null ) {
{
mca.clear(); mca.clear();
} }
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.Viewer#setSelection(ISelection, boolean) * @see org.eclipse.jface.viewers.Viewer#setSelection(ISelection, boolean)
*/ */
public void setSelection( ISelection selection, boolean reveal ) public void setSelection( ISelection selection, boolean reveal ) {
{
} }
public void propertyChange( PropertyChangeEvent event ) public void propertyChange( PropertyChangeEvent event ) {
{ if ( fTabFolder != null ) {
if ( fTabFolder != null )
{
CTabItem[] tabItems = fTabFolder.getItems(); CTabItem[] tabItems = fTabFolder.getItems();
for ( int i = 0; i < tabItems.length; ++i ) for( int i = 0; i < tabItems.length; ++i )
if ( tabItems[i].getControl() instanceof MemoryControlArea ) if ( tabItems[i].getControl() instanceof MemoryControlArea )
((MemoryControlArea)tabItems[i].getControl()).propertyChange( event ); ((MemoryControlArea)tabItems[i].getControl()).propertyChange( event );
} }
} }
protected void inputChanged( Object input, Object oldInput ) protected void inputChanged( Object input, Object oldInput ) {
{ for( int i = 0; i < fMemoryControlAreas.length; ++i )
for ( int i = 0; i < fMemoryControlAreas.length; ++i )
fMemoryControlAreas[i].setInput( input ); fMemoryControlAreas[i].setInput( input );
} }
protected CTabFolder getTabFolder() protected CTabFolder getTabFolder() {
{
return fTabFolder; return fTabFolder;
} }
private MemoryControlArea getMemoryControlArea( IFormattedMemoryBlock block ) private MemoryControlArea getMemoryControlArea( IFormattedMemoryBlock block ) {
{
CTabItem[] tabItems = fTabFolder.getItems(); CTabItem[] tabItems = fTabFolder.getItems();
for ( int i = 0; i < tabItems.length; ++i ) for( int i = 0; i < tabItems.length; ++i ) {
{ if ( tabItems[i].getControl() instanceof MemoryControlArea && block != null && block.equals( ((MemoryControlArea)tabItems[i].getControl()).getMemoryBlock() ) ) {
if ( tabItems[i].getControl() instanceof MemoryControlArea && return (MemoryControlArea)tabItems[i].getControl();
block != null && }
block.equals( ((MemoryControlArea)tabItems[i].getControl()).getMemoryBlock() ) )
{
return (MemoryControlArea)tabItems[i].getControl();
}
} }
return null; return null;
} }
public boolean canChangeFormat( int format ) public boolean canChangeFormat( int format ) {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return ( block != null && block.canChangeFormat( format ) ); return (block != null && block.canChangeFormat( format ));
} }
public boolean canUpdate() public boolean canUpdate() {
{ return (((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null);
return ( ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null );
} }
public boolean canSave() public boolean canSave() {
{ return (((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null);
return ( ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock() != null );
} }
public boolean isFrozen() public boolean isFrozen() {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return ( block != null ) ? block.isFrozen() : true; return (block != null) ? block.isFrozen() : true;
} }
public void setFrozen( boolean frozen ) public void setFrozen( boolean frozen ) {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) if ( block != null ) {
{
block.setFrozen( frozen ); block.setFrozen( frozen );
} }
} }
public void clear() public void clear() {
{
((MemoryControlArea)fTabFolder.getSelection().getControl()).clear(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).clear();
} }
public void refreshMemoryBlock() public void refreshMemoryBlock() {
{
((MemoryControlArea)fTabFolder.getSelection().getControl()).refreshMemoryBlock(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).refreshMemoryBlock();
} }
public boolean showAscii() public boolean showAscii() {
{
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().displayASCII(); return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().displayASCII();
} }
public void setShowAscii( boolean show ) public void setShowAscii( boolean show ) {
{
((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().setDisplayAscii( show ); ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().setDisplayAscii( show );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
} }
public boolean canShowAscii() public boolean canShowAscii() {
{
return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().canDisplayAscii(); return ((MemoryControlArea)fTabFolder.getSelection().getControl()).getPresentation().canDisplayAscii();
} }
public int getCurrentFormat() public int getCurrentFormat() {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return ( block != null ) ? block.getFormat() : 0; return (block != null) ? block.getFormat() : 0;
} }
public void setFormat( int format ) throws DebugException public void setFormat( int format ) throws DebugException {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) if ( block != null ) {
{
block.reformat( format, block.getWordSize(), block.getNumberOfRows(), block.getNumberOfColumns() ); block.reformat( format, block.getWordSize(), block.getNumberOfRows(), block.getNumberOfColumns() );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
} }
} }
public int getCurrentWordSize() public int getCurrentWordSize() {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return ( block != null ) ? block.getWordSize() : 0; return (block != null) ? block.getWordSize() : 0;
} }
public void setWordSize( int size ) throws DebugException public void setWordSize( int size ) throws DebugException {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) if ( block != null ) {
{
block.reformat( block.getFormat(), size, block.getNumberOfRows(), block.getNumberOfColumns() ); block.reformat( block.getFormat(), size, block.getNumberOfRows(), block.getNumberOfColumns() );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
} }
} }
public int getCurrentNumberOfColumns() public int getCurrentNumberOfColumns() {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
return ( block != null ) ? block.getNumberOfColumns() : 0; return (block != null) ? block.getNumberOfColumns() : 0;
} }
public void setNumberOfColumns( int numberOfColumns ) throws DebugException public void setNumberOfColumns( int numberOfColumns ) throws DebugException {
{
IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock(); IFormattedMemoryBlock block = ((MemoryControlArea)fTabFolder.getSelection().getControl()).getMemoryBlock();
if ( block != null ) if ( block != null ) {
{
block.reformat( block.getFormat(), block.getWordSize(), block.getNumberOfRows(), numberOfColumns ); block.reformat( block.getFormat(), block.getWordSize(), block.getNumberOfRows(), numberOfColumns );
((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh(); ((MemoryControlArea)fTabFolder.getSelection().getControl()).refresh();
} }
} }
protected ITextOperationTarget getTextOperationTarget() protected ITextOperationTarget getTextOperationTarget() {
{
return (MemoryControlArea)fTabFolder.getSelection().getControl(); return (MemoryControlArea)fTabFolder.getSelection().getControl();
} }
} }

View file

@ -12,20 +12,22 @@
package org.eclipse.cdt.debug.internal.ui.views.sharedlibs; package org.eclipse.cdt.debug.internal.ui.views.sharedlibs;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class SharedLibrariesMessages { public class SharedLibrariesMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.sharedlibs.SharedLibrariesMessages"; //$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.sharedlibs.SharedLibrariesMessages"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private SharedLibrariesMessages() { private SharedLibrariesMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch (MissingResourceException e) { catch (MissingResourceException e) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -49,8 +49,6 @@ import org.eclipse.ui.IWorkbenchPart;
/** /**
* Displays shared libraries. * Displays shared libraries.
*
* @since: Jan 21, 2003
*/ */
public class SharedLibrariesView extends AbstractDebugEventHandlerView public class SharedLibrariesView extends AbstractDebugEventHandlerView
implements ISelectionListener, implements ISelectionListener,

View file

@ -11,20 +11,22 @@
package org.eclipse.cdt.debug.internal.ui.views.signals; package org.eclipse.cdt.debug.internal.ui.views.signals;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class SignalsMessages { public class SignalsMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.signals.SignalsMessages";//$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.views.signals.SignalsMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private SignalsMessages() { private SignalsMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} catch( MissingResourceException e ) { } catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';
} }

View file

@ -24,7 +24,6 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/** /**
* The wizard to add a file system directory based source location to the source locator. * The wizard to add a file system directory based source location to the source locator.
@ -89,7 +88,7 @@ public class AddDirectorySourceLocationWizard extends Wizard implements INewSour
setErrorMessage( null ); setErrorMessage( null );
String dirText = fAttachBlock.getLocationPath(); String dirText = fAttachBlock.getLocationPath();
if ( dirText.length() == 0 ) { if ( dirText.length() == 0 ) {
setErrorMessage( CDebugUIPlugin.getResourceString( "internal.ui.wizards.AddDirectorySourceLocationWizard.ErrorDirectoryEmpty" ) ); //$NON-NLS-1$ setErrorMessage( WizardMessages.getString( "AddDirectorySourceLocationWizard.6" ) ); //$NON-NLS-1$
complete = false; complete = false;
} }
else { else {

View file

@ -11,24 +11,22 @@
package org.eclipse.cdt.debug.internal.ui.wizards; package org.eclipse.cdt.debug.internal.ui.wizards;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.ResourceBundle; //import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/**
* Comment for .
*/
public class WizardMessages { public class WizardMessages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.wizards.WizardMessages";//$NON-NLS-1$ // private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.wizards.WizardMessages";//$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); // private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private WizardMessages() { private WizardMessages() {
} }
public static String getString( String key ) { public static String getString( String key ) {
// TODO Auto-generated method stub
try { try {
return RESOURCE_BUNDLE.getString( key ); return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
} }
catch( MissingResourceException e ) { catch( MissingResourceException e ) {
return '!' + key + '!'; return '!' + key + '!';

View file

@ -8,6 +8,7 @@ AddDirectorySourceLocationWizard.2=Add a local file system directory to the sour
AddDirectorySourceLocationWizard.3=Directory does not exist. AddDirectorySourceLocationWizard.3=Directory does not exist.
AddDirectorySourceLocationWizard.4=Directory path must be absolute. AddDirectorySourceLocationWizard.4=Directory path must be absolute.
AddDirectorySourceLocationWizard.5=Add a local file system directory to the source locations list. AddDirectorySourceLocationWizard.5=Add a local file system directory to the source locations list.
AddDirectorySourceLocationWizard.6=Directory must not be empty.
AddDirectorySourceLocationBlock.0=Select location directory: AddDirectorySourceLocationBlock.0=Select location directory:
AddDirectorySourceLocationBlock.1=&Browse... AddDirectorySourceLocationBlock.1=&Browse...
AddDirectorySourceLocationBlock.2=Select Location Directory AddDirectorySourceLocationBlock.2=Select Location Directory

View file

@ -221,7 +221,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
log( status ); log( status );
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if ( shell != null ) { if ( shell != null ) {
ErrorDialog.openError( shell, CDebugUIPlugin.getResourceString( "ui.CDebugUIPlugin.Error" ), message, status ); //$NON-NLS-1$ ErrorDialog.openError( shell, UIMessages.getString( "CDebugUIPlugin.0" ), message, status ); //$NON-NLS-1$
} }
} }
@ -230,7 +230,7 @@ public class CDebugUIPlugin extends AbstractUIPlugin implements ISelectionListen
Shell shell = getActiveWorkbenchShell(); Shell shell = getActiveWorkbenchShell();
if ( shell != null ) { if ( shell != null ) {
IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, t.getMessage(), null ); //$NON-NLS-1$ IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, t.getMessage(), null ); //$NON-NLS-1$
ErrorDialog.openError( shell, CDebugUIPlugin.getResourceString( "ui.CDebugUIPlugin.Error" ), message, status ); //$NON-NLS-1$ ErrorDialog.openError( shell, UIMessages.getString( "CDebugUIPlugin.0" ), message, status ); //$NON-NLS-1$
} }
} }

View file

@ -1,76 +1,268 @@
ui.sourcelookup.SourceListDialogField.yes=yes CDebugModelPresentation.unknown_1=unknown
ui.sourcelookup.SourceListDialogField.no=no CDebugImageDescriptorRegistry.0=Allocating image for wrong display.
ui.sourcelookup.SourceListDialogField.Add=Add... CDebugModelPresentation.not_available_1=<not available>
ui.sourcelookup.SourceListDialogField.Up=Up CDTDebugModelPresentation.0=<terminated>
ui.sourcelookup.SourceListDialogField.Down=Down CDTDebugModelPresentation.1=<disconnected>
ui.sourcelookup.SourceListDialogField.Remove=Remove CDTDebugModelPresentation.2=<not_responding>
ui.sourcelookup.SourceListDialogField.Location=Location CDTDebugModelPresentation.3={0} (Exited.{1})
ui.sourcelookup.SourceListDialogField.Association=Association CDTDebugModelPresentation.5=Signal ''{0}'' received. Description: {1}.
ui.sourcelookup.SourceListDialogField.Search_subfolders=Search subfolders CDTDebugModelPresentation.6=Exit code = {0}.
ui.sourcelookup.SourcePropertyPage.Terminated=Terminated. CDTDebugModelPresentation.7={0} (Suspended)
ui.sourcelookup.SourceLookupBlock.Select_All=Select All CDTDebugModelPresentation.8=Thread [{0}]
ui.sourcelookup.SourceLookupBlock.Deselect_All=Deselect All CDTDebugModelPresentation.9=Thread [{0}] (Terminated)
ui.sourcelookup.SourceLookupBlock.Generic_Source_Locations=Generic Source Locations CDTDebugModelPresentation.10=Thread [{0}] (Stepping)
ui.sourcelookup.SourceLookupBlock.Additional_Source_Locations=Additional Source Locations CDTDebugModelPresentation.11=Thread [{0}] (Running)
ui.sourcelookup.SourceLookupBlock.Search_for_dup_src_files=Search for duplicate source files CDTDebugModelPresentation.13=: Signal ''{0}'' received. Description: {1}.
ui.sourcelookup.DefaultSourceLocator.Always_map_to_selection=Always map to the selection CDTDebugModelPresentation.14=: Watchpoint triggered. Old value: ''{0}''. New value: ''{1}''.
ui.sourcelookup.DefaultSourceLocator.Unable_to_create_memento_for_src_location=Unable to create memento for C/C++ source locator. CDTDebugModelPresentation.15=: Watchpoint is out of scope.
ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator=Unable to restore prompting source locator - invalid format. CDTDebugModelPresentation.16=: Breakpoint hit.
ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator_project_not_found=Unable to restore prompting source locator - project {0} not found. CDTDebugModelPresentation.17=: Shared library event.
ui.sourcelookup.DefaultSourceLocator.Exception_initializing_src_locator=Exception occurred initializing source locator. CDTDebugModelPresentation.18=Thread [{0}] (Suspended{1})
ui.sourcelookup.DefaultSourceLocator.Selection_needed=Selection needed CDTDebugModelPresentation.19=Thread [{0}]
ui.sourcelookup.DefaultSourceLocator.Select_file_associated_with_stack_frame=Debugger has found multiple files with the same name.\nPlease select one associated with the selected stack frame. CDTDebugModelPresentation.20=at
ui.sourcelookup.DefaultSourceLocator.Project_does_not_exist=Project "{0}" does not exist. CDTDebugModelPresentation.21=<symbol is not available>
MemoryViewer.Memory=Memory CDTDebugModelPresentation.22=(disabled)
MemoryControlArea.Address=Address: CDTDebugModelPresentation.23=Infinity
MemoryControlArea.Evaluate=Evaluate CDTDebugModelPresentation.24=-Infinity
MemoryControlArea.Evaluate_Expression=Evaluate expression to address CDTDebugModelPresentation.25=(disabled)
MemoryControlArea.Error_memoryBlock=Unable to get memory block. CDTDebugModelPresentation.26=[line: {0}]
MemoryControlArea.Memory_view=Memory View CDTDebugModelPresentation.27=[address: {0}]
MemoryControlArea.Error_memoryRefresh=Unable to refresh memory. CDTDebugModelPresentation.28=[function: {0}]
MemoryView.Cut=Cut CDTDebugModelPresentation.29=[ignore count: {0}]
MemoryView.Copy=Copy CDTDebugModelPresentation.30=if
MemoryView.Paste=Paste CDTDebugModelPresentation.31=at
MemoryView.Select_All=Select All LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library.
MemoryView.Format=Format LoadSymbolsActionDelegate.Operation_failed_1=Operation failed.
MemoryView.Memory_Unit_Size=Memory Unit Size LoadSymbolsForAllAction.Load_Symbols_For_All_1=Load Symbols For All
MemoryView.Number_of_Columns=Number Of Columns LoadSymbolsForAllAction.Load_symbols_for_all_shared_libraries_1=Load symbols for all shared libraries.
RegistersView.Auto_Refresh=Auto-Refresh LoadSymbolsForAllActionDelegate.Error(s)_occurred_loading_the_symbols_1=Error(s) occurred loading the symbols.
RegistersView.Automatically_Refresh_Registers_View=Automatically Refresh Registers View LoadSymbolsForAllAction.Load_Symbols_For_All_2=Load Symbols For All
RegistersView.Refresh_Registers_View=Refresh Registers View LoadSymbolsForAllActionDelegate.Error_1=Error
RegistersView.Refresh=Refresh LoadSymbolsForAllAction.Unable_to_load_symbols_1=Unable to load symbols.
SharedLibrariesView.Name=Name SignalPropertiesDialog.Title_1=Properties for signal ''{0}''
SharedLibrariesView.Start_Address=Start Address SignalPropertiesDialog.Description_label_1=Signal description: {0}.
SharedLibrariesView.End_Address=End Address SignalPropertiesDialog.Stop_label_1=Suspend the program when this signal happens.
SharedLibrariesView.Refresh_Shared_Libraries_View=Refresh Shared Libraries View SignalPropertiesDialog.Pass_label_1=Pass this signal to the program.
SignalsViewer.yes=yes SignalZeroWorkbenchActionDelegate.0=Exceptions occurred attempting to resume without signal.
SignalsViewer.no=no SignalZeroWorkbenchActionDelegate.1=Resume without signal failed.
SignalsViewer.Name=Name SignalZeroWorkbenchActionDelegate.2=Resume Without Signal
SignalsViewer.Pass=Pass SignalZeroObjectActionDelegate.0=Unable to resume ignoring the signal.
SignalsViewer.Suspend=Suspend SignalZeroObjectActionDelegate.1=Operation failed.
SignalsViewer.Description=Description SignalPropertiesActionDelegate.Unable_to_change_signal_properties_1=Unable to change signal properties.
internal.ui.CDTDebugModelPresentation.terminated=<terminated> SignalPropertiesActionDelegate.Operation_failed_1=Operation failed.
internal.ui.CDTDebugModelPresentation.disconnected=<disconnected> RunToLineActionDelegate.Error_1=Error
internal.ui.CDTDebugModelPresentation.not_responding=<not_responding> RunToLineActionDelegate.Operation_failed_1=Operation failed.
internal.ui.CDTDebugModelPresentation.Exited=\ (Exited RunToLineAdapter.Empty_editor_1=Empty editor
internal.ui.CDTDebugModelPresentation.Signal_received_Description=: Signal ''{0}'' received. Description: {1}. RunToLineAdapter.Missing_document_1=Missing document
internal.ui.CDTDebugModelPresentation.Exit_code=. Exit code = ToggleBreakpointAdapter.Empty_editor_1=Empty editor
internal.ui.CDTDebugModelPresentation.closeBracket=) ToggleBreakpointAdapter.Missing_document_1=Missing document
internal.ui.CDTDebugModelPresentation.Suspended=\ (Suspended ToggleBreakpointAdapter.Missing_resource_1=Missing resource
internal.ui.CDTDebugModelPresentation.Thread_threadName_suspended=Thread [{0}] (Suspended) ToggleBreakpointAdapter.Invalid_line_1=Invalid line
internal.ui.CDTDebugModelPresentation.Thread_name=Thread [{0}] ToggleBreakpointAdapter.Empty_editor_2=Empty editor
internal.ui.CDTDebugModelPresentation.threadName_Terminated={0} (Terminated) ToggleWatchpointActionDelegate.Error_1=Error
internal.ui.CDTDebugModelPresentation.threadName_Stepping={0} (Stepping) ToggleBreakpointAdapter.Missing_document_2=Missing document
internal.ui.CDTDebugModelPresentation.threadName_Running={0} (Running) ToggleBreakpointAdapter.Missing_resource_2=Missing resource
internal.ui.CDTDebugModelPresentation.Thread_threadName_suspended=Thread [{0}] (Suspended) ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression:
internal.ui.CDTDebugModelPresentation.Symbol_not_available=<symbol is not available> RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported.
internal.ui.CDTDebugModelPresentation.disabled=\ (disabled) EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint
internal.ui.CDTDebugModelPresentation.Infinity=Infinity EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints
internal.ui.CDTDebugModelPresentation.line=\ [line: {0}] EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint
internal.ui.CDTDebugModelPresentation.function=\ [function: {0}] EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint
internal.ui.CDTDebugModelPresentation.address=\ [address: {0}] ToggleBreakpointRulerAction.Toggle_Breakpoint_1=Toggle &Breakpoint
internal.ui.CDTDebugModelPresentation.ignore_count=\ [ignore count: {0}] ToggleWatchpointActionDelegate.Operation_failed_1=Operation failed.
internal.ui.CDTDebugModelPresentation.if=if ToggleBreakpointRulerAction.Error_1=Error
internal.ui.CDTDebugModelPresentation.at=at ToggleBreakpointRulerAction.Operation_failed_1=Operation failed
internal.ui.CDebugImageDescriptorRegistry.Allocating_image_for_wrong_display=Allocating image for wrong display CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties...
ui.CDebugUIPlugin.Error=Error ResumeAtLineActionDelegate.Error_1=Error
RestoreDefaultTypeActionDelegate.0=Unable to restore the default type.
ResumeAtLineActionDelegate.Operation_failed_1=Operation failed.
ResumeAtLineActionDelegate.Missing_document=Missing document
ResumeAtLineActionDelegate.Empty_editor_1=Empty editor
ResumeAtLineActionDelegate.Operation_is_not_supported_1=Operation is not supported
AddGlobalsActionDelegate.Error(s)_occured_adding_globals_1=Error(s) occured adding globals.
AbstractRefreshActionDelegate.Error_1=Error
AbstractRefreshActionDelegate.Error(s)_occurred_refreshing_the_view_1=Error(s) occurred refreshing the view.
ManageFunctionBreakpointActionDelegate.Error_1=Error
ManageFunctionBreakpointActionDelegate.Operation_failed_1=Operation failed.
SignalActionDelegate.0=Unable to deliver the signal to the target.
SignalActionDelegate.1=Operation failed.
AutoRefreshMemoryAction.0=Auto-Refresh
AutoRefreshMemoryAction.1=Turns on/off the auto-refresh mode.
AutoRefreshMemoryAction.2=Auto-Refresh Mode
RestartActionDelegate.0=Exception(s) occurred attempting to restart.
RestartActionDelegate.1=Restart failed.
RestartActionDelegate.2=Restart
ShowAsciiAction.0=Show ASCII
ShowAsciiAction.1=Displays the ASCII presentation of the memory.
ShowAsciiAction.2=Show the ASCII presentation
AddGlobalsActionDelegate.0=Select Variables:
AddGlobalsActionDelegate.1=Add global variables failed.
VariableFormatActionDelegate.0=Unable to set format.
ExpressionDialog.0=Add Watch Expression
ExpressionDialog.1=Expression to watch:
CastToTypeActionDelegate.0=The 'Type' field must not be empty.
CastToTypeActionDelegate.1=Cast To Type
CastToTypeActionDelegate.2=Enter type:
CastToTypeActionDelegate.3=Unable to cast to type.
CastToArrayActionDelegate.0=Display As Array
CastToArrayActionDelegate.1=Start index:
CastToArrayActionDelegate.2=Length
CastToArrayActionDelegate.3=The 'First index' field must not be empty.
CastToArrayActionDelegate.4=Invalid first index.
CastToArrayActionDelegate.5=The 'Last index' field must not be empty.
CastToArrayActionDelegate.6=Invalid last index.
CastToArrayActionDelegate.7=The length must be greater than 0.
CastToArrayActionDelegate.8=Unable to display this variable as an array.
EnableVariablesActionDelegate.0=Exceptions occurred enabling the variable(s).
EnableVariablesActionDelegate.1=Enable variable(s) failed.
MemorySizeAction.0={0, number, integer} {0, choice, 1\#byte|2\#bytes}
MemorySizeAction.1=Unable to change memory unit size.
MemoryFormatAction.0=Unable to change the format.
MemoryFormatAction.1=Hexadecimal
MemoryFormatAction.2=Signed_Decimal
MemoryFormatAction.3=Unsigned_Decimal
MemoryNumberOfColumnAction.0={0, number, integer} {0, choice, 0\#columns|1\#column|2\#columns}
MemoryNumberOfColumnAction.1=Unable to change the column number.
CBreakpointPreferencePage.0=Ignore count must be a positive integer
CBreakpointPreferencePage.1=Not available
CBreakpointPreferencePage.2=Function name:
CBreakpointPreferencePage.3=C/C++ Function Breakpoint Properties
CBreakpointPreferencePage.4=Not available
CBreakpointPreferencePage.5=Address:
CBreakpointPreferencePage.6=C/C++ Address Breakpoint Properties
CBreakpointPreferencePage.7=File:
CBreakpointPreferencePage.8=C/C++ Line Breakpoint Properties
CBreakpointPreferencePage.9=Line_Number:
CBreakpointPreferencePage.10=Project:
CBreakpointPreferencePage.11=C/C++ Read Watchpoint Properties
CBreakpointPreferencePage.12=C/C++ Watchpoint Properties
CBreakpointPreferencePage.13=C/C++ Access Watchpoint Properties
CBreakpointPreferencePage.14=Expression To Watch:
CBreakpointPreferencePage.15=&Condition
CBreakpointPreferencePage.16=Invalid_condition.
CBreakpointPreferencePage.17=&Ignore Count:
AddWatchpointActionDelegate.0=Cannot add watchpoint.
AddWatchpointDialog.0=Add Watchpoint
AddWatchpointDialog.1=Expression to watch:
AddWatchpointDialog.2=Access
AddWatchpointDialog.3=Write
AddWatchpointDialog.4=Read
ClearMemoryAction.0=Clear
ClearMemoryAction.1=Clears the current memory block
ClearMemoryAction.2=Clear
RefreshMemoryAction.0=Refreshs the current memory block.
RefreshMemoryAction.1=Refresh
MemoryViewer.0=Memory
MemoryView.0=Cut
MemoryView.1=Copy
MemoryView.2=Paste
MemoryView.3=Select All
MemoryView.4=Format
MemoryView.5=Memory Unit Size
MemoryView.6=Number Of Columns
MemoryControlArea.0=Address:
MemoryControlArea.1=Evaluate
MemoryControlArea.2=Evaluate expression to address
MemoryControlArea.3=Unable to get the memory block.
MemoryControlArea.4=Memory View
MemoryControlArea.7=Unable to refresh the memory block.
MemoryControlArea.8=Unable to get the memory block.
SharedLibrariesView.Name_1=Name
SharedLibrariesView.Start_Address_1=Start Address
SharedLibrariesView.End_Address_1=End Address
SharedLibrariesView.Loaded_1=Loaded
SharedLibrariesView.Not_loaded_1=Not loaded
SharedLibrariesView.Symbols_1=Symbols
SignalsViewer.4=Name
SignalsViewer.5=Pass
SignalsViewer.6=Suspend
SignalsViewer.7=Description
SignalsViewer.8=yes
SignalsViewer.9=no
CDebugEditor.0=C/C++ File Editor
CDebugEditor.1=Source not found
CDebugEditor.2=You can attach a new source location by pressing the button below.
CDebugEditor.3=&Attach Source...
CDebugEditor.4=Can not find the file ''{0}'' in the specified source locations.
CDebugPreferencePage.Color_of_disassembly_source_lines_1=Color of source lines:
CDebugPreferencePage.0=Natural
CDebugPreferencePage.1=Hexadecimal
CDebugPreferencePage.2=Decimal
CDebugPreferencePage.3=General settings for C/C++ Debugging.
CDebugPreferencePage.4=Opened view default settings
CDebugPreferencePage.5=Show full &paths
CDebugPreferencePage.6=Automatically refresh registers
CDebugPreferencePage.7=Automatically refresh shared libraries
CDebugPreferencePage.8=Default variable format:
CDebugPreferencePage.9=Default expression format:
CDebugPreferencePage.10=Default register format:
CDebugPreferencePage.11=Disassembly options
CDebugPreferencePage.12=Maximum number of displayed instructions:
CDebugPreferencePage.13=The valid value range is [{0},{1}].
SourcePreferencePage.0=Common source lookup settings.
SourcePreferencePage.1=Source Locations
SourcePreferencePage.2=Search for duplicate source files
MemoryViewPreferencePage.0=The Memory view settings.
MemoryViewPreferencePage.1=Text Color:
MemoryViewPreferencePage.2=Background Color:
MemoryViewPreferencePage.3=Address Color:
MemoryViewPreferencePage.4=Changed Value Color:
MemoryViewPreferencePage.5=Font:
MemoryViewPreferencePage.6=Padding Character:
MemoryViewPreferencePage.7=Auto-Refresh by default
MemoryViewPreferencePage.8=Show ASCII by default
DisassemblyDocumentProvider.Pending_1=Pending...
DisassemblyInstructionPointerAnnotation.Current_Pointer_1=Current Disassembly Instruction Pointer
DisassemblyInstructionPointerAnnotation.Secondary_Pointer_1=Secondary Disassembly Instruction Pointer
DisassemblyAnnotationHover.Multiple_markers_at_this_line_1=Multiple markers at this line
HTMLTextPresenter.ellipsis=
HTML2TextReader.dash=-
DisassemblyEditorInput.source_line_is_not_available_1=<source line is not available>
AddProjectSourceLocationWizard.0=Select Project
AddProjectSourceLocationWizard.1=Add Project Source Location
AddProjectSourceLocationWizard.2=Add an existing workspace project to the source locations list.
AddProjectSourceLocationWizard.3=Add an existing project to the source locations list.
AddDirectorySourceLocationWizard.0=Select Directory
AddDirectorySourceLocationWizard.1=Add Directory Source Location
AddDirectorySourceLocationWizard.2=Add a local file system directory to the source locations list.
AddDirectorySourceLocationWizard.3=Directory does not exist.
AddDirectorySourceLocationWizard.4=Directory path must be absolute.
AddDirectorySourceLocationWizard.5=Add a local file system directory to the source locations list.
AddDirectorySourceLocationWizard.6=Directory must not be empty.
AddDirectorySourceLocationBlock.0=Select location directory:
AddDirectorySourceLocationBlock.1=&Browse...
AddDirectorySourceLocationBlock.2=Select Location Directory
AddDirectorySourceLocationBlock.3=&Associate with
AddDirectorySourceLocationBlock.4=Search sub&folders
AddSourceLocationWizard.0=Add Source Location
SourceLocationSelectionPage.0=Add Source Location
SourceLocationSelectionPage.1=Select
SourceLocationSelectionPage.2=Select source location type:
SourceLocationSelectionPage.3=Existing Project Into Workspace
SourceLocationSelectionPage.4=File System Directory
CDebugUIPlugin.0=Error
SourceListDialogField.0=yes
SourceListDialogField.1=no
SourceListDialogField.2=Add...
SourceListDialogField.3=Up
SourceListDialogField.4=Down
SourceListDialogField.5=Remove
SourceListDialogField.6=Location
SourceListDialogField.7=Association
SourceListDialogField.8=Search subfolders
SourcePropertyPage.0=Terminated.
SourceLookupBlock.0=Select All
SourceLookupBlock.1=Deselect All
SourceLookupBlock.2=Generic Source Locations
SourceLookupBlock.3=Additional Source Locations
SourceLookupBlock.4=Search for duplicate source files
DefaultSourceLocator.0=Always map to the selection
DefaultSourceLocator.1=Unable to create memento for C/C++ source locator.
DefaultSourceLocator.2=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.3=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.4=Unable to restore prompting source locator - project {0} not found.
DefaultSourceLocator.5=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.6=Exception occurred initializing source locator.
DefaultSourceLocator.7=Selection needed
DefaultSourceLocator.8=Debugger has found multiple files with the same name.\nPlease select one associated with the selected stack frame.
DefaultSourceLocator.9=Project ''{0}'' does not exist.

View file

@ -0,0 +1,34 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.ui;
import java.util.MissingResourceException;
//import java.util.ResourceBundle;
public class UIMessages {
// private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.UIMessages";//$NON-NLS-1$
// private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private UIMessages() {
}
public static String getString( String key ) {
try {
return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1 @@
CDebugUIPlugin.0=Error

View file

@ -1,9 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.ui.sourcelookup; package org.eclipse.cdt.debug.ui.sourcelookup;
import java.io.IOException; import java.io.IOException;
@ -54,60 +58,54 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* Enter type comment. * Default source locator.
*
* @since Oct 24, 2003
*/ */
public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptable public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptable {
{
public class SourceSelectionDialog extends ListDialog public class SourceSelectionDialog extends ListDialog {
{
private SelectionButtonDialogField fAlwaysUseThisFileButton = new SelectionButtonDialogField( SWT.CHECK ); private SelectionButtonDialogField fAlwaysUseThisFileButton = new SelectionButtonDialogField( SWT.CHECK );
public SourceSelectionDialog( Shell parent ) public SourceSelectionDialog( Shell parent ) {
{
super( parent ); super( parent );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite) * @see org.eclipse.ui.dialogs.ListDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/ */
protected Control createDialogArea( Composite parent ) protected Control createDialogArea( Composite parent ) {
{
Composite comp = ControlFactory.createComposite( parent, 1 ); Composite comp = ControlFactory.createComposite( parent, 1 );
super.createDialogArea( comp ); super.createDialogArea( comp );
Composite comp1 = ControlFactory.createComposite( comp, 1 ); Composite comp1 = ControlFactory.createComposite( comp, 1 );
fAlwaysUseThisFileButton.setLabelText( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Always_map_to_selection") ); //$NON-NLS-1$ fAlwaysUseThisFileButton.setLabelText( SourceLookupMessages.getString( "DefaultSourceLocator.0" ) ); //$NON-NLS-1$
fAlwaysUseThisFileButton.doFillIntoGrid( comp1, 1 ); fAlwaysUseThisFileButton.doFillIntoGrid( comp1, 1 );
return comp; return comp;
} }
public boolean alwaysMapToSelection() public boolean alwaysMapToSelection() {
{
return fAlwaysUseThisFileButton.isSelected(); return fAlwaysUseThisFileButton.isSelected();
} }
} }
public class SourceElementLabelProvider extends LabelProvider public class SourceElementLabelProvider extends LabelProvider {
{
protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry(); protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry();
public SourceElementLabelProvider() public SourceElementLabelProvider() {
{
super(); super();
} }
public String getText(Object element) public String getText( Object element ) {
{
if ( element instanceof IFile ) if ( element instanceof IFile )
return ((IFile)element).getFullPath().toString(); return ((IFile)element).getFullPath().toString();
if ( element instanceof FileStorage ) if ( element instanceof FileStorage )
return ((FileStorage)element).getFullPath().toOSString(); return ((FileStorage)element).getFullPath().toOSString();
return super.getText(element); return super.getText( element );
} }
public Image getImage( Object element ) public Image getImage( Object element ) {
{
if ( element instanceof IFile ) if ( element instanceof IFile )
return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_WORKSPACE_SOURCE_FILE ); return fDebugImageRegistry.get( CDebugImages.DESC_OBJS_WORKSPACE_SOURCE_FILE );
if ( element instanceof FileStorage ) if ( element instanceof FileStorage )
@ -117,15 +115,17 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
} }
/** /**
* Identifier for the 'Default C/C++ Source Locator' extension * Identifier for the 'Default C/C++ Source Locator' extension (value <code>"org.eclipse.cdt.debug.ui.DefaultSourceLocator"</code>).
* (value <code>"org.eclipse.cdt.debug.ui.DefaultSourceLocator"</code>).
*/ */
public static final String ID_DEFAULT_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + ".DefaultSourceLocator"; //$NON-NLS-1$ public static final String ID_DEFAULT_SOURCE_LOCATOR = CDebugUIPlugin.getUniqueIdentifier() + ".DefaultSourceLocator"; //$NON-NLS-1$
// to support old configurations // to support old configurations
public static final String ID_OLD_DEFAULT_SOURCE_LOCATOR = "org.eclipse.cdt.launch" + ".DefaultSourceLocator"; //$NON-NLS-1$ //$NON-NLS-2$ public static final String ID_OLD_DEFAULT_SOURCE_LOCATOR = "org.eclipse.cdt.launch" + ".DefaultSourceLocator"; //$NON-NLS-1$ //$NON-NLS-2$
private static final String ELEMENT_NAME = "PromptingSourceLocator"; //$NON-NLS-1$ private static final String ELEMENT_NAME = "PromptingSourceLocator"; //$NON-NLS-1$
private static final String ATTR_PROJECT = "project"; //$NON-NLS-1$ private static final String ATTR_PROJECT = "project"; //$NON-NLS-1$
private static final String ATTR_MEMENTO = "memento"; //$NON-NLS-1$ private static final String ATTR_MEMENTO = "memento"; //$NON-NLS-1$
/** /**
@ -134,76 +134,67 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
private ICSourceLocator fSourceLocator; private ICSourceLocator fSourceLocator;
private HashMap fFramesToSource = null; private HashMap fFramesToSource = null;
private HashMap fNamesToSource = null; private HashMap fNamesToSource = null;
public DefaultSourceLocator() public DefaultSourceLocator() {
{
super(); super();
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento() * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
*/ */
public String getMemento() throws CoreException public String getMemento() throws CoreException {
{ if ( getCSourceLocator() != null ) {
if ( getCSourceLocator() != null ) Document document = null;
{ Throwable ex = null;
Document document = null; try {
Throwable ex = null; document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
try Element element = document.createElement( ELEMENT_NAME );
{ document.appendChild( element );
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element element = document.createElement( ELEMENT_NAME );
document.appendChild( element );
element.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() ); element.setAttribute( ATTR_PROJECT, getCSourceLocator().getProject().getName() );
IPersistableSourceLocator psl = getPersistableSourceLocator(); IPersistableSourceLocator psl = getPersistableSourceLocator();
if ( psl != null ) if ( psl != null ) {
{
element.setAttribute( ATTR_MEMENTO, psl.getMemento() ); element.setAttribute( ATTR_MEMENTO, psl.getMemento() );
} }
return CDebugUtils.serializeDocument( document ); return CDebugUtils.serializeDocument( document );
} }
catch( ParserConfigurationException e ) catch( ParserConfigurationException e ) {
{
ex = e;
}
catch( IOException e )
{
ex = e; ex = e;
} }
catch( TransformerException e ) catch( IOException e ) {
{
ex = e; ex = e;
} }
abort( CDebugUIPlugin.getResourceString( "ui.sourcelookup.DefaultSourceLocator.Unable_to_create_memento_for_src_location" ), ex ); //$NON-NLS-1$ catch( TransformerException e ) {
ex = e;
}
abort( SourceLookupMessages.getString( "DefaultSourceLocator.1" ), ex ); //$NON-NLS-1$
} }
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeFromMemento(java.lang.String)
*/ */
public void initializeFromMemento( String memento ) throws CoreException public void initializeFromMemento( String memento ) throws CoreException {
{
Exception ex = null; Exception ex = null;
try try {
{
Element root = null; Element root = null;
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
StringReader reader = new StringReader( memento ); StringReader reader = new StringReader( memento );
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( ELEMENT_NAME ) ) abort( SourceLookupMessages.getString( "DefaultSourceLocator.2" ), null ); //$NON-NLS-1$
{
abort( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator"), null ); //$NON-NLS-1$
} }
String projectName = root.getAttribute( ATTR_PROJECT ); String projectName = root.getAttribute( ATTR_PROJECT );
String data = root.getAttribute( ATTR_MEMENTO ); String data = root.getAttribute( ATTR_MEMENTO );
if ( isEmpty( projectName ) ) if ( isEmpty( projectName ) ) {
{ abort( SourceLookupMessages.getString( "DefaultSourceLocator.3" ), null ); //$NON-NLS-1$
abort( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator"), null ); //$NON-NLS-1$
} }
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( getCSourceLocator() == null ) if ( getCSourceLocator() == null )
@ -211,78 +202,71 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
if ( getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals( project ) ) if ( getCSourceLocator().getProject() != null && !getCSourceLocator().getProject().equals( project ) )
return; return;
if ( project == null || !project.exists() || !project.isOpen() ) if ( project == null || !project.exists() || !project.isOpen() )
abort( MessageFormat.format( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator_project_not_found"), new String[] { projectName } ), null ); //$NON-NLS-1$ abort( MessageFormat.format( SourceLookupMessages.getString( "DefaultSourceLocator.4" ), new String[]{ projectName } ), null ); //$NON-NLS-1$
IPersistableSourceLocator psl = getPersistableSourceLocator(); IPersistableSourceLocator psl = getPersistableSourceLocator();
if ( psl != null ) if ( psl != null )
psl.initializeFromMemento( data ); psl.initializeFromMemento( data );
else else
abort( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Unable_to_restore_prompting_src_locator_project_not_found"), null ); //$NON-NLS-1$ abort( SourceLookupMessages.getString( "DefaultSourceLocator.5" ), null ); //$NON-NLS-1$
return; return;
} }
catch( ParserConfigurationException e ) catch( ParserConfigurationException e ) {
{
ex = e; ex = e;
} }
catch( SAXException e ) catch( SAXException e ) {
{
ex = e; ex = e;
} }
catch( IOException e ) catch( IOException e ) {
{
ex = e; ex = e;
} }
abort( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Exception_initializing_src_locator"), ex ); //$NON-NLS-1$ abort( SourceLookupMessages.getString( "DefaultSourceLocator.6" ), ex ); //$NON-NLS-1$
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration) * @see org.eclipse.debug.core.model.IPersistableSourceLocator#initializeDefaults(org.eclipse.debug.core.ILaunchConfiguration)
*/ */
public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException public void initializeDefaults( ILaunchConfiguration configuration ) throws CoreException {
{
setCSourceLocator( SourceLookupFactory.createSourceLocator( getProject( configuration ) ) ); setCSourceLocator( SourceLookupFactory.createSourceLocator( getProject( configuration ) ) );
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$ String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$
if ( !isEmpty( memento ) ) if ( !isEmpty( memento ) )
initializeFromMemento( memento ); initializeFromMemento( memento );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
public Object getAdapter( Class adapter ) public Object getAdapter( Class adapter ) {
{ if ( getCSourceLocator() instanceof IAdaptable ) {
if ( getCSourceLocator() instanceof IAdaptable ) if ( adapter.equals( ICSourceLocator.class ) ) {
{
if ( adapter.equals( ICSourceLocator.class ) )
{
return ((IAdaptable)getCSourceLocator()).getAdapter( adapter ); return ((IAdaptable)getCSourceLocator()).getAdapter( adapter );
} }
if ( adapter.equals( IResourceChangeListener.class ) ) if ( adapter.equals( IResourceChangeListener.class ) ) {
{
return ((IAdaptable)getCSourceLocator()).getAdapter( adapter ); return ((IAdaptable)getCSourceLocator()).getAdapter( adapter );
} }
} }
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame) * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame)
*/ */
public Object getSourceElement( IStackFrame stackFrame ) public Object getSourceElement( IStackFrame stackFrame ) {
{
Object res = cacheLookup( stackFrame ); Object res = cacheLookup( stackFrame );
if ( res == null ) if ( res == null ) {
{
res = getCSourceLocator().getSourceElement( stackFrame ); res = getCSourceLocator().getSourceElement( stackFrame );
if ( res instanceof List ) if ( res instanceof List ) {
{
List list = (List)res; List list = (List)res;
if ( list.size() != 0 ) if ( list.size() != 0 ) {
{
SourceSelectionDialog dialog = createSourceSelectionDialog( list ); SourceSelectionDialog dialog = createSourceSelectionDialog( list );
dialog.open(); dialog.open();
Object[] objs = dialog.getResult(); Object[] objs = dialog.getResult();
res = ( objs != null && objs.length > 0 ) ? objs[0] : null; res = (objs != null && objs.length > 0) ? objs[0] : null;
if ( res != null ) if ( res != null )
cacheSourceElement( stackFrame, res, dialog.alwaysMapToSelection() ); cacheSourceElement( stackFrame, res, dialog.alwaysMapToSelection() );
} }
@ -290,10 +274,8 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
res = null; res = null;
} }
} }
if ( res == null ) if ( res == null ) {
{ if ( stackFrame instanceof ICStackFrame && !isEmpty( ((ICStackFrame)stackFrame).getFile() ) ) {
if ( stackFrame instanceof ICStackFrame && !isEmpty( ((ICStackFrame)stackFrame).getFile() ) )
{
res = new FileNotFoundElement( stackFrame ); res = new FileNotFoundElement( stackFrame );
} }
else // don't show in editor else // don't show in editor
@ -304,68 +286,56 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
return res; return res;
} }
protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) {
{ try {
try
{
ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() ); ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() );
copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
copy.doSave(); copy.doSave();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null );
} }
} }
private SourceSelectionDialog createSourceSelectionDialog( List list ) private SourceSelectionDialog createSourceSelectionDialog( List list ) {
{
SourceSelectionDialog dialog = new SourceSelectionDialog( CDebugUIPlugin.getActiveWorkbenchShell() ); SourceSelectionDialog dialog = new SourceSelectionDialog( CDebugUIPlugin.getActiveWorkbenchShell() );
dialog.setInput( list.toArray() ); dialog.setInput( list.toArray() );
dialog.setContentProvider( new ArrayContentProvider() ); dialog.setContentProvider( new ArrayContentProvider() );
dialog.setLabelProvider( new SourceElementLabelProvider() ); dialog.setLabelProvider( new SourceElementLabelProvider() );
dialog.setTitle( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Selection_needed") ); //$NON-NLS-1$ dialog.setTitle( SourceLookupMessages.getString( "DefaultSourceLocator.7" ) ); //$NON-NLS-1$
dialog.setMessage( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Select_file_associated_with_stack_frame") ); //$NON-NLS-1$ dialog.setMessage( SourceLookupMessages.getString( "DefaultSourceLocator.8" ) ); //$NON-NLS-1$
dialog.setInitialSelections( new Object[] { list.get( 0 ) } ); dialog.setInitialSelections( new Object[]{ list.get( 0 ) } );
return dialog; return dialog;
} }
private void cacheSourceElement( IStackFrame frame, Object sourceElement, boolean alwaysMapToSelection ) private void cacheSourceElement( IStackFrame frame, Object sourceElement, boolean alwaysMapToSelection ) {
{ if ( alwaysMapToSelection ) {
if ( alwaysMapToSelection )
{
String name = getFileName( frame ); String name = getFileName( frame );
if ( name != null ) if ( name != null ) {
{ if ( fNamesToSource == null )
if ( fNamesToSource == null )
fNamesToSource = new HashMap(); fNamesToSource = new HashMap();
fNamesToSource.put( name, sourceElement ); fNamesToSource.put( name, sourceElement );
} }
} }
else else {
{ if ( fFramesToSource == null )
if ( fFramesToSource == null )
fFramesToSource = new HashMap(); fFramesToSource = new HashMap();
fFramesToSource.put( frame, sourceElement ); fFramesToSource.put( frame, sourceElement );
} }
} }
private Object cacheLookup( IStackFrame frame ) private Object cacheLookup( IStackFrame frame ) {
{
String name = getFileName( frame ); String name = getFileName( frame );
if ( name != null && fNamesToSource != null ) if ( name != null && fNamesToSource != null ) {
{
Object result = fNamesToSource.get( name ); Object result = fNamesToSource.get( name );
if ( result != null ) if ( result != null )
return result; return result;
} }
return ( fFramesToSource != null ) ? fFramesToSource.get( frame ) : null; return (fFramesToSource != null) ? fFramesToSource.get( frame ) : null;
} }
private String getFileName( IStackFrame frame ) private String getFileName( IStackFrame frame ) {
{ if ( frame instanceof ICStackFrame ) {
if ( frame instanceof ICStackFrame )
{
String name = ((ICStackFrame)frame).getFile(); String name = ((ICStackFrame)frame).getFile();
if ( !isEmpty( name ) ) if ( !isEmpty( name ) )
return name.trim(); return name.trim();
@ -373,48 +343,40 @@ public class DefaultSourceLocator implements IPersistableSourceLocator, IAdaptab
return null; return null;
} }
private ICSourceLocator getCSourceLocator() private ICSourceLocator getCSourceLocator() {
{
return fSourceLocator; return fSourceLocator;
} }
private void setCSourceLocator( ICSourceLocator locator ) private void setCSourceLocator( ICSourceLocator locator ) {
{
fSourceLocator = locator; fSourceLocator = locator;
} }
private IPersistableSourceLocator getPersistableSourceLocator() private IPersistableSourceLocator getPersistableSourceLocator() {
{
ICSourceLocator sl = getCSourceLocator(); ICSourceLocator sl = getCSourceLocator();
return ( sl instanceof IPersistableSourceLocator ) ? (IPersistableSourceLocator)sl : null; return (sl instanceof IPersistableSourceLocator) ? (IPersistableSourceLocator)sl : null;
} }
/** /**
* Throws an internal error exception * Throws an internal error exception
*/ */
private void abort( String message, Throwable e ) throws CoreException private void abort( String message, Throwable e ) throws CoreException {
{
IStatus s = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, message, e ); IStatus s = new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), 0, message, e );
throw new CoreException( s ); throw new CoreException( s );
} }
private boolean isEmpty( String string ) private boolean isEmpty( String string ) {
{
return string == null || string.trim().length() == 0; return string == null || string.trim().length() == 0;
} }
private IProject getProject( ILaunchConfiguration configuration ) throws CoreException private IProject getProject( ILaunchConfiguration configuration ) throws CoreException {
{
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null ); String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null );
if ( !isEmpty( projectName ) ) if ( !isEmpty( projectName ) ) {
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project.exists() ) if ( project.exists() ) {
{
return project; return project;
} }
} }
abort( MessageFormat.format( CDebugUIPlugin.getResourceString("ui.sourcelookup.DefaultSourceLocator.Project_does_not_exist"), new String[] { projectName } ), null ); //$NON-NLS-1$ abort( MessageFormat.format( SourceLookupMessages.getString( "DefaultSourceLocator.9" ), new String[]{ projectName } ), null ); //$NON-NLS-1$
return null; return null;
} }
} }

View file

@ -1,15 +1,14 @@
/* /***************************************************************************************************************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This program and the accompanying materials are made available under the terms of
* All Rights Reserved. * the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors: QNX Software Systems - Initial API and implementation
**************************************************************************************************************************************************************/
package org.eclipse.cdt.debug.ui.sourcelookup; package org.eclipse.cdt.debug.ui.sourcelookup;
import java.util.List; import java.util.List;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation; import org.eclipse.cdt.debug.internal.core.sourcelookup.CDirectorySourceLocation;
import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter; import org.eclipse.cdt.debug.internal.ui.dialogfields.IListAdapter;
@ -28,187 +27,153 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class SourceListDialogField extends ListDialogField {
public class SourceListDialogField extends ListDialogField public class ObservableSourceList extends Observable {
{
public class ObservableSourceList extends Observable protected synchronized void setChanged() {
{
protected synchronized void setChanged()
{
super.setChanged(); super.setChanged();
} }
} }
// String constants // String constants
protected static final String YES_VALUE = CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.yes"); //$NON-NLS-1$ protected static final String YES_VALUE = SourceLookupMessages.getString( "SourceListDialogField.0" ); //$NON-NLS-1$
protected static final String NO_VALUE = CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.no"); //$NON-NLS-1$
protected static final String NO_VALUE = SourceLookupMessages.getString( "SourceListDialogField.1" ); //$NON-NLS-1$
// Column properties // Column properties
private static final String CP_LOCATION = "location"; //$NON-NLS-1$ private static final String CP_LOCATION = "location"; //$NON-NLS-1$
private static final String CP_ASSOCIATION = "association"; //$NON-NLS-1$ private static final String CP_ASSOCIATION = "association"; //$NON-NLS-1$
private static final String CP_SEARCH_SUBFOLDERS = "searchSubfolders"; //$NON-NLS-1$ private static final String CP_SEARCH_SUBFOLDERS = "searchSubfolders"; //$NON-NLS-1$
private ObservableSourceList fObservable = new ObservableSourceList(); private ObservableSourceList fObservable = new ObservableSourceList();
public SourceListDialogField( String title, IListAdapter listAdapter ) public SourceListDialogField( String title, IListAdapter listAdapter ) {
{ super( listAdapter, new String[]{
super( listAdapter, /* 0 */SourceLookupMessages.getString( "SourceListDialogField.2" ), //$NON-NLS-1$
new String[] /* 1 */null,
{ /* 2 */SourceLookupMessages.getString( "SourceListDialogField.3" ), //$NON-NLS-1$
/* 0 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Add"), //$NON-NLS-1$ /* 3 */SourceLookupMessages.getString( "SourceListDialogField.4" ), //$NON-NLS-1$
/* 1 */ null, /* 4 */null,
/* 2 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Up"), //$NON-NLS-1$ /* 5 */SourceLookupMessages.getString( "SourceListDialogField.5" ) //$NON-NLS-1$
/* 3 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Down"), //$NON-NLS-1$ }, new SourceLookupLabelProvider() );
/* 4 */ null,
/* 5 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Remove"), //$NON-NLS-1$
},
new SourceLookupLabelProvider() );
setUpButtonIndex( 2 ); setUpButtonIndex( 2 );
setDownButtonIndex( 3 ); setDownButtonIndex( 3 );
setRemoveButtonIndex( 5 ); setRemoveButtonIndex( 5 );
setLabelText( title ); setLabelText( title );
} }
protected boolean managedButtonPressed( int index ) protected boolean managedButtonPressed( int index ) {
{
super.managedButtonPressed( index ); super.managedButtonPressed( index );
return false; return false;
} }
protected TableViewer createTableViewer( Composite parent ) protected TableViewer createTableViewer( Composite parent ) {
{
TableViewer viewer = super.createTableViewer( parent ); TableViewer viewer = super.createTableViewer( parent );
Table table = viewer.getTable(); Table table = viewer.getTable();
TableLayout tableLayout = new TableLayout(); TableLayout tableLayout = new TableLayout();
table.setLayout( tableLayout ); table.setLayout( tableLayout );
GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL ); GridData gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL );
gd.grabExcessVerticalSpace = true; gd.grabExcessVerticalSpace = true;
gd.grabExcessHorizontalSpace = true; gd.grabExcessHorizontalSpace = true;
table.setLayoutData( gd ); table.setLayoutData( gd );
table.setLinesVisible( true ); table.setLinesVisible( true );
table.setHeaderVisible( true ); table.setHeaderVisible( true );
new TableColumn( table, SWT.NULL ); new TableColumn( table, SWT.NULL );
tableLayout.addColumnData( new ColumnWeightData( 2, true ) ); tableLayout.addColumnData( new ColumnWeightData( 2, true ) );
new TableColumn( table, SWT.NULL ); new TableColumn( table, SWT.NULL );
tableLayout.addColumnData( new ColumnWeightData( 2, true ) ); tableLayout.addColumnData( new ColumnWeightData( 2, true ) );
new TableColumn( table, SWT.NULL ); new TableColumn( table, SWT.NULL );
tableLayout.addColumnData( new ColumnWeightData( 1, true ) ); tableLayout.addColumnData( new ColumnWeightData( 1, true ) );
TableColumn[] columns = table.getColumns(); TableColumn[] columns = table.getColumns();
columns[0].setText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Location") ); //$NON-NLS-1$ columns[0].setText( SourceLookupMessages.getString( "SourceListDialogField.6" ) ); //$NON-NLS-1$
columns[1].setText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Association") ); //$NON-NLS-1$ columns[1].setText( SourceLookupMessages.getString( "SourceListDialogField.7" ) ); //$NON-NLS-1$
columns[2].setText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceListDialogField.Search_subfolders") ); //$NON-NLS-1$ columns[2].setText( SourceLookupMessages.getString( "SourceListDialogField.8" ) ); //$NON-NLS-1$
CellEditor textCellEditor = new TextCellEditor( table ); CellEditor textCellEditor = new TextCellEditor( table );
CellEditor comboCellEditor = new ComboBoxCellEditor( table, new String[]{ YES_VALUE, NO_VALUE } ); CellEditor comboCellEditor = new ComboBoxCellEditor( table, new String[]{ YES_VALUE, NO_VALUE } );
viewer.setCellEditors( new CellEditor[]{ null, textCellEditor, comboCellEditor } ); viewer.setCellEditors( new CellEditor[]{ null, textCellEditor, comboCellEditor } );
viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION, CP_SEARCH_SUBFOLDERS } ); viewer.setColumnProperties( new String[]{ CP_LOCATION, CP_ASSOCIATION, CP_SEARCH_SUBFOLDERS } );
viewer.setCellModifier( createCellModifier() ); viewer.setCellModifier( createCellModifier() );
return viewer; return viewer;
} }
private ICellModifier createCellModifier() private ICellModifier createCellModifier() {
{ return new ICellModifier() {
return new ICellModifier()
{
public boolean canModify( Object element, String property )
{
return ( element instanceof CDirectorySourceLocation && ( property.equals( CP_ASSOCIATION ) || property.equals( CP_SEARCH_SUBFOLDERS ) ) );
}
public Object getValue( Object element, String property ) public boolean canModify( Object element, String property ) {
{ return (element instanceof CDirectorySourceLocation && (property.equals( CP_ASSOCIATION ) || property.equals( CP_SEARCH_SUBFOLDERS )));
if ( element instanceof CDirectorySourceLocation && property.equals( CP_ASSOCIATION ) ) }
{
return ( ((CDirectorySourceLocation)element).getAssociation() != null ) ?
((CDirectorySourceLocation)element).getAssociation().toOSString() : ""; //$NON-NLS-1$
}
if ( element instanceof CDirectorySourceLocation && property.equals( CP_SEARCH_SUBFOLDERS ) )
{
return ( ((CDirectorySourceLocation)element).searchSubfolders() ) ? new Integer( 0 ) : new Integer( 1 );
}
return null;
}
public void modify( Object element, String property, Object value ) public Object getValue( Object element, String property ) {
{ if ( element instanceof CDirectorySourceLocation && property.equals( CP_ASSOCIATION ) ) {
Object entry = getSelection(); return (((CDirectorySourceLocation)element).getAssociation() != null) ? ((CDirectorySourceLocation)element).getAssociation().toOSString() : ""; //$NON-NLS-1$
if ( entry instanceof CDirectorySourceLocation ) }
{ if ( element instanceof CDirectorySourceLocation && property.equals( CP_SEARCH_SUBFOLDERS ) ) {
if ( property.equals( CP_ASSOCIATION ) && value instanceof String ) return (((CDirectorySourceLocation)element).searchSubfolders()) ? new Integer( 0 ) : new Integer( 1 );
{ }
IPath association = new Path( (String)value ); return null;
if ( association.isValidPath( (String)value ) ) }
{
((CDirectorySourceLocation)entry).setAssociation( association ); public void modify( Object element, String property, Object value ) {
setChanged(); Object entry = getSelection();
} if ( entry instanceof CDirectorySourceLocation ) {
} if ( property.equals( CP_ASSOCIATION ) && value instanceof String ) {
if ( property.equals( CP_SEARCH_SUBFOLDERS ) && value instanceof Integer ) IPath association = new Path( (String)value );
{ if ( association.isValidPath( (String)value ) ) {
((CDirectorySourceLocation)entry).setSearchSubfolders( ((Integer)value).intValue() == 0 ); ((CDirectorySourceLocation)entry).setAssociation( association );
setChanged(); setChanged();
}
if ( hasChanged() )
{
refresh();
notifyObservers();
}
}
} }
}; }
if ( property.equals( CP_SEARCH_SUBFOLDERS ) && value instanceof Integer ) {
((CDirectorySourceLocation)entry).setSearchSubfolders( ((Integer)value).intValue() == 0 );
setChanged();
}
if ( hasChanged() ) {
refresh();
notifyObservers();
}
}
}
};
} }
protected Object getSelection() protected Object getSelection() {
{
List list = getSelectedElements(); List list = getSelectedElements();
return ( list.size() > 0 ) ? list.get( 0 ) : null; return (list.size() > 0) ? list.get( 0 ) : null;
} }
public synchronized void addObserver( Observer o ) public synchronized void addObserver( Observer o ) {
{
fObservable.addObserver( o ); fObservable.addObserver( o );
} }
public synchronized void deleteObserver( Observer o ) public synchronized void deleteObserver( Observer o ) {
{
fObservable.deleteObserver( o ); fObservable.deleteObserver( o );
} }
public synchronized boolean hasChanged() public synchronized boolean hasChanged() {
{
return fObservable.hasChanged(); return fObservable.hasChanged();
} }
public void notifyObservers() public void notifyObservers() {
{
fObservable.notifyObservers(); fObservable.notifyObservers();
} }
public void notifyObservers( Object arg ) public void notifyObservers( Object arg ) {
{
fObservable.notifyObservers( arg ); fObservable.notifyObservers( arg );
} }
public void dispose() public void dispose() {
{
} }
protected void setChanged() protected void setChanged() {
{
fObservable.setChanged(); fObservable.setChanged();
} }
public ICSourceLocation[] getSourceLocations() public ICSourceLocation[] getSourceLocations() {
{
List list = getElements(); List list = getElements();
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
} }
} }

View file

@ -1,8 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.ui.sourcelookup; package org.eclipse.cdt.debug.ui.sourcelookup;
import java.util.ArrayList; import java.util.ArrayList;
@ -10,7 +15,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@ -51,33 +55,34 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
/** /**
* * The composite widget shared by the source lookup launch tab and property page.
* Enter type comment.
*
* @since Dec 18, 2002
*/ */
public class SourceLookupBlock implements Observer public class SourceLookupBlock implements Observer {
{
private Composite fControl = null; private Composite fControl = null;
private CheckedListDialogField fGeneratedSourceListField; private CheckedListDialogField fGeneratedSourceListField;
private SourceListDialogField fAddedSourceListField; private SourceListDialogField fAddedSourceListField;
private SelectionButtonDialogField fSearchForDuplicateFiles; private SelectionButtonDialogField fSearchForDuplicateFiles;
private ILaunchConfigurationDialog fLaunchConfigurationDialog = null; private ILaunchConfigurationDialog fLaunchConfigurationDialog = null;
private boolean fIsDirty = false; private boolean fIsDirty = false;
private IProject fProject = null; private IProject fProject = null;
/** /**
* Constructor for SourceLookupBlock. * Constructor for SourceLookupBlock.
*/ */
public SourceLookupBlock() public SourceLookupBlock() {
{
fGeneratedSourceListField = createGeneratedSourceListField(); fGeneratedSourceListField = createGeneratedSourceListField();
fAddedSourceListField = createAddedSourceListField(); fAddedSourceListField = createAddedSourceListField();
fSearchForDuplicateFiles = createSearchForDuplicateFilesButton(); fSearchForDuplicateFiles = createSearchForDuplicateFilesButton();
} }
public void createControl( Composite parent ) public void createControl( Composite parent ) {
{
fControl = new Composite( parent, SWT.NONE ); fControl = new Composite( parent, SWT.NONE );
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.numColumns = 2; layout.numColumns = 2;
@ -86,54 +91,38 @@ public class SourceLookupBlock implements Observer
fControl.setLayout( layout ); fControl.setLayout( layout );
fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) ); fControl.setLayoutData( new GridData( GridData.FILL_BOTH ) );
fControl.setFont( JFaceResources.getDialogFont() ); fControl.setFont( JFaceResources.getDialogFont() );
PixelConverter converter = new PixelConverter( fControl ); PixelConverter converter = new PixelConverter( fControl );
fGeneratedSourceListField.doFillIntoGrid( fControl, 3 ); fGeneratedSourceListField.doFillIntoGrid( fControl, 3 );
LayoutUtil.setHorizontalSpan( fGeneratedSourceListField.getLabelControl( null ), 2 ); LayoutUtil.setHorizontalSpan( fGeneratedSourceListField.getLabelControl( null ), 2 );
LayoutUtil.setWidthHint( fGeneratedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) ); LayoutUtil.setWidthHint( fGeneratedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
LayoutUtil.setHorizontalGrabbing( fGeneratedSourceListField.getListControl( null ) ); LayoutUtil.setHorizontalGrabbing( fGeneratedSourceListField.getListControl( null ) );
((CheckboxTableViewer)fGeneratedSourceListField.getTableViewer()). ((CheckboxTableViewer)fGeneratedSourceListField.getTableViewer()).addCheckStateListener( new ICheckStateListener() {
addCheckStateListener( new ICheckStateListener()
{
public void checkStateChanged( CheckStateChangedEvent event )
{
if ( event.getElement() instanceof IProjectSourceLocation )
doCheckStateChanged();
}
} );
public void checkStateChanged( CheckStateChangedEvent event ) {
if ( event.getElement() instanceof IProjectSourceLocation )
doCheckStateChanged();
}
} );
new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) ); new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
fAddedSourceListField.doFillIntoGrid( fControl, 3 ); fAddedSourceListField.doFillIntoGrid( fControl, 3 );
LayoutUtil.setHorizontalSpan( fAddedSourceListField.getLabelControl( null ), 2 ); LayoutUtil.setHorizontalSpan( fAddedSourceListField.getLabelControl( null ), 2 );
LayoutUtil.setWidthHint( fAddedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) ); LayoutUtil.setWidthHint( fAddedSourceListField.getLabelControl( null ), converter.convertWidthInCharsToPixels( 40 ) );
LayoutUtil.setHorizontalGrabbing( fAddedSourceListField.getListControl( null ) ); LayoutUtil.setHorizontalGrabbing( fAddedSourceListField.getListControl( null ) );
// new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
// new Separator().doFillIntoGrid( fControl, 3, converter.convertHeightInCharsToPixels( 1 ) );
fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 ); fSearchForDuplicateFiles.doFillIntoGrid( fControl, 3 );
} }
public Control getControl() public Control getControl() {
{
return fControl; return fControl;
} }
public void initialize( ILaunchConfiguration configuration ) public void initialize( ILaunchConfiguration configuration ) {
{
IProject project = getProjectFromLaunchConfiguration( configuration ); IProject project = getProjectFromLaunchConfiguration( configuration );
if ( project != null ) if ( project != null ) {
{
setProject( project ); setProject( project );
try try {
{
String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" ); //$NON-NLS-1$ String id = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "" ); //$NON-NLS-1$
if ( isEmpty( id ) || if ( isEmpty( id ) || CDebugUIPlugin.getDefaultSourceLocatorID().equals( id ) || CDebugUIPlugin.getDefaultSourceLocatorOldID().equals( id ) ) {
CDebugUIPlugin.getDefaultSourceLocatorID().equals( id ) ||
CDebugUIPlugin.getDefaultSourceLocatorOldID().equals( id ) )
{
String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$ String memento = configuration.getAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, "" ); //$NON-NLS-1$
if ( !isEmpty( memento ) ) if ( !isEmpty( memento ) )
initializeFromMemento( memento ); initializeFromMemento( memento );
@ -141,44 +130,37 @@ public class SourceLookupBlock implements Observer
initializeDefaults(); initializeDefaults();
} }
} }
catch( CoreException e ) catch( CoreException e ) {
{
initializeDefaults(); initializeDefaults();
} }
} }
else else {
{
initializeGeneratedLocations( null, new ICSourceLocation[0] ); initializeGeneratedLocations( null, new ICSourceLocation[0] );
resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() ); resetAdditionalLocations( CDebugCorePlugin.getDefault().getCommonSourceLocations() );
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
} }
} }
private void initializeFromMemento( String memento ) throws CoreException private void initializeFromMemento( String memento ) throws CoreException {
{
IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator(); IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator();
locator.initializeFromMemento( memento ); locator.initializeFromMemento( memento );
if ( locator instanceof IAdaptable ) if ( locator instanceof IAdaptable ) {
{
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ); ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
if ( clocator != null ) if ( clocator != null )
initializeFromLocator( clocator ); initializeFromLocator( clocator );
} }
} }
private void initializeDefaults() private void initializeDefaults() {
{
fGeneratedSourceListField.removeAllElements(); fGeneratedSourceListField.removeAllElements();
IProject project = getProject(); IProject project = getProject();
if ( project != null && project.exists() && project.isOpen() ) if ( project != null && project.exists() && project.isOpen() ) {
{
ICSourceLocation location = SourceLookupFactory.createProjectSourceLocation( project, true ); ICSourceLocation location = SourceLookupFactory.createProjectSourceLocation( project, true );
fGeneratedSourceListField.addElement( location ); fGeneratedSourceListField.addElement( location );
fGeneratedSourceListField.setChecked( location, true ); fGeneratedSourceListField.setChecked( location, true );
List list = CDebugUtils.getReferencedProjects( project ); List list = CDebugUtils.getReferencedProjects( project );
Iterator it = list.iterator(); Iterator it = list.iterator();
while( it.hasNext() ) while( it.hasNext() ) {
{
location = SourceLookupFactory.createProjectSourceLocation( (IProject)it.next(), true ); location = SourceLookupFactory.createProjectSourceLocation( (IProject)it.next(), true );
fGeneratedSourceListField.addElement( location ); fGeneratedSourceListField.addElement( location );
fGeneratedSourceListField.setChecked( location, true ); fGeneratedSourceListField.setChecked( location, true );
@ -188,32 +170,28 @@ public class SourceLookupBlock implements Observer
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
} }
private void initializeFromLocator( ICSourceLocator locator ) private void initializeFromLocator( ICSourceLocator locator ) {
{
ICSourceLocation[] locations = locator.getSourceLocations(); ICSourceLocation[] locations = locator.getSourceLocations();
initializeGeneratedLocations( locator.getProject(), locations ); initializeGeneratedLocations( locator.getProject(), locations );
resetAdditionalLocations( locations ); resetAdditionalLocations( locations );
fSearchForDuplicateFiles.setSelection( locator.searchForDuplicateFiles() ); fSearchForDuplicateFiles.setSelection( locator.searchForDuplicateFiles() );
} }
private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations ) private void initializeGeneratedLocations( IProject project, ICSourceLocation[] locations ) {
{
fGeneratedSourceListField.removeAllElements(); fGeneratedSourceListField.removeAllElements();
if ( project == null || !project.exists() || !project.isOpen() ) if ( project == null || !project.exists() || !project.isOpen() )
return; return;
List list = CDebugUtils.getReferencedProjects( project ); List list = CDebugUtils.getReferencedProjects( project );
IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] ); IProject[] refs = (IProject[])list.toArray( new IProject[list.size()] );
ICSourceLocation loc = getLocationForProject( project, locations ); ICSourceLocation loc = getLocationForProject( project, locations );
boolean checked = ( loc != null && ((IProjectSourceLocation)loc).isGeneric() ); boolean checked = (loc != null && ((IProjectSourceLocation)loc).isGeneric());
if ( loc == null ) if ( loc == null )
loc = SourceLookupFactory.createProjectSourceLocation( project, true ); loc = SourceLookupFactory.createProjectSourceLocation( project, true );
fGeneratedSourceListField.addElement( loc ); fGeneratedSourceListField.addElement( loc );
fGeneratedSourceListField.setChecked( loc, checked ); fGeneratedSourceListField.setChecked( loc, checked );
for( int i = 0; i < refs.length; ++i ) {
for ( int i = 0; i < refs.length; ++i )
{
loc = getLocationForProject( refs[i], locations ); loc = getLocationForProject( refs[i], locations );
checked = ( loc != null ); checked = (loc != null);
if ( loc == null ) if ( loc == null )
loc = SourceLookupFactory.createProjectSourceLocation( refs[i], true ); loc = SourceLookupFactory.createProjectSourceLocation( refs[i], true );
fGeneratedSourceListField.addElement( loc ); fGeneratedSourceListField.addElement( loc );
@ -221,96 +199,78 @@ public class SourceLookupBlock implements Observer
} }
} }
private void resetGeneratedLocations( ICSourceLocation[] locations ) private void resetGeneratedLocations( ICSourceLocation[] locations ) {
{
fGeneratedSourceListField.checkAll( false ); fGeneratedSourceListField.checkAll( false );
for ( int i = 0; i < locations.length; ++i ) for( int i = 0; i < locations.length; ++i ) {
{ if ( locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric() )
if ( locations[i] instanceof IProjectSourceLocation &&
((IProjectSourceLocation)locations[i]).isGeneric() )
fGeneratedSourceListField.setChecked( locations[i], true ); fGeneratedSourceListField.setChecked( locations[i], true );
} }
} }
private void resetAdditionalLocations( ICSourceLocation[] locations ) private void resetAdditionalLocations( ICSourceLocation[] locations ) {
{
fAddedSourceListField.removeAllElements(); fAddedSourceListField.removeAllElements();
for ( int i = 0; i < locations.length; ++i ) for( int i = 0; i < locations.length; ++i ) {
{ if ( !(locations[i] instanceof IProjectSourceLocation) || !((IProjectSourceLocation)locations[i]).isGeneric() )
if ( !( locations[i] instanceof IProjectSourceLocation ) || !((IProjectSourceLocation)locations[i]).isGeneric() )
fAddedSourceListField.addElement( locations[i] ); fAddedSourceListField.addElement( locations[i] );
} }
} }
public void performApply( ILaunchConfigurationWorkingCopy configuration ) public void performApply( ILaunchConfigurationWorkingCopy configuration ) {
{
IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator(); IPersistableSourceLocator locator = CDebugUIPlugin.createDefaultSourceLocator();
try try {
{
locator.initializeDefaults( configuration ); locator.initializeDefaults( configuration );
if ( locator instanceof IAdaptable ) if ( locator instanceof IAdaptable ) {
{
ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class ); ICSourceLocator clocator = (ICSourceLocator)((IAdaptable)locator).getAdapter( ICSourceLocator.class );
if ( clocator != null && getProject() != null && getProject().equals( getProjectFromLaunchConfiguration( configuration ) ) ) if ( clocator != null && getProject() != null && getProject().equals( getProjectFromLaunchConfiguration( configuration ) ) ) {
{
clocator.setSourceLocations( getSourceLocations() ); clocator.setSourceLocations( getSourceLocations() );
clocator.setSearchForDuplicateFiles( searchForDuplicateFiles() ); clocator.setSearchForDuplicateFiles( searchForDuplicateFiles() );
} }
} }
configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); configuration.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
} }
catch( CoreException e ) catch( CoreException e ) {
{
} }
} }
protected void doCheckStateChanged() protected void doCheckStateChanged() {
{
fIsDirty = true; fIsDirty = true;
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
protected void doGeneratedSourceButtonPressed( int index ) protected void doGeneratedSourceButtonPressed( int index ) {
{ switch( index ) {
switch( index ) case 0: // Select All
{ case 1: // Deselect All
case 0: // Select All
case 1: // Deselect All
fIsDirty = true; fIsDirty = true;
break; break;
} }
if ( isDirty() ) if ( isDirty() )
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
protected void doGeneratedSourceSelectionChanged() protected void doGeneratedSourceSelectionChanged() {
{
} }
protected void doAddedSourceButtonPressed( int index ) protected void doAddedSourceButtonPressed( int index ) {
{ switch( index ) {
switch( index ) case 0: // Add...
{
case 0: // Add...
if ( addSourceLocation() ) if ( addSourceLocation() )
fIsDirty = true; fIsDirty = true;
break; break;
case 2: // Up case 2: // Up
case 3: // Down case 3: // Down
case 5: // Remove case 5: // Remove
fIsDirty = true; fIsDirty = true;
break; break;
} }
if ( isDirty() ) if ( isDirty() )
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
public ICSourceLocation[] getSourceLocations() public ICSourceLocation[] getSourceLocations() {
{
ArrayList list = new ArrayList( getGeneratedSourceListField().getElements().size() + getAddedSourceListField().getElements().size() ); ArrayList list = new ArrayList( getGeneratedSourceListField().getElements().size() + getAddedSourceListField().getElements().size() );
Iterator it = getGeneratedSourceListField().getElements().iterator(); Iterator it = getGeneratedSourceListField().getElements().iterator();
while( it.hasNext() ) while( it.hasNext() ) {
{
IProjectSourceLocation location = (IProjectSourceLocation)it.next(); IProjectSourceLocation location = (IProjectSourceLocation)it.next();
if ( getGeneratedSourceListField().isChecked( location ) ) if ( getGeneratedSourceListField().isChecked( location ) )
list.add( location ); list.add( location );
@ -318,52 +278,43 @@ public class SourceLookupBlock implements Observer
list.addAll( getAddedSourceListField().getElements() ); list.addAll( getAddedSourceListField().getElements() );
return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] ); return (ICSourceLocation[])list.toArray( new ICSourceLocation[list.size()] );
} }
private boolean addSourceLocation() private boolean addSourceLocation() {
{
AddSourceLocationWizard wizard = new AddSourceLocationWizard( getSourceLocations() ); AddSourceLocationWizard wizard = new AddSourceLocationWizard( getSourceLocations() );
WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard ); WizardDialog dialog = new WizardDialog( fControl.getShell(), wizard );
if ( dialog.open() == Window.OK ) if ( dialog.open() == Window.OK ) {
{
fAddedSourceListField.addElement( wizard.getSourceLocation() ); fAddedSourceListField.addElement( wizard.getSourceLocation() );
return true; return true;
} }
return false; return false;
} }
protected void updateLaunchConfigurationDialog() protected void updateLaunchConfigurationDialog() {
{ if ( getLaunchConfigurationDialog() != null ) {
if ( getLaunchConfigurationDialog() != null )
{
getLaunchConfigurationDialog().updateMessage(); getLaunchConfigurationDialog().updateMessage();
getLaunchConfigurationDialog().updateButtons(); getLaunchConfigurationDialog().updateButtons();
fIsDirty = false; fIsDirty = false;
} }
} }
public ILaunchConfigurationDialog getLaunchConfigurationDialog() public ILaunchConfigurationDialog getLaunchConfigurationDialog() {
{
return fLaunchConfigurationDialog; return fLaunchConfigurationDialog;
} }
public void setLaunchConfigurationDialog( ILaunchConfigurationDialog launchConfigurationDialog ) public void setLaunchConfigurationDialog( ILaunchConfigurationDialog launchConfigurationDialog ) {
{
fLaunchConfigurationDialog = launchConfigurationDialog; fLaunchConfigurationDialog = launchConfigurationDialog;
} }
public boolean isDirty() public boolean isDirty() {
{
return fIsDirty; return fIsDirty;
} }
protected Object getSelection() protected Object getSelection() {
{
List list = fAddedSourceListField.getSelectedElements(); List list = fAddedSourceListField.getSelectedElements();
return ( list.size() > 0 ) ? list.get( 0 ) : null; return (list.size() > 0) ? list.get( 0 ) : null;
} }
protected void restoreDefaults() protected void restoreDefaults() {
{
ICSourceLocation[] locations = new ICSourceLocation[0]; ICSourceLocation[] locations = new ICSourceLocation[0];
if ( getProject() != null ) if ( getProject() != null )
locations = CSourceLocator.getDefaultSourceLocations( getProject() ); locations = CSourceLocator.getDefaultSourceLocations( getProject() );
@ -372,117 +323,95 @@ public class SourceLookupBlock implements Observer
fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) ); fSearchForDuplicateFiles.setSelection( CDebugCorePlugin.getDefault().getPluginPreferences().getBoolean( ICDebugConstants.PREF_SEARCH_DUPLICATE_FILES ) );
} }
public IProject getProject() public IProject getProject() {
{
return fProject; return fProject;
} }
private void setProject( IProject project ) private void setProject( IProject project ) {
{
fProject = project; fProject = project;
} }
public SourceListDialogField getAddedSourceListField() public SourceListDialogField getAddedSourceListField() {
{
return fAddedSourceListField; return fAddedSourceListField;
} }
public CheckedListDialogField getGeneratedSourceListField() public CheckedListDialogField getGeneratedSourceListField() {
{
return fGeneratedSourceListField; return fGeneratedSourceListField;
} }
private ICSourceLocation getLocationForProject( IProject project, ICSourceLocation[] locations ) private ICSourceLocation getLocationForProject( IProject project, ICSourceLocation[] locations ) {
{ for( int i = 0; i < locations.length; ++i )
for ( int i = 0; i < locations.length; ++i ) if ( locations[i] instanceof IProjectSourceLocation && project.equals( ((IProjectSourceLocation)locations[i]).getProject() ) )
if ( locations[i] instanceof IProjectSourceLocation &&
project.equals( ((IProjectSourceLocation)locations[i]).getProject() ) )
return locations[i]; return locations[i];
return null; return null;
} }
public boolean searchForDuplicateFiles() public boolean searchForDuplicateFiles() {
{ return (fSearchForDuplicateFiles != null) ? fSearchForDuplicateFiles.isSelected() : false;
return ( fSearchForDuplicateFiles != null ) ? fSearchForDuplicateFiles.isSelected() : false;
} }
private CheckedListDialogField createGeneratedSourceListField() private CheckedListDialogField createGeneratedSourceListField() {
{ String[] generatedSourceButtonLabels = new String[]{
String[] generatedSourceButtonLabels = new String[] /* 0 */SourceLookupMessages.getString( "SourceLookupBlock.0" ), //$NON-NLS-1$
{ /* 1 */SourceLookupMessages.getString( "SourceLookupBlock.1" ), //$NON-NLS-1$
/* 0 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Select_All"), //$NON-NLS-1$
/* 1 */ CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Deselect_All"), //$NON-NLS-1$
}; };
IListAdapter generatedSourceAdapter = new IListAdapter() {
IListAdapter generatedSourceAdapter = new IListAdapter() public void customButtonPressed( DialogField field, int index ) {
{ doGeneratedSourceButtonPressed( index );
public void customButtonPressed( DialogField field, int index ) }
{
doGeneratedSourceButtonPressed( index );
}
public void selectionChanged( DialogField field )
{
doGeneratedSourceSelectionChanged();
}
};
public void selectionChanged( DialogField field ) {
doGeneratedSourceSelectionChanged();
}
};
CheckedListDialogField field = new CheckedListDialogField( generatedSourceAdapter, generatedSourceButtonLabels, new SourceLookupLabelProvider() ); CheckedListDialogField field = new CheckedListDialogField( generatedSourceAdapter, generatedSourceButtonLabels, new SourceLookupLabelProvider() );
field.setLabelText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Generic_Source_Locations") ); //$NON-NLS-1$ field.setLabelText( SourceLookupMessages.getString( "SourceLookupBlock.2" ) ); //$NON-NLS-1$
field.setCheckAllButtonIndex( 0 ); field.setCheckAllButtonIndex( 0 );
field.setUncheckAllButtonIndex( 1 ); field.setUncheckAllButtonIndex( 1 );
field.setDialogFieldListener( field.setDialogFieldListener( new IDialogFieldListener() {
new IDialogFieldListener()
{ public void dialogFieldChanged( DialogField f ) {
public void dialogFieldChanged( DialogField f ) doCheckStateChanged();
{ }
doCheckStateChanged(); } );
}
} );
return field; return field;
} }
private SourceListDialogField createAddedSourceListField() private SourceListDialogField createAddedSourceListField() {
{ SourceListDialogField field = new SourceListDialogField( SourceLookupMessages.getString( "SourceLookupBlock.3" ), //$NON-NLS-1$
SourceListDialogField field = new IListAdapter() {
new SourceListDialogField( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Additional_Source_Locations"), //$NON-NLS-1$
new IListAdapter()
{
public void customButtonPressed( DialogField f, int index )
{
doAddedSourceButtonPressed( index );
}
public void selectionChanged(DialogField f) public void customButtonPressed( DialogField f, int index ) {
{ doAddedSourceButtonPressed( index );
} }
} );
public void selectionChanged( DialogField f ) {
}
} );
field.addObserver( this ); field.addObserver( this );
return field; return field;
} }
private SelectionButtonDialogField createSearchForDuplicateFilesButton() private SelectionButtonDialogField createSearchForDuplicateFilesButton() {
{
SelectionButtonDialogField button = new SelectionButtonDialogField( SWT.CHECK ); SelectionButtonDialogField button = new SelectionButtonDialogField( SWT.CHECK );
button.setLabelText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourceLookupBlock.Search_for_dup_src_files") ); //$NON-NLS-1$ button.setLabelText( SourceLookupMessages.getString( "SourceLookupBlock.4" ) ); //$NON-NLS-1$
button.setDialogFieldListener( button.setDialogFieldListener( new IDialogFieldListener() {
new IDialogFieldListener()
{ public void dialogFieldChanged( DialogField field ) {
public void dialogFieldChanged( DialogField field ) doCheckStateChanged();
{ }
doCheckStateChanged(); } );
}
} );
return button; return button;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see java.util.Observer#update(java.util.Observable, java.lang.Object) * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
*/ */
public void update( Observable o, Object arg ) public void update( Observable o, Object arg ) {
{ if ( arg instanceof Integer && ((Integer)arg).intValue() == 0 ) {
if ( arg instanceof Integer && ((Integer)arg).intValue() == 0 )
{
if ( addSourceLocation() ) if ( addSourceLocation() )
fIsDirty = true; fIsDirty = true;
} }
@ -492,34 +421,27 @@ public class SourceLookupBlock implements Observer
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
private boolean isEmpty( String string ) private boolean isEmpty( String string ) {
{
return string == null || string.length() == 0; return string == null || string.length() == 0;
} }
public void dispose() public void dispose() {
{ if ( getAddedSourceListField() != null ) {
if ( getAddedSourceListField() != null )
{
getAddedSourceListField().deleteObserver( this ); getAddedSourceListField().deleteObserver( this );
getAddedSourceListField().dispose(); getAddedSourceListField().dispose();
} }
} }
private IProject getProjectFromLaunchConfiguration( ILaunchConfiguration configuration ) private IProject getProjectFromLaunchConfiguration( ILaunchConfiguration configuration ) {
{ try {
try
{
String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" ); //$NON-NLS-1$ String projectName = configuration.getAttribute( ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "" ); //$NON-NLS-1$
if ( !isEmpty( projectName ) ) if ( !isEmpty( projectName ) ) {
{
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName ); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName );
if ( project != null && project.exists() && project.isOpen() ) if ( project != null && project.exists() && project.isOpen() )
return project; return project;
} }
} }
catch( CoreException e ) catch( CoreException e ) {
{
} }
return null; return null;
} }

View file

@ -0,0 +1,35 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.ui.sourcelookup;
import java.util.MissingResourceException;
//import java.util.ResourceBundle;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public class SourceLookupMessages {
// private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.ui.sourcelookup.SourceLookupMessages";//$NON-NLS-1$
// private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
private SourceLookupMessages() {
}
public static String getString( String key ) {
try {
return CDebugUIPlugin.getResourceString( key );
// return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,25 @@
SourceListDialogField.0=yes
SourceListDialogField.1=no
SourceListDialogField.2=Add...
SourceListDialogField.3=Up
SourceListDialogField.4=Down
SourceListDialogField.5=Remove
SourceListDialogField.6=Location
SourceListDialogField.7=Association
SourceListDialogField.8=Search subfolders
SourcePropertyPage.0=Terminated.
SourceLookupBlock.0=Select All
SourceLookupBlock.1=Deselect All
SourceLookupBlock.2=Generic Source Locations
SourceLookupBlock.3=Additional Source Locations
SourceLookupBlock.4=Search for duplicate source files
DefaultSourceLocator.0=Always map to the selection
DefaultSourceLocator.1=Unable to create memento for C/C++ source locator.
DefaultSourceLocator.2=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.3=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.4=Unable to restore prompting source locator - project {0} not found.
DefaultSourceLocator.5=Unable to restore prompting source locator - invalid format.
DefaultSourceLocator.6=Exception occurred initializing source locator.
DefaultSourceLocator.7=Selection needed
DefaultSourceLocator.8=Debugger has found multiple files with the same name.\nPlease select one associated with the selected stack frame.
DefaultSourceLocator.9=Project ''{0}'' does not exist.

View file

@ -1,8 +1,13 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.ui.sourcelookup; package org.eclipse.cdt.debug.ui.sourcelookup;
import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.core.model.ICDebugTarget;
@ -22,20 +27,16 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.dialogs.PropertyPage; import org.eclipse.ui.dialogs.PropertyPage;
/** /**
* * The "Source Lookup" property page.
* Enter type comment.
*
* @since Dec 18, 2002
*/ */
public class SourcePropertyPage extends PropertyPage public class SourcePropertyPage extends PropertyPage {
{
private SourceLookupBlock fBlock = null; private SourceLookupBlock fBlock = null;
/** /**
* Constructor for SourcePropertyPage. * Constructor for SourcePropertyPage.
*/ */
public SourcePropertyPage() public SourcePropertyPage() {
{
noDefaultAndApplyButton(); noDefaultAndApplyButton();
fBlock = new SourceLookupBlock(); fBlock = new SourceLookupBlock();
} }
@ -43,74 +44,61 @@ public class SourcePropertyPage extends PropertyPage
/** /**
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite) * @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
*/ */
protected Control createContents( Composite parent ) protected Control createContents( Composite parent ) {
{
ICDebugTarget target = getDebugTarget(); ICDebugTarget target = getDebugTarget();
if ( target == null || target.isTerminated() || target.isDisconnected() ) if ( target == null || target.isTerminated() || target.isDisconnected() ) {
{
return createTerminatedContents( parent ); return createTerminatedContents( parent );
} }
return createActiveContents( parent ); return createActiveContents( parent );
} }
protected Control createTerminatedContents( Composite parent ) protected Control createTerminatedContents( Composite parent ) {
{ Label label = new Label( parent, SWT.LEFT );
Label label= new Label( parent, SWT.LEFT ); label.setText( SourceLookupMessages.getString( "SourcePropertyPage.0" ) ); //$NON-NLS-1$
label.setText( CDebugUIPlugin.getResourceString("ui.sourcelookup.SourcePropertyPage.Terminated") ); //$NON-NLS-1$
return label; return label;
} }
protected Control createActiveContents( Composite parent ) protected Control createActiveContents( Composite parent ) {
{
fBlock.initialize( getLaunchConfiguration() ); fBlock.initialize( getLaunchConfiguration() );
fBlock.createControl( parent ); fBlock.createControl( parent );
return fBlock.getControl(); return fBlock.getControl();
} }
protected ICDebugTarget getDebugTarget() protected ICDebugTarget getDebugTarget() {
{
IAdaptable element = getElement(); IAdaptable element = getElement();
if ( element != null ) if ( element != null ) {
{
return (ICDebugTarget)element.getAdapter( ICDebugTarget.class ); return (ICDebugTarget)element.getAdapter( ICDebugTarget.class );
} }
return null; return null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferencePage#performOk() * @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/ */
public boolean performOk() public boolean performOk() {
{ if ( fBlock.isDirty() ) {
if ( fBlock.isDirty() ) try {
{
try
{
setAttributes( fBlock ); setAttributes( fBlock );
} }
catch( DebugException e ) catch( DebugException e ) {
{
CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null );
return false; return false;
} }
} }
return true; return true;
} }
private void setAttributes( SourceLookupBlock block ) throws DebugException private void setAttributes( SourceLookupBlock block ) throws DebugException {
{
ICDebugTarget target = getDebugTarget(); ICDebugTarget target = getDebugTarget();
if ( target != null ) if ( target != null ) {
{ if ( target.getLaunch().getSourceLocator() instanceof IAdaptable ) {
if ( target.getLaunch().getSourceLocator() instanceof IAdaptable )
{
ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class ); ICSourceLocator locator = (ICSourceLocator)((IAdaptable)target.getLaunch().getSourceLocator()).getAdapter( ICSourceLocator.class );
if ( locator != null ) if ( locator != null ) {
{
locator.setSourceLocations( block.getSourceLocations() ); locator.setSourceLocations( block.getSourceLocations() );
locator.setSearchForDuplicateFiles( block.searchForDuplicateFiles() ); locator.setSearchForDuplicateFiles( block.searchForDuplicateFiles() );
if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator ) if ( target.getLaunch().getSourceLocator() instanceof IPersistableSourceLocator ) {
{
ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration(); ILaunchConfiguration configuration = target.getLaunch().getLaunchConfiguration();
saveChanges( configuration, (IPersistableSourceLocator)target.getLaunch().getSourceLocator() ); saveChanges( configuration, (IPersistableSourceLocator)target.getLaunch().getSourceLocator() );
} }
@ -119,34 +107,30 @@ public class SourcePropertyPage extends PropertyPage
} }
} }
protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) protected void saveChanges( ILaunchConfiguration configuration, IPersistableSourceLocator locator ) {
{ try {
try
{
ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() ); ILaunchConfigurationWorkingCopy copy = configuration.copy( configuration.getName() );
copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() ); copy.setAttribute( ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, locator.getMemento() );
copy.doSave(); copy.doSave();
} }
catch( CoreException e ) catch( CoreException e ) {
{
CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null ); CDebugUIPlugin.errorDialog( e.getMessage(), (IStatus)null );
} }
} }
private ILaunchConfiguration getLaunchConfiguration() private ILaunchConfiguration getLaunchConfiguration() {
{
ICDebugTarget target = getDebugTarget(); ICDebugTarget target = getDebugTarget();
return ( target != null ) ? target.getLaunch().getLaunchConfiguration() : null; return (target != null) ? target.getLaunch().getLaunchConfiguration() : null;
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.IDialogPage#dispose() * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
*/ */
public void dispose() public void dispose() {
{
if ( fBlock != null ) if ( fBlock != null )
fBlock.dispose(); fBlock.dispose();
super.dispose(); super.dispose();
} }
}
}