-
Notifications
You must be signed in to change notification settings - Fork 5
Use of Image Registry with Activator_96501779
nxi edited this page Apr 9, 2015
·
1 revision
Created by Tony Lam, last modified on Aug 05, 2008
For certain platform ther are restriction on the number of image object hold by SWT. JFace provides the concept of image registry to encourage the reuse of image object so the total number of image object can be reduced. This facility is accessible in Eclipse RCP via each AbstractUIPlugin instance. To use this, simply override the method initializeImageRegistry(ImageRegistry).
The following code shows how this can be done, with proper disposal management:
It is convenience to keep image key as static field in an "Internal" class. This restrict the use of image within the plug-in level.
public class Activator extends AbstractUIPlugin { ... private boolean imageRegistryInitialised = false; ... public void stop(BundleContext context) throws Exception { if (imageRegistryInitialised) { getImageRegistry().dispose(); imageRegistryInitialised = false; } ... } ... protected void initializeImageRegistry(ImageRegistry reg) { reg.put(Internal.IMG_KEY_IMAGE_NOT_AVAILABLE, imageDescriptorFromPlugin(PLUGIN_ID, "images/NotAvailable.png")); ... imageRegistryInitialised = true; } ... }
Document generated by Confluence on Apr 01, 2015 00:11
Home | Developer Guide | Copyright © 2013 ANSTO