Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0ac9fd29d6bb6b0ae5c40e4386c636dc73b9f556 (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
/*******************************************************************************
 * Copyright (c) 2004, 2008 John Krasnay 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:
 *     John Krasnay - initial API and implementation
 *     Igor Jacy Lino Campista - Java 5 warnings fixed (bug 311325)
 *******************************************************************************/
package org.eclipse.wst.xml.vex.ui.internal.config;

import java.io.IOException;
import java.net.URL;
import java.text.MessageFormat;

import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.xml.vex.ui.internal.VexPlugin;

/**
 * An installed Eclipse bundle that provides Vex configuration items.
 */
public class ConfigPlugin extends ConfigSource {

	private String bundleSymbolicName;
	
	public ConfigPlugin(String bundleSymbolicName) {
		super(bundleSymbolicName);
		this.bundleSymbolicName = bundleSymbolicName;
		load();
	}

	private void load() {
		removeAllItems();
		for (IExtension extension : Platform.getExtensionRegistry().getExtensions(bundleSymbolicName)) {
			try {
				addItem(extension.getExtensionPointUniqueIdentifier(),
						extension.getSimpleIdentifier(), extension.getLabel(),
						ConfigurationElementWrapper.convertArray(extension
								.getConfigurationElements()));
			} catch (IOException e) {
				String message = MessageFormat.format(Messages
						.getString("ConfigPlugin.loadError"), //$NON-NLS-1$
						new Object[] { extension.getSimpleIdentifier(), bundleSymbolicName });
				VexPlugin.getInstance().log(IStatus.ERROR, message, e);
				return;
			}
		}
		parseResources(null);
	}
	
	public URL getBaseUrl() {
		return Platform.getBundle(bundleSymbolicName).getEntry("plugin.xml"); //$NON-NLS-1$
	}

}

Back to the top