mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Cosmetics.
This commit is contained in:
parent
ef023fca29
commit
1d59eac559
2 changed files with 133 additions and 166 deletions
|
@ -23,9 +23,7 @@ import org.eclipse.swt.widgets.Display;
|
|||
* A registry that maps <code>ImageDescriptors</code> to <code>Image</code>.
|
||||
*/
|
||||
public class CDebugImageDescriptorRegistry {
|
||||
|
||||
private HashMap fRegistry = new HashMap( 10 );
|
||||
|
||||
private HashMap<ImageDescriptor, Image> fRegistry = new HashMap<ImageDescriptor, Image>(10);
|
||||
private Display fDisplay;
|
||||
|
||||
/**
|
||||
|
@ -57,7 +55,7 @@ public class CDebugImageDescriptorRegistry {
|
|||
public Image get(ImageDescriptor descriptor) {
|
||||
if (descriptor == null)
|
||||
descriptor = ImageDescriptor.getMissingImageDescriptor();
|
||||
Image result = (Image)fRegistry.get( descriptor );
|
||||
Image result = fRegistry.get(descriptor);
|
||||
if (result != null)
|
||||
return result;
|
||||
Assert.isTrue(fDisplay == CDebugUIPlugin.getStandardDisplay(), CDebugUIMessages.getString("CDebugImageDescriptorRegistry.0")); //$NON-NLS-1$
|
||||
|
@ -71,8 +69,8 @@ public class CDebugImageDescriptorRegistry {
|
|||
* Disposes all images managed by this registry.
|
||||
*/
|
||||
public void dispose() {
|
||||
for( Iterator iter = fRegistry.values().iterator(); iter.hasNext(); ) {
|
||||
Image image = (Image)iter.next();
|
||||
for (Iterator<Image> iter = fRegistry.values().iterator(); iter.hasNext();) {
|
||||
Image image = iter.next();
|
||||
image.dispose();
|
||||
}
|
||||
fRegistry.clear();
|
||||
|
@ -80,10 +78,8 @@ public class CDebugImageDescriptorRegistry {
|
|||
|
||||
private void hookDisplay() {
|
||||
fDisplay.asyncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
getDisplay().disposeExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
dispose();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.eclipse.jface.resource.ImageRegistry;
|
|||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
/**
|
||||
*
|
||||
* Bundle of most images used by the C/C++ debug plug-in.
|
||||
*
|
||||
* @since Aug 30, 2002
|
||||
|
@ -34,15 +33,11 @@ public class CDebugImages {
|
|||
|
||||
private static URL fgIconBaseURL = null;
|
||||
|
||||
static
|
||||
{
|
||||
static {
|
||||
String pathSuffix = "icons/"; //$NON-NLS-1$
|
||||
try
|
||||
{
|
||||
try {
|
||||
fgIconBaseURL = new URL(CDebugUIPlugin.getDefault().getBundle().getEntry("/"), pathSuffix); //$NON-NLS-1$
|
||||
}
|
||||
catch( MalformedURLException e )
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
@ -214,8 +209,7 @@ public class CDebugImages {
|
|||
* @param key the image's key
|
||||
* @return the image managed under the given key
|
||||
*/
|
||||
public static Image get( String key )
|
||||
{
|
||||
public static Image get(String key) {
|
||||
return getImageRegistry().get(key);
|
||||
}
|
||||
|
||||
|
@ -223,8 +217,7 @@ public class CDebugImages {
|
|||
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
|
||||
* are retrieved from the *tool16 folders.
|
||||
*/
|
||||
public static void setToolImageDescriptors( IAction action, String iconName )
|
||||
{
|
||||
public static void setToolImageDescriptors(IAction action, String iconName) {
|
||||
setImageDescriptors(action, "tool16", iconName); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -232,21 +225,17 @@ public class CDebugImages {
|
|||
* Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
|
||||
* are retrieved from the *lcl16 folders.
|
||||
*/
|
||||
public static void setLocalImageDescriptors( IAction action, String iconName )
|
||||
{
|
||||
public static void setLocalImageDescriptors(IAction action, String iconName) {
|
||||
setImageDescriptors(action, T_LCL, iconName);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper method to access the image registry from the JDIDebugUIPlugin class.
|
||||
*/
|
||||
/* package */ static ImageRegistry getImageRegistry()
|
||||
{
|
||||
if ( fgImageRegistry == null )
|
||||
{
|
||||
/* package */ static ImageRegistry getImageRegistry() {
|
||||
if (fgImageRegistry == null) {
|
||||
fgImageRegistry = new ImageRegistry();
|
||||
for ( Iterator<String> iter = fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext(); )
|
||||
{
|
||||
for (Iterator<String> iter = fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) {
|
||||
String key = iter.next();
|
||||
fgImageRegistry.put(key, fgAvoidSWTErrorMap.get(key));
|
||||
}
|
||||
|
@ -257,72 +246,54 @@ public class CDebugImages {
|
|||
|
||||
//---- Helper methods to access icons on the file system --------------------------------------
|
||||
|
||||
private static void setImageDescriptors( IAction action, String type, String path )
|
||||
{
|
||||
private static void setImageDescriptors(IAction action, String type, String path) {
|
||||
String relPath = path.substring(NAME_PREFIX_LENGTH);
|
||||
try
|
||||
{
|
||||
try {
|
||||
ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath)); //$NON-NLS-1$
|
||||
if (id != null)
|
||||
action.setDisabledImageDescriptor(id);
|
||||
}
|
||||
catch( MalformedURLException e )
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath)); //$NON-NLS-1$
|
||||
if (id != null)
|
||||
action.setHoverImageDescriptor(id);
|
||||
}
|
||||
catch( MalformedURLException e )
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
}
|
||||
|
||||
action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private static ImageDescriptor createManaged( String prefix, String name )
|
||||
{
|
||||
try
|
||||
{
|
||||
private static ImageDescriptor createManaged(String prefix, String name) {
|
||||
try {
|
||||
ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
|
||||
if ( fgAvoidSWTErrorMap == null )
|
||||
{
|
||||
if (fgAvoidSWTErrorMap == null) {
|
||||
fgAvoidSWTErrorMap = new HashMap<String, ImageDescriptor>();
|
||||
}
|
||||
fgAvoidSWTErrorMap.put(name, result);
|
||||
if ( fgImageRegistry != null )
|
||||
{
|
||||
if (fgImageRegistry != null) {
|
||||
CDebugUIPlugin.logErrorMessage("Internal Error: Image registry already defined"); //$NON-NLS-1$
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch( MalformedURLException e )
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
return ImageDescriptor.getMissingImageDescriptor();
|
||||
}
|
||||
}
|
||||
|
||||
private static ImageDescriptor create( String prefix, String name )
|
||||
{
|
||||
try
|
||||
{
|
||||
private static ImageDescriptor create(String prefix, String name) {
|
||||
try {
|
||||
return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
|
||||
}
|
||||
catch( MalformedURLException e )
|
||||
{
|
||||
} catch (MalformedURLException e) {
|
||||
CDebugUIPlugin.log(e);
|
||||
return ImageDescriptor.getMissingImageDescriptor();
|
||||
}
|
||||
}
|
||||
|
||||
private static URL makeIconFileURL( String prefix, String name ) throws MalformedURLException
|
||||
{
|
||||
private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException {
|
||||
if (fgIconBaseURL == null)
|
||||
throw new MalformedURLException();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue