1 11 package org.eclipse.debug.internal.ui.actions; 12 13 14 import org.eclipse.debug.internal.ui.DebugUIPlugin; 15 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 16 import org.eclipse.debug.internal.ui.views.console.ConsoleViewer; 17 import org.eclipse.debug.ui.console.IConsoleHyperlink; 18 import org.eclipse.jface.text.ITextSelection; 19 import org.eclipse.jface.viewers.ISelectionProvider; 20 import org.eclipse.ui.ISharedImages; 21 import org.eclipse.ui.actions.SelectionProviderAction; 22 import org.eclipse.ui.help.WorkbenchHelp; 23 import org.eclipse.ui.ide.IDE; 24 25 28 public class FollowHyperlinkAction extends SelectionProviderAction { 29 30 33 public FollowHyperlinkAction(ISelectionProvider selectionProvider) { 34 super(selectionProvider, ActionMessages.getString("FollowHyperlinkAction.&Open_Link_1")); setToolTipText(ActionMessages.getString("FollowHyperlinkAction.Follow_the_selected_hyperlink._2")); ISharedImages images= DebugUIPlugin.getDefault().getWorkbench().getSharedImages(); 37 setImageDescriptor(images.getImageDescriptor(IDE.SharedImages.IMG_OPEN_MARKER)); 38 WorkbenchHelp.setHelp( 39 this, 40 IDebugHelpContextIds.FOLLOW_CONSOLE_HYPERLINK_ACTION); 41 } 42 43 public IConsoleHyperlink getHyperLink() { 44 ISelectionProvider selectionProvider = getSelectionProvider(); 45 if (selectionProvider instanceof ConsoleViewer) { 46 ITextSelection textSelection = (ITextSelection)selectionProvider.getSelection(); 47 ConsoleViewer consoleViewer = (ConsoleViewer)selectionProvider; 48 if (textSelection != null) { 49 return consoleViewer.getHyperlink(textSelection.getOffset()); 50 } 51 } 52 return null; 53 } 54 55 58 public void run() { 59 IConsoleHyperlink link = getHyperLink(); 60 if (link != null) { 61 link.linkActivated(); 62 } 63 } 64 65 } 66 | Popular Tags |