1 11 12 package org.eclipse.ui.internal.navigator.resources.workbench; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.jface.viewers.IStructuredSelection; 16 import org.eclipse.jface.viewers.StructuredSelection; 17 import org.eclipse.ui.IEditorInput; 18 import org.eclipse.ui.IEditorPart; 19 import org.eclipse.ui.IWorkbenchPage; 20 import org.eclipse.ui.ide.ResourceUtil; 21 import org.eclipse.ui.navigator.ILinkHelper; 22 import org.eclipse.ui.part.FileEditorInput; 23 24 31 public class ResourceLinkHelper implements ILinkHelper { 32 33 36 public IStructuredSelection findSelection(IEditorInput anInput) { 37 IFile file = ResourceUtil.getFile(anInput); 38 if (file != null) { 39 return new StructuredSelection(file); 40 } 41 return StructuredSelection.EMPTY; 42 } 43 44 47 public void activateEditor(IWorkbenchPage aPage, 48 IStructuredSelection aSelection) { 49 if (aSelection == null || aSelection.isEmpty()) 50 return; 51 if (aSelection.getFirstElement() instanceof IFile) { 52 IEditorInput fileInput = new FileEditorInput((IFile) aSelection.getFirstElement()); 53 IEditorPart editor = null; 54 if ((editor = aPage.findEditor(fileInput)) != null) 55 aPage.bringToTop(editor); 56 } 57 58 } 59 60 } 61 | Popular Tags |