upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / editor / CElementHyperlink.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2010 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.cdt.internal.ui.editor;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.text.IRegion;
17 import org.eclipse.jface.text.hyperlink.IHyperlink;
18
19
20 /**
21  * C element hyperlink.
22  * 
23  * @since 3.0
24  */
25 public class CElementHyperlink implements IHyperlink {
26
27         private final IRegion fRegion;
28         private final IAction fOpenAction;
29
30         
31         /**
32          * Creates a new C element hyperlink.
33          */
34         public CElementHyperlink(IRegion region, IAction openAction) {
35                 Assert.isNotNull(openAction);
36                 Assert.isNotNull(region);
37                 
38                 fRegion= region;
39                 fOpenAction= openAction;
40         }
41         
42         public IRegion getHyperlinkRegion() {
43                 return fRegion;
44         }
45
46         public void open() {
47                 fOpenAction.run();
48         }
49
50         public String getTypeLabel() {
51                 return null;
52         }
53
54         public String getHyperlinkText() {
55                 return Action.removeMnemonics(fOpenAction.getText());
56         }
57 }