-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from eMoflon/extension-point-for-uri-configura…
…tion Extension point for uri configuration
- Loading branch information
Showing
6 changed files
with
331 additions
and
174 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
org.moflon.core.utilities/src/org/moflon/core/utilities/ExtensionsUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.moflon.core.utilities; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.IConfigurationElement; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.moflon.core.utilities.LogUtils; | ||
|
||
public class ExtensionsUtil { | ||
private static final Logger logger = Logger.getLogger(ExtensionsUtil.class); | ||
|
||
/** | ||
* Collects all registered extensions with the given ID. | ||
* | ||
* @param extensionID | ||
* the ID of the extension | ||
* @param property | ||
* the name of the property | ||
* @param extensionType | ||
* the extension type | ||
* @return all extensions with the given ID as extensions of the given type | ||
*/ | ||
public static <T> Collection<T> collectExtensions(final String extensionID, final String property, | ||
final Class<T> extensionType) { | ||
Collection<T> extensions = new ArrayList<T>(); | ||
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(extensionID); | ||
try { | ||
for (IConfigurationElement e : config) { | ||
logger.debug("Evaluating extension"); | ||
final Object o = e.createExecutableExtension(property); | ||
if (extensionType.isInstance(o)) { | ||
extensions.add(extensionType.cast(o)); | ||
} | ||
} | ||
} catch (CoreException ex) { | ||
LogUtils.error(logger, ex); | ||
} | ||
|
||
return extensions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension-point id="URIPreferenceExtension" name="URIPreferenceExtension" schema="schema/URIPreferenceExtension.exsd"/> | ||
|
||
</plugin> |
102 changes: 102 additions & 0 deletions
102
org.moflon.emf.codegen/schema/URIPreferenceExtension.exsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.moflon.emf.codegen" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appinfo> | ||
<meta.schema plugin="org.moflon.emf.codegen" id="URIPreferenceExtension" name="URIPreferenceExtension"/> | ||
</appinfo> | ||
<documentation> | ||
This is a hook into the building process. Use this to register extensions that are invoked during the compilation process and can specify a preferred platform URI (either resource or plugin) to be used for creating EPackages and GenModels. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appinfo> | ||
<meta.element /> | ||
</appinfo> | ||
</annotation> | ||
<complexType> | ||
<choice> | ||
<element ref="uri_preference_extension"/> | ||
</choice> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appinfo> | ||
<meta.attribute translatable="true"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="uri_preference_extension"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appinfo> | ||
<meta.attribute kind="java" basedOn=":org.moflon.emf.codegen.URIPreferenceExtension"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="since"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="examples"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="apiinfo"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="implementation"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
|
||
</schema> |
Oops, something went wrong.