diff options
author | nitind | 2010-09-29 20:44:31 +0000 |
---|---|---|
committer | nitind | 2010-09-29 20:44:31 +0000 |
commit | 3217c3b60762a17d6f84773bf9b3882708965b34 (patch) | |
tree | ef1a71321cef7f92e50cbcccf8a4a56e34ac170e /bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java | |
parent | ad6a279c7c73d12b25a278cbaae9926aeb70ede5 (diff) | |
parent | 55d9f1a2aea7ec1257fa2b6b389717253db0ed4a (diff) | |
download | webtools.sourceediting-201009292040.tar.gz webtools.sourceediting-201009292040.tar.xz webtools.sourceediting-201009292040.zip |
This commit was manufactured by cvs2svn to create tag 'v201009292040'.v201009292040
Diffstat (limited to 'bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java')
-rw-r--r-- | bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java deleted file mode 100644 index d4ca9f36f4..0000000000 --- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/editor/JSPEditorPluginImageHelper.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 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.jst.jsp.ui.internal.editor; - -import java.util.HashMap; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; - - -/** - * Helper class to handle images provided by this plug-in. - * - * NOTE: For internal use only. For images used externally, please use the - * Shared***ImageHelper class instead. - * - * @author amywu - */ -public class JSPEditorPluginImageHelper { - private final String PLUGINID = JSPUIPlugin.ID; - private static JSPEditorPluginImageHelper instance = null; - - // save a descriptor for each image - private HashMap fImageDescRegistry = null; - - /** - * Gets the instance. - * - * @return Returns a JSPEditorPluginImageHelper - */ - public synchronized static JSPEditorPluginImageHelper getInstance() { - if (instance == null) - instance = new JSPEditorPluginImageHelper(); - return instance; - } - - /** - * Retrieves the image associated with resource from the image registry. - * If the image cannot be retrieved, attempt to find and load the image at - * the location specified in resource. - * - * @param resource - * the image to retrieve - * @return Image the image associated with resource or null if one could - * not be found - */ - public Image getImage(String resource) { - Image image = getImageRegistry().get(resource); - if (image == null) { - // create an image - image = createImage(resource); - } - return image; - } - - /** - * Retrieves the Image associated with ImageDescriptor from the image - * descriptor registry. If the Image cannot be retrieved, it is created - * from the ImageDescriptor - * - * @param resource - * the image descriptor to retrieve - * @return Image the associated with the ImageDescriptor or - * the default "missing" image descriptor if one could not be - * found - */ - public Image getImage(ImageDescriptor descriptor) { - if (descriptor == null) - descriptor= ImageDescriptor.getMissingImageDescriptor(); - - Image result= (Image)getImageDescriptorRegistry().get(descriptor); - if (result != null) - return result; - - result= descriptor.createImage(); - if (result != null) - getImageDescriptorRegistry().put(descriptor, result); - return result; - } - - /** - * Retrieves the image descriptor associated with resource from the image - * descriptor registry. If the image descriptor cannot be retrieved, - * attempt to find and load the image descriptor at the location specified - * in resource. - * - * @param resource - * the image descriptor to retrieve - * @return ImageDescriptor the image descriptor assocated with resource or - * the default "missing" image descriptor if one could not be - * found - */ - public ImageDescriptor getImageDescriptor(String resource) { - ImageDescriptor imageDescriptor = null; - Object o = getImageDescriptorRegistry().get(resource); - if (o == null) { - //create a descriptor - imageDescriptor = createImageDescriptor(resource); - } - else { - imageDescriptor = (ImageDescriptor) o; - } - return imageDescriptor; - } - - /** - * Returns the image descriptor registry for this plugin. - * - * @return HashMap - image descriptor registry for this plugin - */ - private HashMap getImageDescriptorRegistry() { - if (fImageDescRegistry == null) - fImageDescRegistry = new HashMap(); - return fImageDescRegistry; - } - - /** - * Returns the image registry for this plugin. - * - * @return ImageRegistry - image registry for this plugin - */ - private ImageRegistry getImageRegistry() { - return JFaceResources.getImageRegistry(); - } - - /** - * Creates an image from the given resource and adds the image to the - * image registry. - * - * @param resource - * @return Image - */ - private Image createImage(String resource) { - ImageDescriptor desc = getImageDescriptor(resource); - Image image = null; - - if (desc != null) { - image = desc.createImage(); - // dont add the missing image descriptor image to the image registry - if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) - getImageRegistry().put(resource, image); - } - return image; - } - - /** - * Creates an image descriptor from the given imageFilePath and adds the - * image descriptor to the image descriptor registry. If an image - * descriptor could not be created, the default "missing" image descriptor - * is returned but not added to the image descriptor registry. - * - * @param imageFilePath - * @return ImageDescriptor image descriptor for imageFilePath or default - * "missing" image descriptor if resource could not be found - */ - private ImageDescriptor createImageDescriptor(String imageFilePath) { - ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath); - if (imageDescriptor != null) { - getImageDescriptorRegistry().put(imageFilePath, imageDescriptor); - } - else { - imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); - } - - return imageDescriptor; - } -} |