Lines 25-36
Link Here
|
25 |
import org.eclipse.debug.ui.ILaunchShortcut; |
25 |
import org.eclipse.debug.ui.ILaunchShortcut; |
26 |
import org.eclipse.jdt.core.IJavaElement; |
26 |
import org.eclipse.jdt.core.IJavaElement; |
27 |
import org.eclipse.jdt.core.IType; |
27 |
import org.eclipse.jdt.core.IType; |
28 |
import org.eclipse.jdt.core.JavaModelException; |
|
|
29 |
import org.eclipse.jdt.core.search.SearchEngine; |
30 |
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; |
28 |
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; |
31 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
29 |
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; |
32 |
import org.eclipse.jdt.ui.IJavaElementSearchConstants; |
|
|
33 |
import org.eclipse.jdt.ui.JavaUI; |
34 |
import org.eclipse.jface.dialogs.MessageDialog; |
30 |
import org.eclipse.jface.dialogs.MessageDialog; |
35 |
import org.eclipse.jface.operation.IRunnableContext; |
31 |
import org.eclipse.jface.operation.IRunnableContext; |
36 |
import org.eclipse.jface.viewers.ISelection; |
32 |
import org.eclipse.jface.viewers.ISelection; |
Lines 41-47
Link Here
|
41 |
import org.eclipse.ui.IEditorPart; |
37 |
import org.eclipse.ui.IEditorPart; |
42 |
import org.eclipse.ui.PlatformUI; |
38 |
import org.eclipse.ui.PlatformUI; |
43 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
39 |
import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
44 |
import org.eclipse.ui.dialogs.SelectionDialog; |
|
|
45 |
|
40 |
|
46 |
/** |
41 |
/** |
47 |
* Common behavior for Java launch shortcuts |
42 |
* Common behavior for Java launch shortcuts |
Lines 59-81
Link Here
|
59 |
IType[] types = null; |
54 |
IType[] types = null; |
60 |
try { |
55 |
try { |
61 |
types = findTypes(search, PlatformUI.getWorkbench().getProgressService()); |
56 |
types = findTypes(search, PlatformUI.getWorkbench().getProgressService()); |
62 |
} catch (InterruptedException e) { |
57 |
} |
63 |
return; |
58 |
catch (InterruptedException e) {return;} |
64 |
} catch (CoreException e) { |
59 |
catch (CoreException e) { |
65 |
MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_0, e.getMessage()); |
60 |
MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_0, e.getMessage()); |
66 |
return; |
61 |
return; |
67 |
} |
62 |
} |
68 |
IType type = null; |
63 |
IType type = null; |
69 |
if (types.length == 0) { |
64 |
if (types.length == 0) { |
70 |
MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_1, emptyMessage); |
65 |
MessageDialog.openError(getShell(), LauncherMessages.JavaLaunchShortcut_1, emptyMessage); |
71 |
} else if (types.length > 1) { |
66 |
} |
72 |
try { |
67 |
else if (types.length > 1) { |
73 |
type = chooseType(types, selectMessage); |
68 |
type = chooseType(types, selectMessage); |
74 |
} catch (JavaModelException e) { |
69 |
} |
75 |
reportErorr(e); |
70 |
else { |
76 |
return; |
|
|
77 |
} |
78 |
} else { |
79 |
type = types[0]; |
71 |
type = types[0]; |
80 |
} |
72 |
} |
81 |
if (type != null) { |
73 |
if (type != null) { |
Lines 102-118
Link Here
|
102 |
* |
94 |
* |
103 |
* @return the selected type or <code>null</code> if none. |
95 |
* @return the selected type or <code>null</code> if none. |
104 |
*/ |
96 |
*/ |
105 |
protected IType chooseType(IType[] types, String title) throws JavaModelException { |
97 |
protected IType chooseType(IType[] types, String title) { |
106 |
SelectionDialog dialog = JavaUI.createTypeDialog( |
98 |
MainMethodSelectionDialog mmsd = new MainMethodSelectionDialog(types, new MainMethodLabelProvider(), title, LauncherMessages.JavaMainTab_Choose_a_main__type_to_launch__12); |
107 |
getShell(), |
99 |
if (mmsd.open() == Window.OK) { |
108 |
PlatformUI.getWorkbench().getProgressService(), |
100 |
return (IType)mmsd.getResult()[0]; |
109 |
SearchEngine.createJavaSearchScope(types), |
|
|
110 |
IJavaElementSearchConstants.CONSIDER_CLASSES, |
111 |
false, "**"); //$NON-NLS-1$ |
112 |
dialog.setMessage(LauncherMessages.JavaMainTab_Choose_a_main__type_to_launch__12); |
113 |
dialog.setTitle(title); |
114 |
if (dialog.open() == Window.OK) { |
115 |
return (IType)dialog.getResult()[0]; |
116 |
} |
101 |
} |
117 |
return null; |
102 |
return null; |
118 |
} |
103 |
} |