PageRenderTime 3185ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1. /*
  2. * generated by Xtext
  3. */
  4. package org.wesnoth.ui.internal;
  5. import static com.google.inject.util.Modules.override;
  6. import static com.google.inject.Guice.createInjector;
  7. import org.apache.log4j.Logger;
  8. import org.eclipse.ui.plugin.AbstractUIPlugin;
  9. import org.osgi.framework.BundleContext;
  10. import com.google.inject.Injector;
  11. import com.google.inject.Module;
  12. import java.util.Map;
  13. import java.util.HashMap;
  14. /**
  15. * This class was generated. Customizations should only happen in a newly
  16. * introduced subclass.
  17. */
  18. public class WMLActivator extends AbstractUIPlugin {
  19. private Map<String,Injector> injectors = new HashMap<String,Injector>();
  20. private static WMLActivator INSTANCE;
  21. public Injector getInjector(String languageName) {
  22. return injectors.get(languageName);
  23. }
  24. @Override
  25. public void start(BundleContext context) throws Exception {
  26. super.start(context);
  27. INSTANCE = this;
  28. try {
  29. registerInjectorFor("org.wesnoth.WML");
  30. } catch (Exception e) {
  31. Logger.getLogger(getClass()).error(e.getMessage(), e);
  32. throw e;
  33. }
  34. }
  35. protected void registerInjectorFor(String language) throws Exception {
  36. injectors.put(language, createInjector(
  37. override(override(getRuntimeModule(language)).with(getSharedStateModule())).with(getUiModule(language))));
  38. }
  39. @Override
  40. public void stop(BundleContext context) throws Exception {
  41. injectors.clear();
  42. INSTANCE = null;
  43. super.stop(context);
  44. }
  45. public static WMLActivator getInstance() {
  46. return INSTANCE;
  47. }
  48. protected Module getRuntimeModule(String grammar) {
  49. if ("org.wesnoth.WML".equals(grammar)) {
  50. return new org.wesnoth.WMLRuntimeModule();
  51. }
  52. throw new IllegalArgumentException(grammar);
  53. }
  54. protected Module getUiModule(String grammar) {
  55. if ("org.wesnoth.WML".equals(grammar)) {
  56. return new org.wesnoth.ui.WMLUiModule(this);
  57. }
  58. throw new IllegalArgumentException(grammar);
  59. }
  60. protected Module getSharedStateModule() {
  61. return new org.eclipse.xtext.ui.shared.SharedStateModule();
  62. }
  63. }