KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > registry > SynchronizeWizardDescription


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.registry;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.wizard.IWizard;
16 import org.eclipse.team.internal.ui.TeamUIPlugin;
17
18 /**
19  * Descriptor for accessing and creating synchronize wizards
20  */

21 public class SynchronizeWizardDescription {
22     
23     public static final String JavaDoc ATT_ID = "id"; //$NON-NLS-1$
24
public static final String JavaDoc ATT_NAME = "name"; //$NON-NLS-1$
25
public static final String JavaDoc ATT_ICON = "icon"; //$NON-NLS-1$
26
public static final String JavaDoc ATT_CLASS = "class"; //$NON-NLS-1$
27
public static final String JavaDoc ATT_DESCRIPTION = "description"; //$NON-NLS-1$
28

29     private String JavaDoc label;
30     private String JavaDoc className;
31     private String JavaDoc description;
32     private String JavaDoc id;
33     private ImageDescriptor imageDescriptor;
34     
35     private IConfigurationElement configElement;
36     
37     public SynchronizeWizardDescription(IConfigurationElement e, String JavaDoc descText) throws CoreException {
38         configElement = e;
39         loadFromExtension();
40     }
41     
42     public IWizard createWizard() throws CoreException {
43         Object JavaDoc obj = RegistryReader.createExtension(configElement, ATT_CLASS);
44         return (IWizard) obj;
45     }
46     
47     private void loadFromExtension() throws CoreException {
48         String JavaDoc identifier = configElement.getAttribute(ATT_ID);
49         label = configElement.getAttribute(ATT_NAME);
50         className = configElement.getAttribute(ATT_CLASS);
51         description = configElement.getAttribute(ATT_DESCRIPTION);
52         
53         // Sanity check.
54
if ((label == null) || (className == null) || (identifier == null) || (description == null)) {
55             throw new CoreException(new Status(IStatus.ERROR, configElement.getNamespace(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$
56
null));
57         }
58         
59         id = identifier;
60     }
61     
62     public String JavaDoc getId() {
63         return id;
64     }
65     
66     public String JavaDoc getDescription() {
67         return description;
68     }
69     
70     public ImageDescriptor getImageDescriptor() {
71         if (imageDescriptor != null)
72             return imageDescriptor;
73         String JavaDoc iconName = configElement.getAttribute(ATT_ICON);
74         if (iconName == null)
75             return null;
76         imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName);
77         return imageDescriptor;
78     }
79
80     public String JavaDoc getName() {
81         return label;
82     }
83     
84     public String JavaDoc toString() {
85         return "Synchronize Participant Creation Wizard(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$
86
}
87 }
88
Popular Tags