Bug 281145 – [CheatSheet] Simple mechanism to publish internal resources of cheatsheet plugin via http urls:
diff --git a/bundles/org.eclipse.ui.browser/plugin.properties b/bundles/org.eclipse.ui.browser/plugin.properties
index 8b21ac5..d8067b8 100644
--- a/bundles/org.eclipse.ui.browser/plugin.properties
+++ b/bundles/org.eclipse.ui.browser/plugin.properties
@@ -26,6 +26,11 @@
 commandParameter.openBrowser.name.name=Browser Name
 commandParameter.openBrowser.tooltip.name=Browser Tooltip
 
+command.openBundleResource.name=Open Resource in Browser
+command.openBundleResource.description=Opens a bundle resource in the default web browser.
+commandParameter.openBundleResource.plugin.name=Plugin
+commandParameter.openBundleResource.path.name=Path
+
 browserInternetExplorer=Internet Explorer
 browserNetscape4=Netscape Communicator v4.x
 browserNetscape7=Netscape v7.x
diff --git a/bundles/org.eclipse.ui.browser/plugin.xml b/bundles/org.eclipse.ui.browser/plugin.xml
index 07866ff..6e21252 100644
--- a/bundles/org.eclipse.ui.browser/plugin.xml
+++ b/bundles/org.eclipse.ui.browser/plugin.xml
Binary files differ
diff --git a/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/OpenBundleResourceHandler.java b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/OpenBundleResourceHandler.java
new file mode 100644
index 0000000..34486ad
--- /dev/null
+++ b/bundles/org.eclipse.ui.browser/src/org/eclipse/ui/internal/browser/OpenBundleResourceHandler.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.ui.internal.browser;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.URL;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.browser.IWebBrowser;
+import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.osgi.framework.Bundle;
+
+public class OpenBundleResourceHandler extends AbstractHandler {
+
+	private static final String PARAM_ID_PLUGIN = "plugin"; //$NON-NLS-1$
+
+	private static final String PARAM_ID_PATH = "path"; //$NON-NLS-1$
+
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+
+		String pluginId = event.getParameter(PARAM_ID_PLUGIN);
+		String pluginPath = event.getParameter(PARAM_ID_PATH);
+		URL url;
+		File workspaceFile;
+		Bundle bundle;
+		String errorMessage=""; //$NON-NLS-1$
+		if (pluginId == null || pluginPath==null) {
+			url = null;
+		} else {
+			try {
+				if(pluginPath.startsWith("/")) //$NON-NLS-1$
+					pluginPath = pluginPath.substring(1);
+				url = new URL(Platform.getInstanceLocation().getURL().toString()+pluginId+"/"+pluginPath); //$NON-NLS-1$
+				workspaceFile = new File(url.getFile());	
+				if(!workspaceFile.exists())
+				{	
+					bundle = Platform.getBundle(pluginId);
+					if (bundle != null) {
+						url=FileLocator.toFileURL(new URL(bundle.getEntry("/"), pluginPath)); //$NON-NLS-1$
+						if (url == null) {
+							errorMessage="file not found:" + pluginId+"/"+pluginPath; //$NON-NLS-1$ //$NON-NLS-2$
+							throw new ExecutionException(errorMessage);
+						}
+					}
+					else
+					{
+						errorMessage = "plugin not found:" + pluginId; //$NON-NLS-1$
+						throw new ExecutionException(errorMessage);
+					}
+				}
+			} catch(FileNotFoundException ex){
+				errorMessage="file not found:" + pluginId+"/"+pluginPath; //$NON-NLS-1$ //$NON-NLS-2$
+				throw new ExecutionException(errorMessage);
+			}
+			catch (Exception ex) {
+				throw new ExecutionException(errorMessage, ex);
+			}
+		}
+
+		String browserId = pluginId+"."+pluginPath; //$NON-NLS-1$
+		try {
+			IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench()
+					.getBrowserSupport();
+			
+			IWebBrowser browser = browserSupport.createBrowser(browserId); 
+			browser.openURL(url);
+		} catch (PartInitException ex) {
+			throw new ExecutionException("error opening browser", ex); //$NON-NLS-1$
+		}
+
+		return null;
+	}
+}