1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.dialogs;
14 import java.lang.reflect.InvocationTargetException;
16 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.core.runtime.Assert;
20 import org.eclipse.jface.operation.IRunnableContext;
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
25 import org.eclipse.jdt.core.IType;
26 import org.eclipse.jdt.core.search.IJavaSearchScope;
28 import org.eclipse.jdt.ui.JavaElementLabelProvider;
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;
36 * A dialog to select a type from a list of types. The dialog allows
37 * multiple selections.
39 public class MultiMainTypeSelectionDialog extends ElementListSelectionDialog {
41 private IRunnableContext fRunnableContext;
42 private IJavaSearchScope fScope;
48 public MultiMainTypeSelectionDialog(Shell shell, IRunnableContext context,
49 IJavaSearchScope scope, int style)
51 super(shell, new JavaElementLabelProvider(
52 JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT));
54 setMultipleSelection(true);
56 Assert.isNotNull(context);
57 Assert.isNotNull(scope);
59 fRunnableContext= context;
69 MainMethodSearchEngine engine= new MainMethodSearchEngine();
72 types= engine.searchMainMethods(fRunnableContext, fScope, fStyle);
73 } catch (InterruptedException e) {
75 } catch (InvocationTargetException e) {
77 ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage());
86 * @see org.eclipse.jface.window.Window#configureShell(Shell)
89 protected void configureShell(Shell newShell) {
90 super.configureShell(newShell);
91 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.MULTI_MAIN_TYPE_SELECTION_DIALOG);