/* * generated by Xtext */ package org.eclipse.papyrus.uml.textedit.common.xtext.ui.internal; import static com.google.inject.util.Modules.override; import static com.google.inject.Guice.createInjector; import org.apache.log4j.Logger; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import com.google.inject.Injector; import com.google.inject.Module; import java.util.Map; import java.util.HashMap; /** * This class was generated. Customizations should only happen in a newly * introduced subclass. */ public class UmlCommonActivator extends AbstractUIPlugin { private Map<String,Injector> injectors = new HashMap<String,Injector>(); private static UmlCommonActivator INSTANCE; public Injector getInjector(String languageName) { return injectors.get(languageName); } @Override public void start(BundleContext context) throws Exception { super.start(context); INSTANCE = this; try { registerInjectorFor("org.eclipse.papyrus.uml.textedit.common.xtext.UmlCommon"); } catch (Exception e) { Logger.getLogger(getClass()).error(e.getMessage(), e); throw e; } } protected void registerInjectorFor(String language) throws Exception { injectors.put(language, createInjector( override(override(getRuntimeModule(language)).with(getSharedStateModule())).with(getUiModule(language)))); } @Override public void stop(BundleContext context) throws Exception { injectors.clear(); INSTANCE = null; super.stop(context); } public static UmlCommonActivator getInstance() { return INSTANCE; } protected Module getRuntimeModule(String grammar) { if ("org.eclipse.papyrus.uml.textedit.common.xtext.UmlCommon".equals(grammar)) { return new org.eclipse.papyrus.uml.textedit.common.xtext.UmlCommonRuntimeModule(); } throw new IllegalArgumentException(grammar); } protected Module getUiModule(String grammar) { if ("org.eclipse.papyrus.uml.textedit.common.xtext.UmlCommon".equals(grammar)) { return new org.eclipse.papyrus.uml.textedit.common.xtext.ui.UmlCommonUiModule(this); } throw new IllegalArgumentException(grammar); } protected Module getSharedStateModule() { return new org.eclipse.xtext.ui.shared.SharedStateModule(); } }