Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2007 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 Contributors: IBM Corporation - initial API and implementation /
Action that launches a URL in a browser.

This class is intended to be specified as a value of a class attribute of an action element in plugin.xml for extensions of org.eclipse.ui.actionSets extension point. The URL to launch must be specified in the markup in one of two ways.

The action element can have an attribute named url, in addition to markup required by org.eclipse.ui.actionSets extension point specification. The value of the url attribute should specify a URL to be opened in a browser. Alternatively, since 3.1, instead of a class attribute on the action element, the extension can specify a nested class element with a class attribute and URL specified in a parameter sub-element. For example:
         <class class="">
              <parameter name="url" value="" />
public class LaunchURL implements IWorkbenchWindowActionDelegate,
	private String url;

	public void dispose() {

	public void init(IWorkbenchWindow window) {

			String propertyNameObject datathrows CoreException {
		if (data != null && data instanceof Hashtable) {
			 = (String) ((Hashtabledata).get("url"); //$NON-NLS-1$
		if ( == null || .length() == 0)
			 = config.getAttribute("url"); //$NON-NLS-1$

	public void run(IAction action) {
		if ( == null || "".equals()) { //$NON-NLS-1$
		IBrowser browser = BrowserManager.getInstance().createBrowser(true);
		try {
catch (Exception e) {
			HelpUIPlugin.logError("Exception occurred when opening URL: " +  //$NON-NLS-1$
"."e); //$NON-NLS-1$

	public void selectionChanged(IAction actionISelection selection) {
New to GrepCode? Check out our FAQ X