| author | Steffen Pingel | 2012-02-04 13:31:31 (EST) |
|---|---|---|
| committer | Steffen Pingel | 2012-02-04 13:31:31 (EST) |
| commit | 6a4dc7d4dadd7f6fe4623ba95464241e4d2d0bd0 (patch) (side-by-side diff) | |
| tree | a26d2028283c13dd667f3c44bbb225ee7117e256 | |
| parent | 0d72d2121e5fc832f8b1add058b323b6752bcbc0 (diff) | |
| download | org.eclipse.mylyn.commons-6a4dc7d4dadd7f6fe4623ba95464241e4d2d0bd0.zip org.eclipse.mylyn.commons-6a4dc7d4dadd7f6fe4623ba95464241e4d2d0bd0.tar.gz org.eclipse.mylyn.commons-6a4dc7d4dadd7f6fe4623ba95464241e4d2d0bd0.tar.bz2 | |
RESOLVED - bug 346046: [api] provide an extension point for registering
URL handlers (was: Hyperlinks to builds should open in task editor)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=346046
Change-Id: I7aa136d99e1e6c3f7a8c046e089316d5c09438b7
| -rw-r--r-- | org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/browser/UrlHyperlink.java | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/browser/UrlHyperlink.java b/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/browser/UrlHyperlink.java new file mode 100644 index 0000000..52b2f59 --- a/dev/null +++ b/org.eclipse.mylyn.commons.workbench/src/org/eclipse/mylyn/commons/workbench/browser/UrlHyperlink.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2012 Tasktop Technologies 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: + * Tasktop Technologies - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylyn.commons.workbench.browser; + +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.hyperlink.URLHyperlink; +import org.eclipse.osgi.util.NLS; + +/** + * A link to a url that opens in a rich editor, if available, or browser, otherwise. + * + * @author Steffen Pingel + * @see BrowserUtil#openUrl(String) + */ +public class UrlHyperlink extends URLHyperlink { + + private final String tooltip; + + /** + * Constructs a hyperlink with a custom tooltip. + * + * @param region + * the region to highlight + * @param url + * the URL to open + * @param tooltip + * a tooltip, maybe <code>null</code> + * @see URLHyperlink#URLHyperlink(IRegion, String) + */ + public UrlHyperlink(IRegion region, String url, String tooltip) { + super(region, url); + this.tooltip = tooltip; + } + + /** + * Constructs a hyperlink + * + * @param region + * the region to highlight + * @param url + * the URL to open + * @see URLHyperlink#URLHyperlink(IRegion, String) + */ + public UrlHyperlink(IRegion region, String url) { + this(region, url, null); + } + + @Override + public void open() { + BrowserUtil.openUrl(getURLString()); + } + + @Override + public String getHyperlinkText() { + if (tooltip != null) { + return tooltip; + } + return NLS.bind("Open ''{0}''", getURLString()); //$NON-NLS-1$ + } + +} |

