Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import java.net.URL; |
13 |
import java.net.URL; |
14 |
|
14 |
|
|
|
15 |
import org.eclipse.jface.internal.JFaceActivator; |
15 |
import org.eclipse.swt.SWTException; |
16 |
import org.eclipse.swt.SWTException; |
16 |
import org.eclipse.swt.graphics.Device; |
17 |
import org.eclipse.swt.graphics.Device; |
17 |
import org.eclipse.swt.graphics.Image; |
18 |
import org.eclipse.swt.graphics.Image; |
Lines 19-24
Link Here
|
19 |
import org.eclipse.swt.graphics.PaletteData; |
20 |
import org.eclipse.swt.graphics.PaletteData; |
20 |
import org.eclipse.swt.graphics.RGB; |
21 |
import org.eclipse.swt.graphics.RGB; |
21 |
import org.eclipse.swt.widgets.Display; |
22 |
import org.eclipse.swt.widgets.Display; |
|
|
23 |
import org.osgi.framework.Bundle; |
24 |
import org.osgi.framework.BundleContext; |
25 |
import org.osgi.framework.ServiceReference; |
22 |
|
26 |
|
23 |
/** |
27 |
/** |
24 |
* An image descriptor is an object that knows how to create |
28 |
* An image descriptor is an object that knows how to create |
Lines 155-161
Link Here
|
155 |
if (url == null) { |
159 |
if (url == null) { |
156 |
return getMissingImageDescriptor(); |
160 |
return getMissingImageDescriptor(); |
157 |
} |
161 |
} |
158 |
return new URLImageDescriptor(url); |
162 |
return new URLImageDescriptor(transformImageLocation(url)); |
159 |
} |
163 |
} |
160 |
|
164 |
|
161 |
/* (non-Javadoc) |
165 |
/* (non-Javadoc) |
Lines 326-329
Link Here
|
326 |
public static ImageDescriptor getMissingImageDescriptor() { |
330 |
public static ImageDescriptor getMissingImageDescriptor() { |
327 |
return MissingImageDescriptor.getInstance(); |
331 |
return MissingImageDescriptor.getInstance(); |
328 |
} |
332 |
} |
|
|
333 |
|
334 |
/** |
335 |
* Transforms the {@link URL} by using an available implementation of |
336 |
* {@link IImageLocationTransformer}. |
337 |
* |
338 |
* @param url |
339 |
* Given image {@link URL}. |
340 |
* @return Transformed {@link URL}. |
341 |
*/ |
342 |
private static URL transformImageLocation(URL url) { |
343 |
URL result = url; |
344 |
|
345 |
Bundle bundle = JFaceActivator.getBundle(); |
346 |
if (bundle != null) { |
347 |
BundleContext bundleContext = JFaceActivator.getBundle() |
348 |
.getBundleContext(); |
349 |
if (bundleContext != null) { |
350 |
ServiceReference serviceReference = bundleContext |
351 |
.getServiceReference(IImageLocationTransformer.class |
352 |
.getName()); |
353 |
if (serviceReference != null) { |
354 |
Object service = bundleContext.getService(serviceReference); |
355 |
if (service != null) { |
356 |
IImageLocationTransformer transformer = (IImageLocationTransformer) service; |
357 |
result = transformer.transform(url); |
358 |
} |
359 |
} |
360 |
} |
361 |
} |
362 |
|
363 |
return result; |
364 |
} |
329 |
} |
365 |
} |