KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > launcher > MainTypeSelectionDialog


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.pde.internal.ui.launcher;
12
13  
14 import org.eclipse.jdt.core.IType;
15 import org.eclipse.jdt.ui.JavaElementLabelProvider;
16 import org.eclipse.jface.util.Assert;
17 import org.eclipse.pde.internal.ui.PDEUIMessages;
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.dialogs.TwoPaneElementSelector;
23
24 public class MainTypeSelectionDialog extends TwoPaneElementSelector {
25
26     /** The main types. */
27     private final IType[] fTypes;
28     
29     private static class PackageRenderer extends JavaElementLabelProvider {
30         public PackageRenderer() {
31             super(JavaElementLabelProvider.SHOW_PARAMETERS | JavaElementLabelProvider.SHOW_POST_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT);
32         }
33
34         public Image getImage(Object JavaDoc element) {
35             return super.getImage(((IType)element).getPackageFragment());
36         }
37         
38         public String JavaDoc getText(Object JavaDoc element) {
39             return super.getText(((IType)element).getPackageFragment());
40         }
41     }
42
43     public MainTypeSelectionDialog(Shell shell, IType[] types) {
44
45         super(shell, new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS),
46             new PackageRenderer());
47
48         Assert.isNotNull(types);
49         fTypes= types;
50         setMessage(PDEUIMessages.MainTypeSelectionDialog_chooseType);
51         setUpperListLabel(PDEUIMessages.MainTypeSelectionDialog_matching);
52         setLowerListLabel(PDEUIMessages.MainTypeSelectionDialog_qualifier);
53     }
54
55     /**
56      * Returns the main types.
57      */

58     public IType[] getTypes() {
59         return fTypes;
60     }
61     
62     /*
63      * @see Window#open()
64      */

65     public int open() {
66
67         if (fTypes == null)
68             return CANCEL;
69         
70         setElements(fTypes);
71         return super.open();
72     }
73     
74     /**
75      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
76      */

77     public Control createDialogArea(Composite parent) {
78         Control control= super.createDialogArea(parent);
79         applyDialogFont(control);
80         return control;
81     }
82 }
83
Popular Tags