| /****************************************************************************** |
| * Copyright (c) 2005 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| ****************************************************************************/ |
| |
| package org.eclipse.gmf.runtime.diagram.ui.providers.internal.l10n; |
| |
| import org.eclipse.gmf.runtime.diagram.ui.providers.internal.DiagramProvidersPlugin; |
| import org.eclipse.jface.resource.ImageDescriptor; |
| import org.eclipse.swt.graphics.Image; |
| import org.eclipse.ui.plugin.AbstractUIPlugin; |
| |
| /** |
| * Bundle of all images used by this plugin. Image descriptors can be retrieved |
| * by referencing the public image descriptor variable directly. The public |
| * strings represent images that will be cached and can be retrieved using |
| * {@link #get(String)} which should <b>not</b> be disposed by the client. |
| * |
| * @author cmahoney |
| */ |
| public class DiagramUIProvidersPluginImages { |
| |
| /** |
| * The icons root directory. |
| */ |
| private static final String PREFIX_ROOT = "icons/"; //$NON-NLS-1$ |
| |
| // Cached images that can be retrieved using the get method. The |
| // corresponding image descriptor must be initialized using the |
| // createAndCache() method. |
| |
| public static final String IMG_BOOKMARK = PREFIX_ROOT + "bookmark.gif"; //$NON-NLS-1$ |
| |
| // Image descriptors. |
| |
| public static final ImageDescriptor DESC_BOOKMARK = createAndCache(IMG_BOOKMARK); |
| |
| /** |
| * Creates the image descriptor from the filename given. |
| * |
| * @param imageName |
| * the full filename of the image |
| * @return the new image descriptor |
| */ |
| private static ImageDescriptor create(String imageName) { |
| return AbstractUIPlugin.imageDescriptorFromPlugin(DiagramProvidersPlugin |
| .getPluginId(), imageName); |
| } |
| |
| /** |
| * Creates the image descriptor from the filename given and caches it in the |
| * plugin's image registry. |
| * |
| * @param imageName |
| * the full filename of the image |
| * @return the new image descriptor |
| */ |
| private static ImageDescriptor createAndCache(String imageName) { |
| ImageDescriptor result = create(imageName); |
| DiagramProvidersPlugin.getInstance().getImageRegistry().put(imageName, result); |
| return result; |
| } |
| |
| /** |
| * Gets an image from the image registry. This image should not be disposed |
| * of, that is handled in the image registry. The image descriptor must have |
| * previously been cached in the image registry. The cached images for the |
| * public image names defined in this file can be retrieved using this |
| * method. |
| * |
| * @param imageName |
| * the full filename of the image |
| * @return the image or null if it has not been cached in the registry |
| */ |
| public static Image get(String imageName) { |
| return DiagramProvidersPlugin.getInstance().getImageRegistry().get(imageName); |
| } |
| |
| } |