1 | package de.uka.ipd.sdq.simulation.abstractsimengine.util; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import org.eclipse.core.runtime.CoreException; |
7 | import org.eclipse.core.runtime.IConfigurationElement; |
8 | import org.eclipse.core.runtime.IExtension; |
9 | import org.eclipse.core.runtime.Platform; |
10 | |
11 | /** |
12 | * |
13 | * Helper class for working with the Eclipse extension point mechanism. |
14 | * |
15 | * TODO: This class should reside in a general plug-in like "de.uka.ipd.sdq.utils". |
16 | * |
17 | * @author Philipp Merkle |
18 | * |
19 | */ |
20 | public class ExtensionPointHelper { |
21 | |
22 | public static List<IConfigurationElement> findConfigurationElements(IExtension extension, String elementName) |
23 | throws CoreException { |
24 | List<IConfigurationElement> result = new ArrayList<IConfigurationElement>(); |
25 | IConfigurationElement[] elements = extension.getConfigurationElements(); |
26 | for (IConfigurationElement element : elements) { |
27 | if (element.getName().equals(elementName)) { |
28 | result.add(element); |
29 | } |
30 | } |
31 | return result; |
32 | } |
33 | |
34 | public static List<IExtension> findExtensions(String extensionPointId) { |
35 | IExtension[] exts = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId).getExtensions(); |
36 | List<IExtension> results = new ArrayList<IExtension>(); |
37 | for (IExtension extension : exts) { |
38 | results.add(extension); |
39 | } |
40 | return results; |
41 | } |
42 | |
43 | } |