KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > SharedImages


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal;
12
13 import org.eclipse.jface.resource.ImageDescriptor;
14 import org.eclipse.swt.graphics.Image;
15 import org.eclipse.ui.ISharedImages;
16
17 /**
18  * Common images used by the workbench which may be useful to other plug-ins.
19  */

20 public class SharedImages implements ISharedImages {
21     /**
22      * Retrieves the specified image from the workbench plugin's image registry.
23      *
24      * @see ISharedImages
25      */

26     public Image getImage(String JavaDoc symbolicName) {
27         Image image = WorkbenchImages.getImage(symbolicName);
28         if (image != null) {
29             return image;
30         }
31
32         //if there is a descriptor for it, add the image to the registry.
33
ImageDescriptor desc = WorkbenchImages.getImageDescriptor(symbolicName);
34         if (desc != null) {
35             WorkbenchImages.getImageRegistry().put(symbolicName, desc);
36             return WorkbenchImages.getImageRegistry().get(symbolicName);
37         }
38         return null;
39     }
40
41     /**
42      * Retrieves the specified image descriptor from the workbench plugin's image registry.
43      *
44      * @see ISharedImages
45      */

46     public ImageDescriptor getImageDescriptor(String JavaDoc symbolicName) {
47         return WorkbenchImages.getImageDescriptor(symbolicName);
48     }
49 }
50
Popular Tags