]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/dialogs/MultiMainTypeSelectionDialog.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / dialogs / MultiMainTypeSelectionDialog.java
CommitLineData
1b2798f6
EK
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
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.dialogs;
12
13
14import java.lang.reflect.InvocationTargetException;
15
16import org.eclipse.swt.widgets.Shell;
17
18import org.eclipse.core.runtime.Assert;
19
20import org.eclipse.jface.operation.IRunnableContext;
21
22import org.eclipse.ui.PlatformUI;
23import org.eclipse.ui.dialogs.ElementListSelectionDialog;
24
25import org.eclipse.jdt.core.IType;
26import org.eclipse.jdt.core.search.IJavaSearchScope;
27
28import org.eclipse.jdt.ui.JavaElementLabelProvider;
29
30import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
31import org.eclipse.jdt.internal.ui.JavaUIMessages;
32import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
33import org.eclipse.jdt.internal.ui.util.MainMethodSearchEngine;
34
35/**
36 * A dialog to select a type from a list of types. The dialog allows
37 * multiple selections.
38 */
39public class MultiMainTypeSelectionDialog extends ElementListSelectionDialog {
40
41 private IRunnableContext fRunnableContext;
42 private IJavaSearchScope fScope;
43 private int fStyle;
44
45 /**
46 * Constructor.
47 */
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 /*
65 * @see Window#open()
66 */
67 @Override
68 public int open() {
69 MainMethodSearchEngine engine= new MainMethodSearchEngine();
70 IType[] types;
71 try {
72 types= engine.searchMainMethods(fRunnableContext, fScope, fStyle);
73 } catch (InterruptedException e) {
74 return CANCEL;
75 } catch (InvocationTargetException e) {
76 //XX: to do
77 ExceptionHandler.handle(e, JavaUIMessages.MultiMainTypeSelectionDialog_errorTitle, e.getMessage());
78 return CANCEL;
79 }
80
81 setElements(types);
82 return super.open();
83 }
84
85 /*
86 * @see org.eclipse.jface.window.Window#configureShell(Shell)
87 */
88 @Override
89 protected void configureShell(Shell newShell) {
90 super.configureShell(newShell);
91 PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaHelpContextIds.MULTI_MAIN_TYPE_SELECTION_DIALOG);
92 }
93
94
95}