1 package org.hibernate.eclipse.mapper.editors; 2 3 import org.eclipse.jdt.core.IJavaElement; 4 import org.eclipse.jdt.core.JavaModelException; 5 import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; 6 import org.eclipse.jface.text.IRegion; 7 import org.eclipse.jface.text.hyperlink.IHyperlink; 8 import org.eclipse.ui.IEditorPart; 9 import org.eclipse.ui.PartInitException; 10 11 public class HBMXMLHyperlink implements IHyperlink { 12 13 private final IRegion region; 14 private IJavaElement element; 15 16 public HBMXMLHyperlink(IRegion region, IJavaElement element) { 17 this.region = region; 19 this.element = element; 20 } 21 22 public IRegion getHyperlinkRegion() { 23 return region; 24 } 25 26 public String getTypeLabel() { 27 return null; 28 } 29 30 public String getHyperlinkText() { 31 return null; 32 } 33 34 public void open() { 35 try { 36 IEditorPart part = EditorUtility.openInEditor(element, true); 37 if(part!=null) { 38 EditorUtility.revealInEditor(part, element); 39 } 40 } catch (JavaModelException e) { 41 e.printStackTrace(); 43 } catch (PartInitException e) { 44 e.printStackTrace(); 46 } 47 } 48 49 public String toString() { 50 return "HBMXML hyperlink: " + element; 51 } 52 53 54 } 55 | Popular Tags |