KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > junit > launcher > TestSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.junit.launcher;
12
13  
14 import org.eclipse.swt.graphics.Image;
15 import org.eclipse.swt.widgets.Shell;
16
17 import org.eclipse.ui.dialogs.TwoPaneElementSelector;
18
19 import org.eclipse.jdt.core.IType;
20
21 import org.eclipse.jdt.ui.JavaElementLabelProvider;
22
23 /**
24  * A dialog to select a test class or a test suite from a list of types.
25  */

26 public class TestSelectionDialog extends TwoPaneElementSelector {
27
28     private final IType[] fTypes;
29     
30     private static class PackageRenderer extends JavaElementLabelProvider {
31         public PackageRenderer() {
32             super(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT);
33         }
34
35         public Image getImage(Object JavaDoc element) {
36             return super.getImage(((IType)element).getPackageFragment());
37         }
38         
39         public String JavaDoc getText(Object JavaDoc element) {
40             return super.getText(((IType)element).getPackageFragment());
41         }
42     }
43     
44     public TestSelectionDialog(Shell shell, IType[] types) {
45         super(shell, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS),
46                 new PackageRenderer());
47         fTypes= types;
48     }
49
50     /**
51      * @see org.eclipse.jface.window.Window#configureShell(Shell)
52      */

53     protected void configureShell(Shell newShell) {
54         super.configureShell(newShell);
55         //PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, new Object[] { IJavaHelpContextIds.MAINTYPE_SELECTION_DIALOG });
56
}
57
58     /*
59      * @see Window#open()
60      */

61     public int open() {
62         setElements(fTypes);
63         return super.open();
64     }
65     
66 }
67
Popular Tags