Here you can find the source of getUrl(String pluginId, String relativePath)
Parameter | Description |
---|---|
pluginId | the identifier for the plug-in |
relativePath | the relative path of the file within the installation directory |
public static URL getUrl(String pluginId, String relativePath)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 Google, Inc.//from ww w .j a va2 s .c om * 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: * Google, Inc. - initial API and implementation *******************************************************************************/ import java.net.URL; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Plugin; import org.osgi.framework.Bundle; public class Main { /** * Return an URL for the file located within the installation directory of the plug-in that has * the given identifier that has the given relative path. * * @param pluginId * the identifier for the plug-in * @param relativePath * the relative path of the file within the installation directory * * @return the URL for the specified file */ public static URL getUrl(String pluginId, String relativePath) { Bundle bundle; if (pluginId == null || relativePath == null) { return null; } bundle = Platform.getBundle(pluginId); if (bundle != null) { return bundle.getEntry(relativePath); } return null; } /** * Return an URL for the file located within the installation directory of the given plug-in that * has the given relative path. * * @param pluginId * the identifier for the plug-in * @param relativePath * the relative path of the file within the installation directory * * @return the URL for the specified file */ public static URL getUrl(Plugin plugin, String relativePath) { if (plugin == null || relativePath == null) { return null; } return plugin.getBundle().getEntry(relativePath); } }