01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.ide.registry;
11:
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: import org.eclipse.core.runtime.Platform;
16: import org.eclipse.jface.resource.ImageDescriptor;
17:
18: /**
19: * Registry to hold mappings from project natures to images
20: */
21:
22: public class ProjectImageRegistry {
23: private Map map = new HashMap(10);
24:
25: /**
26: * Returns the image for the given nature id or
27: * <code>null</code> if no image is registered for the given id
28: */
29: public ImageDescriptor getNatureImage(String natureId) {
30: return (ImageDescriptor) map.get(natureId);
31: }
32:
33: /**
34: * Reads from the plugin registry.
35: */
36: public void load() {
37: ProjectImageRegistryReader reader = new ProjectImageRegistryReader();
38: reader.readProjectNatureImages(Platform.getExtensionRegistry(),
39: this );
40: }
41:
42: /**
43: * Sets the image for the given nature id
44: */
45: public void setNatureImage(String natureId, ImageDescriptor image) {
46: map.put(natureId, image);
47: }
48: }
|