Search in sources :

Example 1 with IModelParser

use of org.eclipse.vorto.core.ui.parser.IModelParser in project vorto by eclipse.

the class ModelParserFactory method getModelParser.

public IModelParser getModelParser() {
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IModelParser.EXTENSIONPOINT_ID);
    IExtension[] modelParserExtensions = extensionPoint.getExtensions();
    if (modelParserExtensions.length == 0) {
        throw new RuntimeException("No Vorto Model Parser found!");
    } else if (modelParserExtensions.length > 1) {
        throw new RuntimeException("More than 1 Vorto Model Parser found. Cannot decide which one to bind. ");
    }
    try {
        return (IModelParser) modelParserExtensions[0].getConfigurationElements()[0].createExecutableExtension("class");
    } catch (Exception e) {
        throw new RuntimeException("Problem binding Vorto Model Parser", e);
    }
}
Also used : IModelParser(org.eclipse.vorto.core.ui.parser.IModelParser) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension)

Aggregations

IExtension (org.eclipse.core.runtime.IExtension)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 IModelParser (org.eclipse.vorto.core.ui.parser.IModelParser)1