]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/dialogs/MultiMainTypeSelectionDialog.java
Some talks, mostly identical.
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / dialogs / MultiMainTypeSelectionDialog.java
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  *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.dialogs;
12
13
14 import java.lang.reflect.InvocationTargetException;
15
16 import org.eclipse.swt.widgets.Shell;
17
18 import org.eclipse.core.runtime.Assert;
19
20 import org.eclipse.jface.operation.IRunnableContext;
21
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.dialogs.ElementListSelectionDialog;
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 /**
36  * A dialog to select a type from a list of types. The dialog allows
37  * multiple selections.
38  */
39 public 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 }