blob: 397265ba68da8e0c278ca77d325ef391e0f65f8c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro
* 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:
* Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2;
import org.eclipse.viatra2.codegen.CodeOutputPluginFactory;
import org.eclipse.viatra2.core.IModelSpace;
import org.eclipse.viatra2.core.simple.SimpleModelSpace;
import org.eclipse.viatra2.core.tracebased.TraceModelSpace;
import org.eclipse.viatra2.framework.ExtensionProvider;
import org.eclipse.viatra2.framework.FrameworkException;
import org.eclipse.viatra2.framework.properties.IViatraPropertyProvider;
import org.eclipse.viatra2.framework.properties.VPMProperties;
import org.eclipse.viatra2.framework.properties.providers.VPMCorePropertyProvider;
import org.eclipse.viatra2.imports.NativeImporterFactory;
import org.eclipse.viatra2.interpreters.ModelInterpreterFactory;
import org.eclipse.viatra2.loaders.LoaderFactory;
import org.eclipse.viatra2.logger.Logger;
import org.eclipse.viatra2.logger.LoggerFactory;
import org.eclipse.viatra2.natives.ASMNativeFunction;
/**
* The extension loader in Eclipse environment. Extensions for the VPM modeling
* core are found and loaded as Eclipse plugins.
*
* @author Andras Schmidt
*
*/
public class EclipseExtensionProvider implements ExtensionProvider {
Logger logger;
public Logger getDefaultLogger() {
return ViatraPlugin.getDefault().getEclipseLogger();
}
public void setLogger(Logger l) {
logger = l;
}
public LoggerFactory[] getAvailableLoggers() {
return ViatraPlugin.getDefault().initLoggerPlugins().toArray(
new LoggerFactory[0]);
}
public CodeOutputPluginFactory[] getCodeOutputPlugins() {
return ViatraPlugin.getDefault().initCodeOutPlugins().toArray(
new CodeOutputPluginFactory[0]);
}
public NativeImporterFactory[] getNativeImporters(VPMProperties p) {
return ViatraPlugin.getDefault().getImporterPlugins();
}
public LoaderFactory[] getLoaders(VPMProperties p) {
return ViatraPlugin.getDefault().getLoaderPlugins();
}
/*
* public InputStream getPropertyStream() throws IOException { return
* ViatraPlugin.getDefault().getPropertyStream(); }
*/
public VPMProperties getDefaultProperties() throws FrameworkException {
// XXX VPMProperties is instantiated here
VPMProperties props = new VPMProperties();
for (IViatraPropertyProvider p : getPropertyProviders()) {
props.addPropertyProvider(p);
for (String key : p.getAllPropertyIds()) {
props.setRuntimeProperty(p.getProviderID(), key, p
.getDefaultPropertyValue(key));
}
}
return props;
}
public ASMNativeFunction[] getNativeFunctions() {
return ViatraPlugin.getDefault().initNativeFunctionPlugins().toArray(
new ASMNativeFunction[0]);
}
public IModelSpace getEmptyModelspace(VPMProperties props) {
if (props.isRuntimePropertySet(
VPMCorePropertyProvider.VPM_CORE_PROVIDER_NAME,
VPMCorePropertyProvider.VPM_CORE_PROVIDER_MANAGER_PROPERTY)) {
if (props
.getRuntimeProperty(
VPMCorePropertyProvider.VPM_CORE_PROVIDER_NAME,
VPMCorePropertyProvider.VPM_CORE_PROVIDER_MANAGER_PROPERTY)
.equals(VPMCorePropertyProvider.VPM_CORE_PROVIDER_TRACEBASED_VALUE)) {
return new TraceModelSpace();
}
}
return new SimpleModelSpace();
}
public ModelInterpreterFactory[] getInterpreters() {
return ViatraPlugin.getDefault().initInterpreterPlugins().toArray(
new ModelInterpreterFactory[0]);
}
public IViatraPropertyProvider[] getPropertyProviders() {
return ViatraPlugin.getDefault().getPropertyProviders().toArray(
new IViatraPropertyProvider[0]);
}
}