1 11 package org.eclipse.jdt.internal.ui.dialogs; 12 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.runtime.Assert; 17 18 import org.eclipse.swt.widgets.Shell; 19 20 import org.eclipse.jface.operation.IRunnableContext; 21 22 import org.eclipse.ui.dialogs.ElementListSelectionDialog; 23 import org.eclipse.ui.PlatformUI; 24 25 import org.eclipse.jdt.core.IType; 26 import org.eclipse.jdt.core.search.IJavaSearchScope; 27 28 import org.eclipse.jdt.ui.JavaElementLabelProvider; 29 30 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 31 import org.eclipse.jdt.internal.ui.JavaUIMessages; 32 import org.eclipse.jdt.internal.ui.util.ExceptionHandler; 33 import org.eclipse.jdt.internal.ui.util.MainMethodSearchEngine; 34 35 39 public class MultiMainTypeSelectionDialog extends ElementListSelectionDialog { 40 41 private IRunnableContext fRunnableContext; 42 private IJavaSearchScope fScope; 43 private int fStyle; 44 45 48 public MultiMainTypeSelectionDialog(Shell shell, IRunnableContext context, 49 IJavaSearchScope scope, int style) 50 { 51 super(shell, new JavaElementLabelProvider( 52 JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT)); 53 54 setMultipleSelection(true); 55 56 Assert.isNotNull(context); 57 Assert.isNotNull(scope); 58 59 fRunnableContext= context; 60 fScope= scope; 61 fStyle= style; 62 } 63 64 67 public int open() { 68 MainMethodSearchEngine engine= new MainMethodSearchEngine(); 69 IType[] types; 70 try { 71 types= engine.searchMainMethods(fRunnableContext, fScope, fStyle); 72 } catch (InterruptedException e) { 73 return CANCEL; 74 } catch (InvocationTargetException e) { 75 ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage()); 77 return CANCEL; 78 } 79 80 setElements(types); 81 return super.open(); 82 } 83 84 87 protected void configureShell(Shell newShell) { 88 super.configureShell(newShell); 89 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.MULTI_MAIN_TYPE_SELECTION_DIALOG); 90 } 91 92 93 } 94 | Popular Tags |