1 11 package org.eclipse.debug.internal.ui.actions; 12 13 14 import org.eclipse.debug.internal.ui.DebugUIPlugin; 15 import org.eclipse.debug.ui.console.IConsoleHyperlink; 16 import org.eclipse.jface.action.IStatusLineManager; 17 import org.eclipse.jface.text.ITextSelection; 18 import org.eclipse.jface.viewers.ISelection; 19 import org.eclipse.jface.viewers.ISelectionProvider; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 import org.eclipse.ui.IActionBars; 22 23 28 public class KeyBindingFollowHyperlinkAction extends FollowHyperlinkAction { 29 30 private boolean fSelectionNotAHyperlink = false; 31 private IActionBars fActionBars; 32 33 public KeyBindingFollowHyperlinkAction(ISelectionProvider selectionProvider, IActionBars actionBars) { 34 super(selectionProvider); 35 fActionBars = actionBars; 36 } 37 38 41 public void run() { 42 IConsoleHyperlink link = getHyperLink(); 43 if (link == null) { 44 IStatusLineManager statusLine= getStatusLineManager(); 45 if (statusLine != null) { 46 statusLine.setErrorMessage(ActionMessages.getString("KeyBindingFollowHyperLinkAction.No_hyperlink")); fSelectionNotAHyperlink = true; 48 } 49 DebugUIPlugin.getStandardDisplay().beep(); 50 } else { 51 link.linkActivated(); 52 fSelectionNotAHyperlink = false; 53 } 54 } 55 56 public void clearStatusLine() { 57 if (fSelectionNotAHyperlink) { 58 IStatusLineManager statusLine= getStatusLineManager(); 59 if (statusLine != null) { 60 statusLine.setErrorMessage(null); 61 fSelectionNotAHyperlink = false; 62 } 63 } 64 } 65 66 69 public void selectionChanged(ISelection selection) { 70 if (isEmptySelection(selection)) { 71 clearStatusLine(); 72 } 73 } 74 75 78 public void selectionChanged(IStructuredSelection selection) { 79 selectionChanged((ISelection)selection); 80 } 81 82 87 protected boolean isEmptySelection(ISelection selection) { 88 if (selection instanceof ITextSelection) { 89 return ((ITextSelection)selection).getLength() < 1; 90 } 91 return selection.isEmpty(); 92 } 93 94 97 protected IStatusLineManager getStatusLineManager() { 98 return fActionBars.getStatusLineManager(); 99 } 100 101 } 102 | Popular Tags |