KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > registry > ProjectImageRegistry


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.ide.registry;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import org.eclipse.core.runtime.Platform;
17 import org.eclipse.jface.resource.ImageDescriptor;
18
19 /**
20  * Registry to hold mappings from project natures to images
21  */

22
23 public class ProjectImageRegistry {
24     private Map JavaDoc map = new HashMap JavaDoc(10);
25
26     /**
27      * Returns the image for the given nature id or
28      * <code>null</code> if no image is registered for the given id
29      */

30     public ImageDescriptor getNatureImage(String JavaDoc natureId) {
31         return (ImageDescriptor) map.get(natureId);
32     }
33
34     /**
35      * Reads from the plugin registry.
36      */

37     public void load() {
38         ProjectImageRegistryReader reader = new ProjectImageRegistryReader();
39         reader.readProjectNatureImages(Platform.getExtensionRegistry(), this);
40     }
41
42     /**
43      * Sets the image for the given nature id
44      */

45     public void setNatureImage(String JavaDoc natureId, ImageDescriptor image) {
46         map.put(natureId, image);
47     }
48 }
49
Popular Tags