KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > part > services > PluginResources


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.part.services;
12
13 import java.io.File JavaDoc;
14 import java.net.URL JavaDoc;
15
16 import org.eclipse.core.runtime.Path;
17 import org.eclipse.core.runtime.Platform;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.ui.internal.part.components.services.IPluginResources;
20 import org.osgi.framework.Bundle;
21
22 /**
23  * @since 3.1
24  */

25 public class PluginResources implements IPluginResources {
26
27     private Bundle bundle;
28     
29     public PluginResources(Bundle pluginBundle) {
30         bundle = pluginBundle;
31     }
32     
33     /* (non-Javadoc)
34      * @see org.eclipse.ui.workbench.services.IPluginImages#getImage(java.lang.String)
35      */

36     public ImageDescriptor getImage(String JavaDoc path) {
37         return ImageDescriptor.createFromURL(getPluginURL(path));
38     }
39     
40     /* (non-Javadoc)
41      * @see org.eclipse.ui.internal.part.components.services.IPluginResources#getPluginFile(java.lang.String)
42      */

43     public URL JavaDoc getPluginURL(String JavaDoc path) {
44         return Platform.find(bundle, new Path(path));
45     }
46     
47     /* (non-Javadoc)
48      * @see org.eclipse.ui.internal.part.components.services.IPluginResources#getStateFile(java.lang.String)
49      */

50     public File JavaDoc getStateFile(String JavaDoc path) {
51         return Platform.getStateLocation(bundle).append(path).toFile();
52     }
53
54 }
55
Popular Tags