Lines 12-17
Link Here
|
12 |
|
12 |
|
13 |
import org.eclipse.core.runtime.CoreException; |
13 |
import org.eclipse.core.runtime.CoreException; |
14 |
|
14 |
|
|
|
15 |
import org.eclipse.core.resources.ResourcesPlugin; |
16 |
|
15 |
import org.eclipse.swt.widgets.Shell; |
17 |
import org.eclipse.swt.widgets.Shell; |
16 |
|
18 |
|
17 |
import org.eclipse.jface.action.Action; |
19 |
import org.eclipse.jface.action.Action; |
Lines 24-31
Link Here
|
24 |
import org.eclipse.ui.IWorkbenchWindowActionDelegate; |
26 |
import org.eclipse.ui.IWorkbenchWindowActionDelegate; |
25 |
import org.eclipse.ui.PlatformUI; |
27 |
import org.eclipse.ui.PlatformUI; |
26 |
|
28 |
|
|
|
29 |
import org.eclipse.jdt.core.IJavaModel; |
30 |
import org.eclipse.jdt.core.IJavaProject; |
27 |
import org.eclipse.jdt.core.IType; |
31 |
import org.eclipse.jdt.core.IType; |
|
|
32 |
import org.eclipse.jdt.core.JavaCore; |
33 |
import org.eclipse.jdt.core.JavaModelException; |
28 |
import org.eclipse.jdt.core.search.IJavaSearchConstants; |
34 |
import org.eclipse.jdt.core.search.IJavaSearchConstants; |
|
|
35 |
import org.eclipse.jdt.core.search.SearchEngine; |
29 |
|
36 |
|
30 |
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; |
37 |
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; |
31 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
38 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
Lines 47-74
Link Here
|
47 |
} |
54 |
} |
48 |
|
55 |
|
49 |
public void run() { |
56 |
public void run() { |
50 |
Shell parent= JavaPlugin.getActiveWorkbenchShell(); |
57 |
try { |
51 |
OpenTypeSelectionDialog2 dialog= new OpenTypeSelectionDialog2(parent, false, |
58 |
Shell parent= JavaPlugin.getActiveWorkbenchShell(); |
52 |
PlatformUI.getWorkbench().getProgressService(), |
59 |
IJavaModel model= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); |
53 |
null, IJavaSearchConstants.TYPE); |
60 |
IJavaProject p= model.getJavaProject("XX"); |
54 |
dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle); |
61 |
IType tt= p.findType("java.lang.Throwable"); |
55 |
dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage); |
62 |
OpenTypeSelectionDialog2 dialog= new OpenTypeSelectionDialog2(parent, false, |
56 |
|
63 |
PlatformUI.getWorkbench().getProgressService(), |
57 |
int result= dialog.open(); |
64 |
SearchEngine.createHierarchyScope(tt), |
58 |
if (result != IDialogConstants.OK_ID) |
65 |
IJavaSearchConstants.TYPE); |
59 |
return; |
66 |
dialog.setTitle(JavaUIMessages.OpenTypeAction_dialogTitle); |
60 |
|
67 |
dialog.setMessage(JavaUIMessages.OpenTypeAction_dialogMessage); |
61 |
Object[] types= dialog.getResult(); |
68 |
|
62 |
if (types != null && types.length > 0) { |
69 |
int result= dialog.open(); |
63 |
IType type= (IType)types[0]; |
70 |
if (result != IDialogConstants.OK_ID) |
64 |
try { |
71 |
return; |
65 |
IEditorPart part= EditorUtility.openInEditor(type, true); |
72 |
|
66 |
EditorUtility.revealInEditor(part, type); |
73 |
Object[] types= dialog.getResult(); |
67 |
} catch (CoreException x) { |
74 |
if (types != null && types.length > 0) { |
68 |
String title= JavaUIMessages.OpenTypeAction_errorTitle; |
75 |
IType type= (IType)types[0]; |
69 |
String message= JavaUIMessages.OpenTypeAction_errorMessage; |
76 |
try { |
70 |
ExceptionHandler.handle(x, title, message); |
77 |
IEditorPart part= EditorUtility.openInEditor(type, true); |
|
|
78 |
EditorUtility.revealInEditor(part, type); |
79 |
} catch (CoreException x) { |
80 |
String title= JavaUIMessages.OpenTypeAction_errorTitle; |
81 |
String message= JavaUIMessages.OpenTypeAction_errorMessage; |
82 |
ExceptionHandler.handle(x, title, message); |
83 |
} |
71 |
} |
84 |
} |
|
|
85 |
} catch (JavaModelException e) { |
86 |
// TODO Auto-generated catch block |
87 |
e.printStackTrace(); |
72 |
} |
88 |
} |
73 |
} |
89 |
} |
74 |
|
90 |
|