Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 183e4adfdae964c650de6320d011a1b62bcc6f72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ui.registry;

import org.eclipse.core.runtime.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.team.internal.ui.TeamUIPlugin;

/**
 * Descriptor for accessing and creating synchronize wizards
 */
public class SynchronizeWizardDescription {

	public  static final String ATT_ID = "id"; //$NON-NLS-1$
	public  static final String ATT_NAME = "name"; //$NON-NLS-1$
	public  static final String ATT_ICON = "icon"; //$NON-NLS-1$
	public  static final String ATT_CLASS = "class"; //$NON-NLS-1$
	public  static final String ATT_DESCRIPTION = "description"; //$NON-NLS-1$

	private String label;
	private String className;
	private String description;
	private String id;
	private ImageDescriptor imageDescriptor;

	private IConfigurationElement configElement;

	public SynchronizeWizardDescription(IConfigurationElement e, String descText) throws CoreException {
		configElement = e;
		loadFromExtension();
	}

	public IWizard createWizard() throws CoreException {
		Object obj = RegistryReader.createExtension(configElement, ATT_CLASS);
		return (IWizard) obj;
	}

	private void loadFromExtension() throws CoreException {
		String identifier = configElement.getAttribute(ATT_ID);
		label = configElement.getAttribute(ATT_NAME);
		className = configElement.getAttribute(ATT_CLASS);
		description = configElement.getAttribute(ATT_DESCRIPTION);

		// Sanity check.
		if ((label == null) || (className == null) || (identifier == null) || (description == null)) {
			throw new CoreException(new Status(IStatus.ERROR, configElement.getContributor().getName(), 0, "Invalid extension (missing label or class name): " + identifier, //$NON-NLS-1$
					null));
		}

		id = identifier;
	}

	public String getId() {
		return id;
	}

	public String getDescription() {
		return description;
	}

	public ImageDescriptor getImageDescriptor() {
		if (imageDescriptor != null)
			return imageDescriptor;
		String iconName = configElement.getAttribute(ATT_ICON);
		if (iconName == null)
			return null;
		imageDescriptor = TeamUIPlugin.getImageDescriptorFromExtension(configElement.getDeclaringExtension(), iconName);
		return imageDescriptor;
	}

	public String getName() {
		return label;
	}

	@Override
	public String toString() {
		return "Synchronize Participant Creation Wizard(" + getId() + ")"; //$NON-NLS-2$//$NON-NLS-1$
	}
}

Back to the top