KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > dialogs > WizardNewProjectCapabilityPage


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.ui.internal.ide.dialogs;
12
13 import org.eclipse.jface.viewers.CheckStateChangedEvent;
14 import org.eclipse.jface.viewers.ICheckStateListener;
15 import org.eclipse.jface.wizard.WizardPage;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.ui.PlatformUI;
18 import org.eclipse.ui.internal.ide.Category;
19 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
20 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
21 import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
22 import org.eclipse.ui.internal.ide.misc.ProjectCapabilitySelectionGroup;
23 import org.eclipse.ui.internal.ide.registry.Capability;
24 import org.eclipse.ui.internal.ide.registry.CapabilityRegistry;
25
26 /**
27  * Second page for the new project creation wizard. This page
28  * collects the capabilities of the new project.
29  * <p>
30  * Example useage:
31  * <pre>
32  * mainPage = new WizardNewProjectCapabilityPage("wizardNewProjectCapabilityPage");
33  * mainPage.setTitle("Project");
34  * mainPage.setDescription("Choose project's capabilities.");
35  * </pre>
36  * </p>
37  */

38 public class WizardNewProjectCapabilityPage extends WizardPage {
39     // initial value stores
40
private Capability[] initialProjectCapabilities;
41
42     private Category[] initialSelectedCategories;
43
44     // widgets
45
private ProjectCapabilitySelectionGroup capabilityGroup;
46
47     /**
48      * Creates a new project capabilities wizard page.
49      *
50      * @param pageName the name of this page
51      */

52     public WizardNewProjectCapabilityPage(String JavaDoc pageName) {
53         super(pageName);
54     }
55
56     /* (non-Javadoc)
57      * Method declared on IWizardPage
58      */

59     public boolean canFlipToNextPage() {
60         // Already know there is a next page...
61
return isPageComplete();
62     }
63
64     /* (non-Javadoc)
65      * Method declared on IDialogPage.
66      */

67     public void createControl(Composite parent) {
68         PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
69                 IIDEHelpContextIds.NEW_PROJECT_CAPABILITY_WIZARD_PAGE);
70         CapabilityRegistry reg = IDEWorkbenchPlugin.getDefault()
71                 .getCapabilityRegistry();
72         capabilityGroup = new ProjectCapabilitySelectionGroup(
73                 initialSelectedCategories, initialProjectCapabilities, reg);
74         setControl(capabilityGroup.createContents(parent));
75
76         capabilityGroup.setCheckStateListener(new ICheckStateListener() {
77             public void checkStateChanged(CheckStateChangedEvent event) {
78                 getWizard().getContainer().updateButtons();
79             }
80         });
81
82         if (!reg.hasCapabilities())
83             setMessage(
84                     IDEWorkbenchMessages.WizardNewProjectCapabilityPage_noCapabilities, WARNING);
85     }
86
87     /**
88      * Returns the collection of capabilities selected
89      * by the user. The collection is not in prerequisite
90      * order.
91      *
92      * @return array of selected capabilities
93      */

94     /* package */Capability[] getSelectedCapabilities() {
95         return capabilityGroup.getSelectedCapabilities();
96     }
97
98     /**
99      * Sets the initial categories to be selected.
100      *
101      * @param categories initial categories to select
102      */

103     /* package */void setInitialSelectedCategories(Category[] categories) {
104         initialSelectedCategories = categories;
105     }
106
107     /**
108      * Sets the initial project capabilities to be selected.
109      *
110      * @param capabilities initial project capabilities to select
111      */

112     /* package */void setInitialProjectCapabilities(Capability[] capabilities) {
113         initialProjectCapabilities = capabilities;
114     }
115 }
116
Popular Tags