KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > launcher > MainTypeSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.ui.launcher;
12
13  
14 import org.eclipse.jdt.core.IType;
15 import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
16 import org.eclipse.jdt.ui.JavaElementLabelProvider;
17 import org.eclipse.jface.util.Assert;
18 import org.eclipse.swt.graphics.Image;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.dialogs.TwoPaneElementSelector;
24
25 /**
26  * A dialog to select a type from a list of types. The dialog allows
27  * multiple selections.
28  *
29  * @since 2.1
30  */

31 public class MainTypeSelectionDialog extends TwoPaneElementSelector {
32
33     /** The main types. */
34     private final IType[] fTypes;
35     
36     private static class PackageRenderer extends JavaElementLabelProvider {
37         public PackageRenderer() {
38             super(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT);
39         }
40
41         public Image getImage(Object JavaDoc element) {
42             return super.getImage(((IType)element).getPackageFragment());
43         }
44         
45         public String JavaDoc getText(Object JavaDoc element) {
46             return super.getText(((IType)element).getPackageFragment());
47         }
48     }
49
50     public MainTypeSelectionDialog(Shell shell, IType[] types) {
51
52         super(shell, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS),
53             new PackageRenderer());
54
55         Assert.isNotNull(types);
56         fTypes= types;
57         setMessage(LauncherMessages.MainTypeSelectionDialog_Choose_a_type); //$NON-NLS-1$
58
setUpperListLabel(LauncherMessages.MainTypeSelectionDialog_Matching_types); //$NON-NLS-1$
59
setLowerListLabel(LauncherMessages.MainTypeSelectionDialog_Qualifier); //$NON-NLS-1$
60
}
61
62     /**
63      * Returns the main types.
64      */

65     public IType[] getTypes() {
66         return fTypes;
67     }
68     
69     /*
70      * @see Windows#configureShell
71      */

72     protected void configureShell(Shell newShell) {
73         super.configureShell(newShell);
74         PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaDebugHelpContextIds.MAIN_TYPE_SELECTION_DIALOG);
75     }
76
77     /*
78      * @see Window#open()
79      */

80     public int open() {
81
82         if (fTypes == null)
83             return CANCEL;
84         
85         setElements(fTypes);
86         return super.open();
87     }
88     
89     /**
90      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
91      */

92     public Control createDialogArea(Composite parent) {
93         Control control= super.createDialogArea(parent);
94         applyDialogFont(control);
95         return control;
96     }
97 }
98
Popular Tags