1 11 package org.eclipse.pde.internal.ui.search; 12 13 import org.eclipse.jdt.core.IJavaElement; 14 import org.eclipse.jdt.core.JavaModelException; 15 import org.eclipse.jdt.ui.JavaUI; 16 import org.eclipse.jface.action.Action; 17 import org.eclipse.jface.viewers.ISelection; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.pde.core.plugin.IPluginBase; 20 import org.eclipse.pde.core.plugin.IPluginObject; 21 import org.eclipse.pde.internal.ui.editor.plugin.*; 22 import org.eclipse.search.ui.ISearchResultView; 23 import org.eclipse.search.ui.ISearchResultViewEntry; 24 import org.eclipse.search.ui.SearchUI; 25 import org.eclipse.ui.IEditorPart; 26 import org.eclipse.ui.PartInitException; 27 import org.eclipse.ui.ide.*; 28 29 37 public class SearchGoToAction extends Action { 38 39 public SearchGoToAction() { 40 super(); 41 } 42 43 public void run() { 44 try { 45 ISearchResultView view = SearchUI.getSearchResultView(); 46 ISelection selection = view.getSelection(); 47 Object element = null; 48 if (selection instanceof IStructuredSelection) 49 element = ((IStructuredSelection) selection).getFirstElement(); 50 if (element instanceof ISearchResultViewEntry) { 51 ISearchResultViewEntry entry = (ISearchResultViewEntry) element; 52 element = entry.getGroupByKey(); 53 if (element instanceof IJavaElement) { 54 IEditorPart editor = 55 JavaUI.openInEditor((IJavaElement) element); 56 IDE.gotoMarker(editor, entry.getSelectedMarker()); 57 } else if (element instanceof IPluginObject) { 58 IPluginObject object = (IPluginObject) element; 59 if (object instanceof IPluginBase) { 60 ManifestEditor.openPluginEditor((IPluginBase) object); 61 } else { 62 ManifestEditor.openPluginEditor( 63 object.getPluginBase(), 64 object, 65 entry.getSelectedMarker()); 66 } 67 } 68 } 69 } catch (PartInitException e) { 70 } catch (JavaModelException e) { 71 } 72 } 73 74 75 } 76 | Popular Tags |