Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 378575

Summary: SupportTray.createImages throws FNF
Product: [RT] RAP Reporter: Thomas Kratz <eiswind>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 1.5 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Thomas Kratz CLA 2012-05-05 06:04:59 EDT
Build Identifier: 1.5M5

I was trying some stuff with an ErrorSuppotProvider today and I found that the SupportTray implementation in rap.ui.workbench only works when launched from the IDE (exploded). When bundled as a jar plugin I fails to load some Images that are coded into createImegas (don't know how often I made the same mistake already)
I could fix it with the following snippet:

private void createImages() {
		Display display = Display.getCurrent();
		int[] shape = new int[] { 3, 3, 5, 3, 7, 5, 8, 5, 10, 3, 12, 3, 12,
				5, 10, 7, 10, 8, 12, 10, 12, 12, 10, 12, 8, 10, 7, 10, 5,
				12, 3, 12, 3, 10, 5, 8, 5, 7, 3, 5 };

		/*
		 * Use magenta as transparency color since it is used infrequently.
		 */
		Color border = display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
		Color background = display
				.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
		Color backgroundHot = new Color(display, new RGB(252, 160, 160));
		Color transparent = display.getSystemColor(SWT.COLOR_MAGENTA);

		PaletteData palette = new PaletteData(new RGB[] {
				transparent.getRGB(), border.getRGB(), background.getRGB(),
				backgroundHot.getRGB() });
		ImageData data = new ImageData(16, 16, 8, palette);
		data.transparentPixel = 0;

		// RAP [bm] owner drawn image replaced by static
//		normal = new Image(display, data);
//		normal.setBackground(transparent);
//		GC gc = new GC(normal);
//		gc.setBackground(background);
//		gc.fillPolygon(shape);
//		gc.setForeground(border);
//		gc.drawPolygon(shape);
//		gc.dispose();
		InputStream in = this.getClass().getClassLoader().getResourceAsStream("org/eclipse/ui/internal/statushandlers/close.gif");
		normal = new Image(display, in);
		
//		hover = new Image(display, data);
//		hover.setBackground(transparent);
//		gc = new GC(hover);
//		gc.setBackground(backgroundHot);
//		gc.fillPolygon(shape);
//		gc.setForeground(border);
//		gc.drawPolygon(shape);
//		gc.dispose();
		in = this.getClass().getClassLoader().getResourceAsStream("org/eclipse/ui/internal/statushandlers/close_hover.gif");
		hover = new Image(display, in);
		
		backgroundHot.dispose();
	}

Note how the Images are loaded from the jar resource.
Should be a quick fix.

Reproducible: Always

Steps to Reproduce:
1. create and register an errorsupportprovider
2. provoke an error
3. SupportTray throws an SWTException because Files are not found
Comment 1 Ivan Furnadjiev CLA 2012-05-09 08:45:54 EDT
Fixed in CVS HEAD as suggested - use image ctor with input stream parameter. Changes are in CVS HEAD and will be part of 1.5RC1
Comment 2 Thomas Kratz CLA 2012-05-09 08:56:09 EDT
Thx!