1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Strings externalization fixes and reformatting.

This commit is contained in:
Mikhail Khodjaiants 2004-04-07 18:17:01 +00:00
parent d546766bee
commit d738d66c3c
11 changed files with 188 additions and 177 deletions

View file

@ -1,3 +1,16 @@
2004-04-07 Mikhail Khodjaiants
Strings externalization fixes and reformatting.
* CDebugUIMessages.properties
* CDebugModelPresentation.java
* CDTDebugModelPresentation.java
* ColorManager.java
* InfoStatusHandler.java
* OverlayImageCache.java
* OverlayImageDescriptor.java
* PixelConverter.java
* QuestionStatusHandler.java
* SWTUtil.java
2004-04-07 Mikhail Khodjaiants 2004-04-07 Mikhail Khodjaiants
Removed the "Show Debugger Console" action. Removed the "Show Debugger Console" action.
* DebuggerConsoleActionDelegate.java * DebuggerConsoleActionDelegate.java

View file

@ -444,7 +444,7 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( info != null && info instanceof ICDISignalExitInfo) if ( info != null && info instanceof ICDISignalExitInfo)
{ {
ICDISignalExitInfo sigInfo = (ICDISignalExitInfo)info; ICDISignalExitInfo sigInfo = (ICDISignalExitInfo)info;
label += CDebugUIPlugin.getFormattedString("CDTDebugModelPresentation.Signal_received_Description", //$NON-NLS-1$//$NON-NLS-2$ label += CDebugUIPlugin.getFormattedString("internal.ui.CDTDebugModelPresentation.Signal_received_Description", //$NON-NLS-1$//$NON-NLS-2$
new String[] { sigInfo.getName(), sigInfo.getDescription() } ); new String[] { sigInfo.getName(), sigInfo.getDescription() } );
} }
else if ( info != null && info instanceof ICDIExitInfo ) else if ( info != null && info instanceof ICDIExitInfo )
@ -493,14 +493,14 @@ public class CDTDebugModelPresentation extends LabelProvider
ICDISignal signal = ((ICDISignalReceived)info).getSignal(); ICDISignal signal = ((ICDISignalReceived)info).getSignal();
String label = threadName + String label = threadName +
CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Suspended") + //$NON-NLS-1$ CDebugUIPlugin.getResourceString("internal.ui.CDTDebugModelPresentation.Suspended") + //$NON-NLS-1$
CDebugUIPlugin.getFormattedString("CDTDebugModelPresentation.Signal_received_Description", //$NON-NLS-1$ CDebugUIPlugin.getFormattedString("internal.ui.CDTDebugModelPresentation.Signal_received_Description", //$NON-NLS-1$
new String[] { signal.getName(), signal.getDescription() } ); new String[] { signal.getName(), signal.getDescription() } );
return label; return label;
} }
if ( info != null && info instanceof ICDIWatchpointTrigger ) if ( info != null && info instanceof ICDIWatchpointTrigger )
{ {
String label = threadName + String label = threadName +
CDebugUIPlugin.getFormattedString("CDTDebugModelPresentation.Suspended_Watchpoint_triggered_Old_New", //$NON-NLS-1$ CDebugUIPlugin.getFormattedString("internal.ui.CDTDebugModelPresentation.Suspended_Watchpoint_triggered_Old_New", //$NON-NLS-1$
new String[] { ((ICDIWatchpointTrigger)info).getOldValue(), new String[] { ((ICDIWatchpointTrigger)info).getOldValue(),
((ICDIWatchpointTrigger)info).getNewValue() } ); ((ICDIWatchpointTrigger)info).getNewValue() } );
return label; return label;

View file

@ -151,13 +151,13 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
label += ( qualified ? path.toOSString() : path.lastSegment() ); label += ( qualified ? path.toOSString() : path.lastSegment() );
} }
else { else {
label += "unknown"; label += CDebugUIMessages.getString( "CDebugModelPresentation.unknown_1" ); //$NON-NLS-1$
} }
return label; return label;
} }
protected String getRegisterGroupText( IRegisterGroup group ) { protected String getRegisterGroupText( IRegisterGroup group ) {
String name = "<not available>"; String name = CDebugUIMessages.getString( "CDebugModelPresentation.not_available_1" ); //$NON-NLS-1$
try { try {
name = group.getName(); name = group.getName();
} }

View file

@ -1 +1,3 @@
CDebugUIPlugin.Error_1=Error CDebugUIPlugin.Error_1=Error
CDebugModelPresentation.unknown_1=unknown
CDebugModelPresentation.not_available_1=<not available>

View file

@ -19,40 +19,38 @@ import org.eclipse.swt.widgets.Display;
* *
* @since Jul 23, 2002 * @since Jul 23, 2002
*/ */
public class ColorManager public class ColorManager {
{
private static ColorManager fgColorManager;
private ColorManager() private static ColorManager gfColorManager;
{
private ColorManager() {
} }
public static ColorManager getDefault() public static ColorManager getDefault() {
{ if ( gfColorManager == null ) {
if ( fgColorManager == null ) gfColorManager = new ColorManager();
{
fgColorManager = new ColorManager();
} }
return fgColorManager; return gfColorManager;
} }
protected Map fColorTable = new HashMap( 10 ); protected Map fColorTable = new HashMap( 10 );
public Color getColor( RGB rgb ) public Color getColor( RGB rgb ) {
{ Color color = (Color)getColorTable().get(rgb);
Color color = (Color)fColorTable.get( rgb ); if ( color == null ) {
if ( color == null )
{
color = new Color( Display.getCurrent(), rgb ); color = new Color( Display.getCurrent(), rgb );
fColorTable.put( rgb, color ); getColorTable().put( rgb, color );
} }
return color; return color;
} }
public void dispose() public void dispose() {
{ Iterator e = getColorTable().values().iterator();
Iterator e = fColorTable.values().iterator();
while( e.hasNext() ) while( e.hasNext() )
((Color)e.next()).dispose(); ((Color)e.next()).dispose();
} }
private Map getColorTable() {
return this.fColorTable;
}
} }

View file

@ -18,23 +18,21 @@ import org.eclipse.jface.dialogs.MessageDialog;
* *
* @since Sep 25, 2002 * @since Sep 25, 2002
*/ */
public class InfoStatusHandler implements IStatusHandler public class InfoStatusHandler implements IStatusHandler {
{
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object) * @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object)
*/ */
public Object handleStatus( IStatus status, Object source ) throws CoreException public Object handleStatus( IStatus status, Object source )
{ throws CoreException {
if ( status != null && source != null && source instanceof IDebugTarget ) if ( status != null && source != null && source instanceof IDebugTarget ) {
{
final String title = ((IDebugTarget)source).getName(); final String title = ((IDebugTarget)source).getName();
final String message = status.getMessage(); final String message = status.getMessage();
CDebugUIPlugin.getStandardDisplay().asyncExec( CDebugUIPlugin.getStandardDisplay().asyncExec(
new Runnable() new Runnable() {
{ public void run() {
public void run()
{
MessageDialog.openInformation( CDebugUIPlugin.getActiveWorkbenchShell(), title, message ); MessageDialog.openInformation( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
} }
} ); } );

View file

@ -1,6 +1,5 @@
/* /*
*(c) Copyright QNX Software Systems Ltd. 2002. * (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
* *
*/ */
@ -17,23 +16,23 @@ import org.eclipse.swt.graphics.Image;
* *
* @since May 30, 2003 * @since May 30, 2003
*/ */
public class OverlayImageCache public class OverlayImageCache {
{
private Map cache = new HashMap(); private Map fCache = new HashMap();
/** /**
* Returns and caches an image corresponding to the specified image descriptor. * Returns and caches an image corresponding to the specified image
* descriptor.
* *
* @param imageDecsriptor the image descriptor * @param imageDecsriptor
* the image descriptor
* @return the image * @return the image
*/ */
public Image getImageFor( OverlayImageDescriptor imageDescriptor ) public Image getImageFor( OverlayImageDescriptor imageDescriptor ) {
{ Image image = (Image)getCache().get( imageDescriptor );
Image image = (Image)cache.get( imageDescriptor ); if ( image == null ) {
if ( image == null )
{
image = imageDescriptor.createImage(); image = imageDescriptor.createImage();
cache.put( imageDescriptor, image ); getCache().put( imageDescriptor, image );
} }
return image; return image;
} }
@ -41,13 +40,15 @@ public class OverlayImageCache
/** /**
* Disposes of all images in the cache. * Disposes of all images in the cache.
*/ */
public void disposeAll() public void disposeAll() {
{ for ( Iterator it = getCache().values().iterator(); it.hasNext(); ) {
for ( Iterator it = cache.values().iterator(); it.hasNext(); )
{
Image image = (Image)it.next(); Image image = (Image)it.next();
image.dispose(); image.dispose();
} }
cache.clear(); getCache().clear();
}
private Map getCache() {
return this.fCache;
} }
} }

View file

@ -1,6 +1,5 @@
/* /*
*(c) Copyright QNX Software Systems Ltd. 2002. * (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
* *
*/ */
@ -14,8 +13,8 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
public class OverlayImageDescriptor extends CompositeImageDescriptor public class OverlayImageDescriptor extends CompositeImageDescriptor {
{
static final int DEFAULT_WIDTH = 16; static final int DEFAULT_WIDTH = 16;
static final int DEFAULT_HEIGHT = 16; static final int DEFAULT_HEIGHT = 16;
@ -33,29 +32,23 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
// the size // the size
private Point fSize; private Point fSize;
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays ) public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays ) {
{ this( base, overlays, new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT ) );
fBase = base;
fOverlays = overlays;
fSize = new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT );
} }
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size ) public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size ) {
{ setBase( base );
fBase = base; setOverlays( overlays );
fOverlays = overlays; setSize( size );
fSize = size;
} }
/** /**
* Draw the fOverlays for the reciever. * Draw the fOverlays for the reciever.
*/ */
protected void drawOverlays( ImageDescriptor[] overlays ) protected void drawOverlays(ImageDescriptor[] overlays) {
{
Point size = getSize(); Point size = getSize();
for ( int i = 0; i < overlays.length; i++ ) for ( int i = 0; i < overlays.length; i++ ) {
{
ImageDescriptor overlay = overlays[i]; ImageDescriptor overlay = overlays[i];
if ( overlay == null ) if ( overlay == null )
continue; continue;
@ -63,8 +56,7 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
//Use the missing descriptor if it is not there. //Use the missing descriptor if it is not there.
if ( overlayData == null ) if ( overlayData == null )
overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData(); overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
switch( i ) switch( i ) {
{
case TOP_LEFT: case TOP_LEFT:
drawImage( overlayData, 0, 0 ); drawImage( overlayData, 0, 0 );
break; break;
@ -81,40 +73,59 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
} }
} }
public boolean equals( Object o ) public boolean equals( Object o ) {
{
if ( !(o instanceof OverlayImageDescriptor) ) if ( !(o instanceof OverlayImageDescriptor) )
return false; return false;
OverlayImageDescriptor other = (OverlayImageDescriptor)o; OverlayImageDescriptor other = (OverlayImageDescriptor)o;
return fBase.equals( other.fBase ) && Arrays.equals( fOverlays, other.fOverlays ); return getBase().equals( other.getBase() ) && Arrays.equals( getOverlays(), other.getOverlays() );
} }
public int hashCode() public int hashCode() {
{ int code = getBase().hashCode();
int code = fBase.hashCode(); for (int i = 0; i < getOverlays().length; i++) {
for ( int i = 0; i < fOverlays.length; i++ ) if ( getOverlays()[i] != null )
{ code ^= getOverlays()[i].hashCode();
if ( fOverlays[i] != null )
code ^= fOverlays[i].hashCode();
} }
return code; return code;
} }
/* (non-Javadoc) /*
* @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int) * (non-Javadoc)
*
* @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int,
* int)
*/ */
protected void drawCompositeImage( int width, int height ) protected void drawCompositeImage( int width, int height ) {
{ drawImage( getBase().getImageData(), 0, 0 );
drawImage( fBase.getImageData(), 0, 0 ); drawOverlays( getOverlays() );
drawOverlays( fOverlays );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize() * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
*/ */
protected Point getSize() protected Point getSize() {
{ return this.fSize;
return fSize;
} }
private Image getBase() {
return this.fBase;
}
private void setBase( Image base ) {
this.fBase = base;
}
private ImageDescriptor[] getOverlays() {
return this.fOverlays;
}
private void setOverlays( ImageDescriptor[] overlays ) {
this.fOverlays = overlays;
}
private void setSize( Point size ) {
this.fSize = size;
}
} }

View file

@ -1,62 +1,63 @@
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
/********************************************************************** /*******************************************************************************
Copyright (c) 2000, 2002 IBM Corp. and others. * Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
All rights reserved. This program and the accompanying materials * program and the accompanying materials are made available under the terms of
are made available under the terms of the Common Public License v0.5 * the Common Public License v0.5 which accompanies this distribution, and is
which accompanies this distribution, and is available at * available at http://www.eclipse.org/legal/cpl-v05.html
http://www.eclipse.org/legal/cpl-v05.html *
* Contributors: IBM Corporation - Initial implementation
Contributors: ******************************************************************************/
IBM Corporation - Initial implementation
**********************************************************************/
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
public class PixelConverter public class PixelConverter {
{
private FontMetrics fFontMetrics; private FontMetrics fFontMetrics;
public PixelConverter( Control control ) public PixelConverter( Control control ) {
{
GC gc = new GC( control ); GC gc = new GC( control );
gc.setFont( control.getFont() ); gc.setFont( control.getFont() );
fFontMetrics = gc.getFontMetrics(); setFontMetrics( gc.getFontMetrics() );
gc.dispose(); gc.dispose();
} }
/** /**
* @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int) * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
*/ */
public int convertHeightInCharsToPixels( int chars ) public int convertHeightInCharsToPixels( int chars ) {
{ return Dialog.convertHeightInCharsToPixels( getFontMetrics(), chars );
return Dialog.convertHeightInCharsToPixels( fFontMetrics, chars );
} }
/** /**
* @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int) * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
*/ */
public int convertHorizontalDLUsToPixels( int dlus ) public int convertHorizontalDLUsToPixels( int dlus ) {
{ return Dialog.convertHorizontalDLUsToPixels( getFontMetrics(), dlus );
return Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus );
} }
/** /**
* @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int) * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
*/ */
public int convertVerticalDLUsToPixels( int dlus ) public int convertVerticalDLUsToPixels( int dlus ) {
{ return Dialog.convertVerticalDLUsToPixels( getFontMetrics(), dlus );
return Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus );
} }
/** /**
* @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int) * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
*/ */
public int convertWidthInCharsToPixels( int chars ) public int convertWidthInCharsToPixels( int chars ) {
{ return Dialog.convertWidthInCharsToPixels( getFontMetrics(), chars );
return Dialog.convertWidthInCharsToPixels( fFontMetrics, chars ); }
private FontMetrics getFontMetrics() {
return this.fFontMetrics;
}
private void setFontMetrics( FontMetrics fontMetrics ) {
this.fFontMetrics = fontMetrics;
} }
} }

View file

@ -1,6 +1,5 @@
/* /*
*(c) Copyright QNX Software Systems Ltd. 2002. * (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
* All Rights Reserved.
* *
*/ */
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
@ -18,24 +17,22 @@ import org.eclipse.jface.dialogs.MessageDialog;
* *
* @since Sep 25, 2002 * @since Sep 25, 2002
*/ */
public class QuestionStatusHandler implements IStatusHandler public class QuestionStatusHandler implements IStatusHandler {
{
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object) * @see org.eclipse.debug.core.IStatusHandler#handleStatus(IStatus, Object)
*/ */
public Object handleStatus( IStatus status, Object source ) throws CoreException public Object handleStatus( IStatus status, Object source ) throws CoreException {
{
final boolean result[] = new boolean[1]; final boolean result[] = new boolean[1];
if ( status != null && source != null && source instanceof IDebugTarget ) if ( status != null && source != null && source instanceof IDebugTarget ) {
{
final String title = ((IDebugTarget)source).getName(); final String title = ((IDebugTarget)source).getName();
final String message = status.getMessage(); final String message = status.getMessage();
CDebugUIPlugin.getStandardDisplay().syncExec( CDebugUIPlugin.getStandardDisplay().syncExec(
new Runnable() new Runnable() {
{ public void run() {
public void run()
{
result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message ); result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
} }
} ); } );

View file

@ -1,6 +1,5 @@
/* /*
* (c) Copyright IBM Corp. 2000, 2001. * (c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
* All Rights Reserved.
*/ */
package org.eclipse.cdt.debug.internal.ui; package org.eclipse.cdt.debug.internal.ui;
@ -22,16 +21,14 @@ import org.eclipse.swt.widgets.Widget;
/** /**
* Utility class to simplify access to some SWT resources. * Utility class to simplify access to some SWT resources.
*/ */
public class SWTUtil public class SWTUtil {
{
/** /**
* Returns the standard display to be used. The method first checks, if * Returns the standard display to be used. The method first checks, if the
* the thread calling this method has an associated disaply. If so, this * thread calling this method has an associated disaply. If so, this
* display is returned. Otherwise the method returns the default display. * display is returned. Otherwise the method returns the default display.
*/ */
public static Display getStandardDisplay() public static Display getStandardDisplay() {
{
Display display; Display display;
display = Display.getCurrent(); display = Display.getCurrent();
if ( display == null ) if ( display == null )
@ -45,8 +42,7 @@ public class SWTUtil
* *
* @return the shell for the given widget * @return the shell for the given widget
*/ */
public static Shell getShell( Widget widget ) public static Shell getShell(Widget widget) {
{
if ( widget instanceof Control ) if ( widget instanceof Control )
return ((Control)widget).getShell(); return ((Control)widget).getShell();
if ( widget instanceof Caret ) if ( widget instanceof Caret )
@ -59,15 +55,13 @@ public class SWTUtil
return ((Menu)widget).getParent().getShell(); return ((Menu)widget).getParent().getShell();
if ( widget instanceof ScrollBar ) if ( widget instanceof ScrollBar )
return ((ScrollBar)widget).getParent().getShell(); return ((ScrollBar)widget).getParent().getShell();
return null; return null;
} }
/** /**
* Returns a width hint for a button control. * Returns a width hint for a button control.
*/ */
public static int getButtonWidthHint( Button button ) public static int getButtonWidthHint( Button button ) {
{
PixelConverter converter = new PixelConverter( button ); PixelConverter converter = new PixelConverter( button );
int widthHint = converter.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH ); int widthHint = converter.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH );
return Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); return Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x );
@ -76,25 +70,21 @@ public class SWTUtil
/** /**
* Returns a height hint for a button control. * Returns a height hint for a button control.
*/ */
public static int getButtonHeigthHint( Button button ) public static int getButtonHeigthHint( Button button ) {
{
PixelConverter converter = new PixelConverter( button ); PixelConverter converter = new PixelConverter( button );
return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT ); return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT );
} }
/** /**
* Sets width and height hint for the button control. * Sets width and height hint for the button control. <b>Note:</b> This
* <b>Note:</b> This is a NOP if the button's layout data is not * is a NOP if the button's layout data is not an instance of <code>GridData</code>.
* an instance of <code>GridData</code>.
* *
* @param the button for which to set the dimension hint * @param the button for which to set the dimension hint
*/ */
public static void setButtonDimensionHint( Button button ) public static void setButtonDimensionHint( Button button ) {
{
Assert.isNotNull( button ); Assert.isNotNull( button );
Object gd = button.getLayoutData(); Object gd = button.getLayoutData();
if ( gd instanceof GridData ) if ( gd instanceof GridData ) {
{
((GridData)gd).heightHint = getButtonHeigthHint( button ); ((GridData)gd).heightHint = getButtonHeigthHint( button );
((GridData)gd).widthHint = getButtonWidthHint( button ); ((GridData)gd).widthHint = getButtonWidthHint( button );
} }