img = ReportPlugin.getImage( key ); imageMap.put( key, img );
try { url = new URL( "file: img = ImageManager.getInstance( ).loadImage( url ); } catch ( IOException e ) { } if ( img != null ) { imageMap.put( key, img ); }
		public void handleEvent( Event event )		{			// change description/image			selectedIndex = templateList.getSelectionIndex( );			ReportDesignHandle handle = (ReportDesignHandle) templates.get( selectedIndex );			String ReprotDescription = handle.getDescription( );			if ( ReprotDescription != null					&& ReprotDescription.trim( ).length( ) != 0 )			{				if ( isPredifinedTemplate( handle.getFileName( ) ) )				{					description.setText( Messages.getString( ReprotDescription ) );				}				else				{					description.setText( ReprotDescription );				}			}			else			{				description.setText( "" );			}			// we need to relayout if the new text has different number of lines			previewPane.layout( );			String key = handle.getIconFile( );			Object img = null;			if ( ( key != null ) && ( !"".equals( key.trim( ) ) ) ) //$NON-NLS-1$			{				URL url = getPreviewImageURL( handle.getFileName( ), key );				if ( url != null )				{					try					{						key = FileLocator.resolve( url ).getPath( );					}					catch ( IOException e )					{						e.printStackTrace( );					}					img = imageMap.get( key );					if ( img == null )					{						img = ReportPlugin.getImage( key );						imageMap.put( key, img );					}					previewCanvas.setVisible( true );					previewThumbnail.setVisible( false );					previewCanvas.clear( );					previewCanvas.loadImage( ( (Image) img ) );					previewCanvas.showOriginal( );				}				else				{					key = null;				}			}			// if (key == null)			if ( key == null					&& handle.getThumbnail( ) != null					&& handle.getThumbnail( ).length != 0 )			{				previewCanvas.setVisible( true );				previewThumbnail.setVisible( false );				byte[] thumbnailData = handle.getThumbnail( );				ByteArrayInputStream inputStream = new ByteArrayInputStream( thumbnailData );				if ( thumbnailImage != null )				{					thumbnailImage.dispose( );					thumbnailImage = null;				}				thumbnailImage = new Image( null, inputStream );				previewCanvas.clear( );				previewCanvas.loadImage( ( (Image) thumbnailImage ) );			}			else if ( key == null )			{				previewCanvas.setVisible( false );				previewThumbnail.setVisible( true );				Control[] children = previewThumbnail.getChildren( );				for ( int i = 0; i < children.length; i++ )				{					children[i].dispose( );				}				ReportGraphicsViewComposite thumbnail = new ReportGraphicsViewComposite( previewThumbnail,						SWT.NULL,						handle );				previewThumbnail.layout( );			}			if ( handle.getCheatSheet( ) != null					&& handle.getCheatSheet( ).trim( ).length( ) != 0 )			{				chkBox.setEnabled( !( handle.getCheatSheet( ).equals( "" ) || handle.getCheatSheet( )						.equals( "org.eclipse.birt.report.designer.ui.cheatsheet.firstreport" ) ) ); //$NON-NLS-1$				if(handle.getCheatSheet( )						.equals( "org.eclipse.birt.report.designer.ui.cheatsheet.firstreport" ))				{					chkBox.setSelection( true );				}			}			else			{				chkBox.setSelection( false );				chkBox.setEnabled( false );			}		}