KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > console > FollowHyperlinkAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.console;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.ui.PlatformUI;
15 import org.eclipse.ui.console.IHyperlink;
16 import org.eclipse.ui.console.TextConsoleViewer;
17
18 /**
19  * Follows a hyperlink in the console
20  *
21  * @since 3.1
22  */

23 public class FollowHyperlinkAction extends Action {
24
25     private TextConsoleViewer viewer;
26
27     /**
28      * Constructs a follow link action
29      */

30     public FollowHyperlinkAction(TextConsoleViewer consoleViewer) {
31         super(ConsoleMessages.FollowHyperlinkAction_0);
32         setToolTipText(ConsoleMessages.FollowHyperlinkAction_1);
33         PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 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 }
56
Popular Tags