Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 7-12
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Francis Upton IV, Oakland Software bug 262097 [common navigator] Goto Type and |
11 |
* Goto Package not enabled in ProjectExplorer |
10 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.internal.ui.packageview; |
13 |
package org.eclipse.jdt.internal.ui.packageview; |
12 |
|
14 |
|
Lines 19-26
Link Here
|
19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
21 |
import org.eclipse.jface.viewers.IStructuredSelection; |
20 |
import org.eclipse.jface.viewers.StructuredSelection; |
22 |
import org.eclipse.jface.viewers.StructuredSelection; |
21 |
|
23 |
|
|
|
24 |
import org.eclipse.ui.IViewPart; |
25 |
import org.eclipse.ui.PartInitException; |
22 |
import org.eclipse.ui.PlatformUI; |
26 |
import org.eclipse.ui.PlatformUI; |
23 |
import org.eclipse.ui.dialogs.SelectionDialog; |
27 |
import org.eclipse.ui.dialogs.SelectionDialog; |
|
|
28 |
import org.eclipse.ui.part.ISetSelectionTarget; |
24 |
|
29 |
|
25 |
import org.eclipse.jdt.core.ICompilationUnit; |
30 |
import org.eclipse.jdt.core.ICompilationUnit; |
26 |
import org.eclipse.jdt.core.IJavaElement; |
31 |
import org.eclipse.jdt.core.IJavaElement; |
Lines 38-52
Link Here
|
38 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
43 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
39 |
import org.eclipse.jdt.internal.ui.util.ExceptionHandler; |
44 |
import org.eclipse.jdt.internal.ui.util.ExceptionHandler; |
40 |
|
45 |
|
41 |
class GotoTypeAction extends Action { |
46 |
public class GotoTypeAction extends Action { |
42 |
|
47 |
|
43 |
private PackageExplorerPart fPackageExplorer; |
48 |
private IViewPart fExplorer; |
44 |
|
49 |
|
45 |
GotoTypeAction(PackageExplorerPart part) { |
50 |
public GotoTypeAction(IViewPart part) { |
46 |
super(); |
51 |
super(); |
47 |
setText(PackagesMessages.GotoType_action_label); |
52 |
setText(PackagesMessages.GotoType_action_label); |
48 |
setDescription(PackagesMessages.GotoType_action_description); |
53 |
setDescription(PackagesMessages.GotoType_action_description); |
49 |
fPackageExplorer= part; |
54 |
fExplorer= part; |
50 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION); |
55 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_TYPE_ACTION); |
51 |
} |
56 |
} |
52 |
|
57 |
|
Lines 85-103
Link Here
|
85 |
element= type.getAncestor(IJavaElement.CLASS_FILE); |
90 |
element= type.getAncestor(IJavaElement.CLASS_FILE); |
86 |
} |
91 |
} |
87 |
if (element != null) { |
92 |
if (element != null) { |
88 |
PackageExplorerPart view= PackageExplorerPart.openInActivePerspective(); |
93 |
try { |
89 |
if (view != null) { |
94 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(fExplorer.getViewSite().getId()); |
90 |
view.selectReveal(new StructuredSelection(element)); |
95 |
} catch (PartInitException e) { |
91 |
if (!element.equals(getSelectedElement(view))) { |
96 |
return; |
92 |
MessageDialog.openInformation(fPackageExplorer.getSite().getShell(), |
97 |
} |
93 |
getDialogTitle(), |
98 |
((ISetSelectionTarget)fExplorer).selectReveal(new StructuredSelection(element)); |
94 |
Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT))); |
99 |
if (!element.equals(getSelectedElement(fExplorer))) { |
95 |
} |
100 |
MessageDialog.openInformation(fExplorer.getSite().getShell(), |
|
|
101 |
getDialogTitle(), |
102 |
Messages.format(PackagesMessages.PackageExplorer_element_not_present, JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT))); |
96 |
} |
103 |
} |
97 |
} |
104 |
} |
98 |
} |
105 |
} |
99 |
|
106 |
|
100 |
private Object getSelectedElement(PackageExplorerPart view) { |
107 |
private Object getSelectedElement(IViewPart view) { |
101 |
return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement(); |
108 |
return ((IStructuredSelection)view.getSite().getSelectionProvider().getSelection()).getFirstElement(); |
102 |
} |
109 |
} |
103 |
|
110 |
|