/wesnoth-1.10.3/utils/umc_dev/org.wesnoth.ui/src-gen/org/wesnoth/ui/internal/WMLActivator.java
Java | 82 lines | 56 code | 19 blank | 7 comment | 2 complexity | 915d6e2b0389d5c61a970b56e4f41690 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, EPL-1.0
- /*
- * generated by Xtext
- */
- package org.wesnoth.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 WMLActivator extends AbstractUIPlugin {
- private Map<String,Injector> injectors = new HashMap<String,Injector>();
- private static WMLActivator 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.wesnoth.WML");
-
- } 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 WMLActivator getInstance() {
- return INSTANCE;
- }
-
- protected Module getRuntimeModule(String grammar) {
- if ("org.wesnoth.WML".equals(grammar)) {
- return new org.wesnoth.WMLRuntimeModule();
- }
-
- throw new IllegalArgumentException(grammar);
- }
-
- protected Module getUiModule(String grammar) {
- if ("org.wesnoth.WML".equals(grammar)) {
- return new org.wesnoth.ui.WMLUiModule(this);
- }
-
- throw new IllegalArgumentException(grammar);
- }
-
- protected Module getSharedStateModule() {
- return new org.eclipse.xtext.ui.shared.SharedStateModule();
- }
-
- }