1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +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
Removed the "Show Debugger Console" action.
* DebuggerConsoleActionDelegate.java

View file

@ -444,7 +444,7 @@ public class CDTDebugModelPresentation extends LabelProvider
if ( info != null && info instanceof ICDISignalExitInfo)
{
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() } );
}
else if ( info != null && info instanceof ICDIExitInfo )
@ -493,14 +493,14 @@ public class CDTDebugModelPresentation extends LabelProvider
ICDISignal signal = ((ICDISignalReceived)info).getSignal();
String label = threadName +
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() } );
return label;
}
if ( info != null && info instanceof ICDIWatchpointTrigger )
{
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(),
((ICDIWatchpointTrigger)info).getNewValue() } );
return label;

View file

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

View file

@ -1 +1,3 @@
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
*/
public class ColorManager
{
private static ColorManager fgColorManager;
public class ColorManager {
private ColorManager()
{
private static ColorManager gfColorManager;
private ColorManager() {
}
public static ColorManager getDefault()
{
if ( fgColorManager == null )
{
fgColorManager = new ColorManager();
public static ColorManager getDefault() {
if ( gfColorManager == null ) {
gfColorManager = new ColorManager();
}
return fgColorManager;
return gfColorManager;
}
protected Map fColorTable = new HashMap( 10 );
public Color getColor( RGB rgb )
{
Color color = (Color)fColorTable.get( rgb );
if ( color == null )
{
public Color getColor( RGB rgb ) {
Color color = (Color)getColorTable().get(rgb);
if ( color == null ) {
color = new Color( Display.getCurrent(), rgb );
fColorTable.put( rgb, color );
getColorTable().put( rgb, color );
}
return color;
}
public void dispose()
{
Iterator e = fColorTable.values().iterator();
public void dispose() {
Iterator e = getColorTable().values().iterator();
while( e.hasNext() )
((Color)e.next()).dispose();
((Color)e.next()).dispose();
}
private Map getColorTable() {
return this.fColorTable;
}
}

View file

@ -18,26 +18,24 @@ import org.eclipse.jface.dialogs.MessageDialog;
*
* @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)
*/
public Object handleStatus( IStatus status, Object source ) throws CoreException
{
if ( status != null && source != null && source instanceof IDebugTarget )
{
public Object handleStatus( IStatus status, Object source )
throws CoreException {
if ( status != null && source != null && source instanceof IDebugTarget ) {
final String title = ((IDebugTarget)source).getName();
final String message = status.getMessage();
CDebugUIPlugin.getStandardDisplay().asyncExec(
new Runnable()
{
public void run()
{
MessageDialog.openInformation( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
}
} );
new Runnable() {
public void run() {
MessageDialog.openInformation( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
}
} );
}
return null;
}

View file

@ -1,7 +1,6 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui;
@ -17,23 +16,23 @@ import org.eclipse.swt.graphics.Image;
*
* @since May 30, 2003
*/
public class OverlayImageCache
{
private Map cache = new HashMap();
public class OverlayImageCache {
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
*/
public Image getImageFor( OverlayImageDescriptor imageDescriptor )
{
Image image = (Image)cache.get( imageDescriptor );
if ( image == null )
{
public Image getImageFor( OverlayImageDescriptor imageDescriptor ) {
Image image = (Image)getCache().get( imageDescriptor );
if ( image == null ) {
image = imageDescriptor.createImage();
cache.put( imageDescriptor, image );
getCache().put( imageDescriptor, image );
}
return image;
}
@ -41,13 +40,15 @@ public class OverlayImageCache
/**
* Disposes of all images in the cache.
*/
public void disposeAll()
{
for ( Iterator it = cache.values().iterator(); it.hasNext(); )
{
public void disposeAll() {
for ( Iterator it = getCache().values().iterator(); it.hasNext(); ) {
Image image = (Image)it.next();
image.dispose();
}
cache.clear();
getCache().clear();
}
private Map getCache() {
return this.fCache;
}
}

View file

@ -1,7 +1,6 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui;
@ -14,8 +13,8 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
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_HEIGHT = 16;
@ -33,29 +32,23 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
// the size
private Point fSize;
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays )
{
fBase = base;
fOverlays = overlays;
fSize = new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT );
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays ) {
this( base, overlays, new Point( DEFAULT_WIDTH, DEFAULT_HEIGHT ) );
}
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size )
{
fBase = base;
fOverlays = overlays;
fSize = size;
public OverlayImageDescriptor( Image base, ImageDescriptor[] overlays, Point size ) {
setBase( base );
setOverlays( overlays );
setSize( size );
}
/**
* Draw the fOverlays for the reciever.
*/
protected void drawOverlays( ImageDescriptor[] overlays )
{
protected void drawOverlays(ImageDescriptor[] overlays) {
Point size = getSize();
for ( int i = 0; i < overlays.length; i++ )
{
for ( int i = 0; i < overlays.length; i++ ) {
ImageDescriptor overlay = overlays[i];
if ( overlay == null )
continue;
@ -63,8 +56,7 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
//Use the missing descriptor if it is not there.
if ( overlayData == null )
overlayData = ImageDescriptor.getMissingImageDescriptor().getImageData();
switch( i )
{
switch( i ) {
case TOP_LEFT:
drawImage( overlayData, 0, 0 );
break;
@ -81,40 +73,59 @@ public class OverlayImageDescriptor extends CompositeImageDescriptor
}
}
public boolean equals( Object o )
{
if ( !( o instanceof OverlayImageDescriptor ) )
public boolean equals( Object o ) {
if ( !(o instanceof OverlayImageDescriptor) )
return false;
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()
{
int code = fBase.hashCode();
for ( int i = 0; i < fOverlays.length; i++ )
{
if ( fOverlays[i] != null )
code ^= fOverlays[i].hashCode();
public int hashCode() {
int code = getBase().hashCode();
for (int i = 0; i < getOverlays().length; i++) {
if ( getOverlays()[i] != null )
code ^= getOverlays()[i].hashCode();
}
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 )
{
drawImage( fBase.getImageData(), 0, 0 );
drawOverlays( fOverlays );
protected void drawCompositeImage( int width, int height ) {
drawImage( getBase().getImageData(), 0, 0 );
drawOverlays( getOverlays() );
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
*/
protected Point getSize()
{
return fSize;
protected Point getSize() {
return this.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;
/**********************************************************************
Copyright (c) 2000, 2002 IBM Corp. and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Common Public License v0.5
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/cpl-v05.html
Contributors:
IBM Corporation - Initial implementation
**********************************************************************/
/*******************************************************************************
* Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v0.5 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors: IBM Corporation - Initial implementation
******************************************************************************/
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Control;
public class PixelConverter
{
public class PixelConverter {
private FontMetrics fFontMetrics;
public PixelConverter( Control control )
{
public PixelConverter( Control control ) {
GC gc = new GC( control );
gc.setFont( control.getFont() );
fFontMetrics = gc.getFontMetrics();
setFontMetrics( gc.getFontMetrics() );
gc.dispose();
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
*/
public int convertHeightInCharsToPixels( int chars )
{
return Dialog.convertHeightInCharsToPixels( fFontMetrics, chars );
public int convertHeightInCharsToPixels( int chars ) {
return Dialog.convertHeightInCharsToPixels( getFontMetrics(), chars );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
*/
public int convertHorizontalDLUsToPixels( int dlus )
{
return Dialog.convertHorizontalDLUsToPixels( fFontMetrics, dlus );
public int convertHorizontalDLUsToPixels( int dlus ) {
return Dialog.convertHorizontalDLUsToPixels( getFontMetrics(), dlus );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
*/
public int convertVerticalDLUsToPixels( int dlus )
{
return Dialog.convertVerticalDLUsToPixels( fFontMetrics, dlus );
public int convertVerticalDLUsToPixels( int dlus ) {
return Dialog.convertVerticalDLUsToPixels( getFontMetrics(), dlus );
}
/**
* @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
*/
public int convertWidthInCharsToPixels( int chars )
{
return Dialog.convertWidthInCharsToPixels( fFontMetrics, chars );
public int convertWidthInCharsToPixels( int chars ) {
return Dialog.convertWidthInCharsToPixels( getFontMetrics(), chars );
}
private FontMetrics getFontMetrics() {
return this.fFontMetrics;
}
private void setFontMetrics( FontMetrics fontMetrics ) {
this.fFontMetrics = fontMetrics;
}
}

View file

@ -1,7 +1,6 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
*
*/
package org.eclipse.cdt.debug.internal.ui;
@ -18,27 +17,25 @@ import org.eclipse.jface.dialogs.MessageDialog;
*
* @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)
*/
public Object handleStatus( IStatus status, Object source ) throws CoreException
{
public Object handleStatus( IStatus status, Object source ) throws CoreException {
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 message = status.getMessage();
CDebugUIPlugin.getStandardDisplay().syncExec(
new Runnable()
{
public void run()
{
result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
}
} );
new Runnable() {
public void run() {
result[0] = MessageDialog.openQuestion( CDebugUIPlugin.getActiveWorkbenchShell(), title, message );
}
} );
}
return new Boolean( result[0] );
}

View file

@ -1,6 +1,5 @@
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
* (c) Copyright IBM Corp. 2000, 2001. All Rights Reserved.
*/
package org.eclipse.cdt.debug.internal.ui;
@ -20,18 +19,16 @@ import org.eclipse.swt.widgets.Shell;
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
* the thread calling this method has an associated disaply. If so, this
* Returns the standard display to be used. The method first checks, if the
* thread calling this method has an associated disaply. If so, this
* display is returned. Otherwise the method returns the default display.
*/
public static Display getStandardDisplay()
{
public static Display getStandardDisplay() {
Display display;
display = Display.getCurrent();
if ( display == null )
@ -45,29 +42,26 @@ public class SWTUtil
*
* @return the shell for the given widget
*/
public static Shell getShell( Widget widget )
{
public static Shell getShell(Widget widget) {
if ( widget instanceof Control )
return ((Control) widget).getShell();
return ((Control)widget).getShell();
if ( widget instanceof Caret )
return ((Caret) widget).getParent().getShell();
return ((Caret)widget).getParent().getShell();
if ( widget instanceof DragSource )
return ((DragSource) widget).getControl().getShell();
return ((DragSource)widget).getControl().getShell();
if ( widget instanceof DropTarget )
return ((DropTarget) widget).getControl().getShell();
return ((DropTarget)widget).getControl().getShell();
if ( widget instanceof Menu )
return ((Menu) widget).getParent().getShell();
return ((Menu)widget).getParent().getShell();
if ( widget instanceof ScrollBar )
return ((ScrollBar) widget).getParent().getShell();
return ((ScrollBar)widget).getParent().getShell();
return null;
}
/**
* 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 );
int widthHint = converter.convertHorizontalDLUsToPixels( IDialogConstants.BUTTON_WIDTH );
return Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x );
@ -76,27 +70,23 @@ public class SWTUtil
/**
* 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 );
return converter.convertVerticalDLUsToPixels( IDialogConstants.BUTTON_HEIGHT );
}
/**
* Sets width and height hint for the button control.
* <b>Note:</b> This is a NOP if the button's layout data is not
* an instance of <code>GridData</code>.
* Sets width and height hint for the button control. <b>Note:</b> This
* is a NOP if the button's layout data is not 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 );
Object gd = button.getLayoutData();
if ( gd instanceof GridData )
{
((GridData) gd).heightHint = getButtonHeigthHint( button );
((GridData) gd).widthHint = getButtonWidthHint( button );
if ( gd instanceof GridData ) {
((GridData)gd).heightHint = getButtonHeigthHint( button );
((GridData)gd).widthHint = getButtonWidthHint( button );
}
}
}