Mercurial > projects > dwt-addons
changeset 73:6787ae179808
Fix FileImageDescriptor to work with compiletime data
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 19:09:48 +0200 |
parents | 5df4896124c7 |
children | dad2e11b8ae4 |
files | dwtx/jface/resource/FileImageDescriptor.d dwtx/jface/resource/ImageDescriptor.d dwtx/jface/resource/URLImageDescriptor.d |
diffstat | 3 files changed, 17 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtx/jface/resource/FileImageDescriptor.d Thu May 22 17:56:17 2008 +0200 +++ b/dwtx/jface/resource/FileImageDescriptor.d Thu May 22 19:09:48 2008 +0200 @@ -176,14 +176,16 @@ * @see dwtx.jface.resource.ImageDescriptor#createImage(bool, * dwt.graphics.Device) */ - public Image createImage(bool returnMissingImageOnError, Device device) { - String path = getFilePath(); - if (path is null) - return createDefaultImage(returnMissingImageOnError, device); - try { - return new Image(device, path); - } catch (DWTException exception) { - //if we fail try the default way using a stream + public override Image createImage(bool returnMissingImageOnError, Device device) { + if( importdata.length is 0 ){ + String path = getFilePath(); + if (path is null ) + return createDefaultImage(returnMissingImageOnError, device); + try { + return new Image(device, path); + } catch (DWTException exception) { + //if we fail try the default way using a stream + } } return super.createImage(returnMissingImageOnError, device); }
--- a/dwtx/jface/resource/ImageDescriptor.d Thu May 22 17:56:17 2008 +0200 +++ b/dwtx/jface/resource/ImageDescriptor.d Thu May 22 19:09:48 2008 +0200 @@ -311,6 +311,7 @@ } return new Image(device, data); } catch (DWTException exception) { + //ExceptionPrintStackTrace(exception); if (returnMissingImageOnError) { try { return new Image(device, DEFAULT_IMAGE_DATA);
--- a/dwtx/jface/resource/URLImageDescriptor.d Thu May 22 17:56:17 2008 +0200 +++ b/dwtx/jface/resource/URLImageDescriptor.d Thu May 22 19:09:48 2008 +0200 @@ -40,13 +40,13 @@ class URLImageDescriptor : ImageDescriptor { /** * Constant for the file protocol for optimized loading - */ + */ private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$ private Uri url; /** * Creates a new URLImageDescriptor. - * + * * @param url * The URL to load the image from. Must be non-null. */ @@ -89,7 +89,7 @@ /** * Returns a stream on the image contents. Returns null if a stream could * not be opened. - * + * * @return the stream for loading the data */ protected InputStream getStream() { @@ -126,7 +126,7 @@ /** * Returns the filename for the ImageData. - * + * * @return {@link String} or <code>null</code> if the file cannot be found */ private String getFilePath() { @@ -152,11 +152,11 @@ /* * (non-Javadoc) - * + * * @see dwtx.jface.resource.ImageDescriptor#createImage(bool, * dwt.graphics.Device) */ - public Image createImage(bool returnMissingImageOnError, Device device) { + public override Image createImage(bool returnMissingImageOnError, Device device) { // Try to see if we can optimize using SWTs file based image support. String path = getFilePath();