01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.console;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.PlatformUI;
14: import org.eclipse.ui.console.IHyperlink;
15: import org.eclipse.ui.console.TextConsoleViewer;
16:
17: /**
18: * Follows a hyperlink in the console
19: *
20: * @since 3.1
21: */
22: public class FollowHyperlinkAction extends Action {
23:
24: private TextConsoleViewer viewer;
25:
26: /**
27: * Constructs a follow link action
28: */
29: public FollowHyperlinkAction(TextConsoleViewer consoleViewer) {
30: super (ConsoleMessages.FollowHyperlinkAction_0);
31: setToolTipText(ConsoleMessages.FollowHyperlinkAction_1);
32: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
33: IConsoleHelpContextIds.CONSOLE_OPEN_LINK_ACTION);
34: this .viewer = consoleViewer;
35: }
36:
37: /* (non-Javadoc)
38: * @see org.eclipse.jface.action.IAction#isEnabled()
39: */
40: public boolean isEnabled() {
41: return viewer.getHyperlink() != null;
42: }
43:
44: /*
45: * (non-Javadoc)
46: * @see org.eclipse.jface.action.IAction#run()
47: */
48: public void run() {
49: IHyperlink link = viewer.getHyperlink();
50: if (link != null) {
51: link.linkActivated();
52: }
53: }
54:
55: }
|