KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > AntElementHyperlinkDetector


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.ant.internal.ui.editor;
12
13 import org.eclipse.ant.internal.ui.editor.text.XMLTextHover;
14 import org.eclipse.jface.text.IRegion;
15 import org.eclipse.jface.text.ITextViewer;
16 import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
17 import org.eclipse.jface.text.hyperlink.IHyperlink;
18
19 public class AntElementHyperlinkDetector extends AbstractHyperlinkDetector {
20
21     private AntEditor fEditor;
22     
23     public AntElementHyperlinkDetector() {
24     }
25
26     /* (non-Javadoc)
27      * @see org.eclipse.jface.text.hyperlink.IHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean)
28      */

29     public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
30          if (region == null) {
31             return null;
32         }
33         fEditor = (AntEditor) getAdapter(AntEditor.class);
34         region= XMLTextHover.getRegion(textViewer, region.getOffset());
35         Object JavaDoc linkTarget= fEditor.findTarget(region);
36         if (linkTarget == null) {
37             return null;
38         }
39         return new IHyperlink[] {new AntElementHyperlink(fEditor, region, linkTarget)};
40     }
41 }
42
Popular Tags