
/*
 * generated by Xtext
 */
package jp.ac.jaist.kslab.e4.dsl.ui.internal;

import org.apache.log4j.Logger;

import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.util.Modules;

import java.util.Map;
import java.util.HashMap;

/**
 * Generated
 */
public class E4DslActivator extends AbstractUIPlugin {

	private Map<String,Injector> injectors = new HashMap<String,Injector>();
	private static E4DslActivator INSTANCE;

	public Injector getInjector(String languageName) {
		return injectors.get(languageName);
	}
	
	@Override
	public void start(BundleContext context) throws Exception {
		super.start(context);
		INSTANCE = this;
		try {
			
			injectors.put("jp.ac.jaist.kslab.e4.dsl.E4Dsl", Guice.createInjector(
				Modules.override(Modules.override(getRuntimeModule("jp.ac.jaist.kslab.e4.dsl.E4Dsl")).with(getUiModule("jp.ac.jaist.kslab.e4.dsl.E4Dsl"))).with(getSharedStateModule())
			));
			
		} catch (Exception e) {
			Logger.getLogger(getClass()).error(e.getMessage(), e);
			throw e;
		}
	}
	
	public static E4DslActivator getInstance() {
		return INSTANCE;
	}
	
	protected Module getRuntimeModule(String grammar) {
		
		if ("jp.ac.jaist.kslab.e4.dsl.E4Dsl".equals(grammar)) {
		  return new jp.ac.jaist.kslab.e4.dsl.E4DslRuntimeModule();
		}
		
		throw new IllegalArgumentException(grammar);
	}
	protected Module getUiModule(String grammar) {
		
		if ("jp.ac.jaist.kslab.e4.dsl.E4Dsl".equals(grammar)) {
		  return new jp.ac.jaist.kslab.e4.dsl.ui.E4DslUiModule(this);
		}
		
		throw new IllegalArgumentException(grammar);
	}
	
	protected Module getSharedStateModule() {
		return new org.eclipse.xtext.ui.shared.SharedStateModule();
	}
	
}
