KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > SearchGoToAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
30  * @author W Melhem
31  *
32  * To change this generated comment edit the template variable "typecomment":
33  * Window>Preferences>Java>Templates.
34  * To enable and disable the creation of type comments go to
35  * Window>Preferences>Java>Code Generation.
36  */

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 JavaDoc 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