KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > wizards > ConfigurationWizardElement


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.team.internal.ui.wizards;
12
13
14 import org.eclipse.core.runtime.*;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.team.internal.ui.TeamUIPlugin;
17 import org.eclipse.ui.IPluginContribution;
18 import org.eclipse.ui.model.IWorkbenchAdapter;
19 import org.eclipse.ui.model.WorkbenchAdapter;
20
21 /**
22  * ConfigurationWizardElement represents an item in the configuration wizard table,
23  * declared by an extension to the configurationWizards extension point.
24  */

25 public class ConfigurationWizardElement extends WorkbenchAdapter implements IAdaptable, IPluginContribution {
26     private String JavaDoc id;
27     private String JavaDoc name;
28     private ImageDescriptor imageDescriptor;
29     private IConfigurationElement configurationElement;
30     
31     /**
32      * Creates a new instance of this class
33      *
34      * @param name the name of the element
35      */

36     public ConfigurationWizardElement(String JavaDoc name) {
37         this.name = name;
38     }
39     /**
40      * Create an the instance of the object described by the configuration
41      * element. That is, create the instance of the class the isv supplied in
42      * the extension point.
43      *
44      * @throws CoreException if an error occurs creating the extension
45      */

46     public Object JavaDoc createExecutableExtension() throws CoreException {
47         return TeamUIPlugin.createExtension(configurationElement, ConfigureProjectWizard.ATT_CLASS);
48     }
49     /*
50      * Method declared on IAdaptable.
51      */

52     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
53         if (adapter == IWorkbenchAdapter.class) {
54             return this;
55         }
56         return Platform.getAdapterManager().getAdapter(this, adapter);
57     }
58     /**
59      * Returns the configuration element
60      *
61      * @return the configuration element
62      */

63     public IConfigurationElement getConfigurationElement() {
64         return configurationElement;
65     }
66     /**
67      * Returns the image for the given element
68      *
69      * @param element the element to get the image for
70      * @return the image for the given element
71      */

72     public ImageDescriptor getImageDescriptor(Object JavaDoc element) {
73         return imageDescriptor;
74     }
75     /**
76      * Returns the label for the given element
77      *
78      * @param element the element to get the label for
79      * @return the label for the given element
80      */

81     public String JavaDoc getLabel(Object JavaDoc element) {
82         return name;
83     }
84     /**
85      * Returns the id as specified in the extension.
86      *
87      * @return java.lang.String
88      */

89     public String JavaDoc getID() {
90         return id;
91     }
92     /**
93      * Returns the image for this element.
94      *
95      * @return the image for this element
96      */

97     public ImageDescriptor getImageDescriptor() {
98         return imageDescriptor;
99     }
100     /**
101      * Set the configuration element
102      *
103      * @param newConfigurationElement the new configuration element
104      */

105     public void setConfigurationElement(IConfigurationElement newConfigurationElement) {
106         configurationElement = newConfigurationElement;
107     }
108     /**
109      * Set the description parameter of this element
110      *
111      * @param value the new desrciption
112      */

113     public void setDescription(String JavaDoc value) {
114         // Not used
115
}
116     /**
117      * Sets the id parameter of this element
118      *
119      * @param value the new ID
120      */

121     public void setID(String JavaDoc value) {
122         id = value;
123     }
124     /**
125      * Sets the image for this element.
126      *
127      * @param value the new image
128      */

129     public void setImageDescriptor(ImageDescriptor value) {
130         imageDescriptor = value;
131     }
132     
133     /* (non-Javadoc)
134      * @see org.eclipse.ui.IPluginContribution#getLocalId()
135      */

136     public String JavaDoc getLocalId() {
137         return configurationElement.getAttribute(ConfigureProjectWizard.ATT_ID);
138     }
139     
140     /* (non-Javadoc)
141      * @see org.eclipse.ui.IPluginContribution#getPluginId()
142      */

143     public String JavaDoc getPluginId() {
144         return configurationElement.getNamespace();
145     }
146 }
147
Popular Tags