Mercurial > hg > thermostat-tools-eclipse
changeset 20:48d068992070
Make hyperlinks in Overview page work
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Tue, 03 Dec 2013 17:07:28 -0500 |
parents | e3a95c4f2ea6 |
children | 540c47958d9c |
files | src/thermostatplugin/editors/MultiPageEditor.java |
diffstat | 1 files changed, 35 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/thermostatplugin/editors/MultiPageEditor.java Tue Dec 03 16:47:54 2013 -0500 +++ b/src/thermostatplugin/editors/MultiPageEditor.java Tue Dec 03 17:07:28 2013 -0500 @@ -1,5 +1,7 @@ package thermostatplugin.editors; +import java.net.MalformedURLException; +import java.net.URL; import java.util.HashMap; import org.eclipse.core.resources.IMarker; @@ -31,7 +33,11 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.Form; import org.eclipse.ui.forms.widgets.FormText; import org.eclipse.ui.forms.widgets.FormToolkit; @@ -112,6 +118,17 @@ + "</p>" + "</form>"; helpText.setText(onlineHelp, true, false); + helpText.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + String href = (String) e.getHref(); + try { + PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(href)); + } catch (PartInitException | MalformedURLException e1) { + e1.printStackTrace(); + } + } + }); section.setClient(sectionData); } @@ -126,12 +143,27 @@ FormText commandAndExtensionsForm = toolkit.createFormText(sectionData, false); String formContents = "" + "<form>" - + "<p>Plugins provide extends or new commands.</p>" - + "<li><a href=\"my:extensions\">Extensions</a>: declares which commands provided by other plugins or thermostat itself should be extended</li>" - + "<li><a href=\"my:commands\">Commands</a>: declares new commands provided by this plugin</li>" + + "<p>Plugins provide new commands or extend existing ones.</p>" + + "<li><a href=\"commands\">Commands</a>: declares new commands provided by this plugin</li>" + + "<li><a href=\"extensions\">Extensions</a>: declares which commands provided by other plugins or thermostat itself should be extended</li>" + "</form>"; commandAndExtensionsForm.setText(formContents, true, false); + commandAndExtensionsForm.addHyperlinkListener(new HyperlinkAdapter() { + @Override + public void linkActivated(HyperlinkEvent e) { + String href = (String) e.getHref(); + switch(href) { + case "commands": + setActivePage(1); + break; + case "extensions": + setActivePage(2); + break; + } + } + }); + section.setClient(sectionData); }