KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.resources.IProject;
14 import org.eclipse.jface.viewers.StructuredSelection;
15 import org.eclipse.jface.wizard.IWizard;
16 import org.eclipse.osgi.util.NLS;
17 import org.eclipse.ui.ICapabilityInstallWizard;
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
20 import org.eclipse.ui.internal.ide.registry.Capability;
21
22 /**
23  * Represents a capability install step in a multi-step
24  * wizard.
25  */

26 public class InstallCapabilityStep extends WizardStep {
27     private Capability capability;
28
29     private ICapabilityInstallWizard wizard;
30
31     private IWorkbench workbench;
32
33     private IProjectProvider projectProvider;
34
35     /**
36      * Creates the capability install step
37      *
38      * @param number step order number
39      * @param capability the capability to install
40      */

41     public InstallCapabilityStep(int number, Capability capability,
42             IWorkbench workbench, IProjectProvider projectProvider) {
43         super(number);
44         this.capability = capability;
45         this.workbench = workbench;
46         this.projectProvider = projectProvider;
47     }
48
49     /* (non-Javadoc)
50      * Method declared on WizardStep.
51      */

52     public String JavaDoc getLabel() {
53         return NLS.bind(IDEWorkbenchMessages.InstallCapabilityStep_label, capability.getName());
54     }
55
56     /* (non-Javadoc)
57      * Method declared on WizardStep.
58      */

59     public String JavaDoc getDetails() {
60         return capability.getInstallDetails();
61     }
62
63     /* (non-Javadoc)
64      * Method declared on WizardStep.
65      */

66     public IWizard getWizard() {
67         if (wizard == null) {
68             wizard = capability.getInstallWizard();
69             if (wizard != null) {
70                 wizard.init(workbench, StructuredSelection.EMPTY,
71                         projectProvider.getProject());
72                 wizard.addPages();
73             }
74         }
75
76         return wizard;
77     }
78
79     interface IProjectProvider {
80         /**
81          * Returns the project to which the capability
82          * is to be configured against.
83          */

84         public IProject getProject();
85     }
86 }
87
Popular Tags