1 11 package org.eclipse.pde.internal.ui.editor.text; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.jdt.ui.IPackagesViewPart; 16 import org.eclipse.jdt.ui.JavaUI; 17 import org.eclipse.jface.text.IRegion; 18 import org.eclipse.pde.internal.ui.PDEPlugin; 19 import org.eclipse.ui.PartInitException; 20 import org.eclipse.ui.ide.IDE; 21 22 public class ResourceHyperlink extends AbstractHyperlink { 23 24 private IResource fResource; 25 26 public ResourceHyperlink(IRegion region, String element, IResource res) { 27 super(region, element); 28 fResource = res; 29 } 30 31 public void open() { 32 if (fResource == null) 33 return; 34 if (fElement.indexOf("$nl$/") == 0) fElement = fElement.substring(5); 36 fResource = fResource.getProject().findMember(fElement); 37 try { 38 if (fResource instanceof IFile) 39 IDE.openEditor(PDEPlugin.getActivePage(), (IFile)fResource, true); 40 else if (fResource != null) { 41 IPackagesViewPart part = (IPackagesViewPart)PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES); 42 part.selectAndReveal(fResource); 43 } 44 } catch (PartInitException e) { 45 PDEPlugin.logException(e); 46 } 47 } 48 49 } 50 | Popular Tags |