PageRenderTime 56ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/org.eclipselabs.spray.generator.graphiti.ui/src/org/eclipselabs/spray/generator/graphiti/ui/Activator.java

https://bitbucket.org/gcubar/eclipselabs.org-spray
Java | 54 lines | 44 code | 8 blank | 2 comment | 0 complexity | 63dacd5e72254be5e938d1a95d28fff8 MD5 | raw file
  1. package org.eclipselabs.spray.generator.graphiti.ui;
  2. import org.apache.log4j.Logger;
  3. import org.eclipse.ui.plugin.AbstractUIPlugin;
  4. import org.eclipse.xtext.ui.shared.SharedStateModule;
  5. import org.eclipselabs.spray.generator.graphiti.GraphitiGeneratorModule;
  6. import org.eclipselabs.spray.runtime.graphiti.GraphitiRuntimeModule;
  7. import org.eclipselabs.spray.xtext.SprayRuntimeModule;
  8. import org.eclipselabs.spray.xtext.util.Modules3;
  9. import org.osgi.framework.BundleContext;
  10. import com.google.inject.Guice;
  11. import com.google.inject.Injector;
  12. import com.google.inject.Module;
  13. /**
  14. */
  15. public class Activator extends AbstractUIPlugin {
  16. public static final String PLUGIN_ID = "org.eclipselabs.spray.generator.graphiti.ui"; //$NON-NLS-1$
  17. private Injector injector;
  18. private static Activator INSTANCE;
  19. public Injector getInjector() {
  20. return injector;
  21. }
  22. @Override
  23. public void start(BundleContext context) throws Exception {
  24. super.start(context);
  25. INSTANCE = this;
  26. try {
  27. initializeInjector();
  28. } catch (Exception e) {
  29. Logger.getLogger(getClass()).error(e.getMessage(), e);
  30. throw e;
  31. }
  32. }
  33. @Override
  34. public void stop(BundleContext context) throws Exception {
  35. injector = null;
  36. super.stop(context);
  37. }
  38. public static Activator getInstance() {
  39. return INSTANCE;
  40. }
  41. protected void initializeInjector() {
  42. Module module = Modules3.mixin(new SprayRuntimeModule(), new GraphitiRuntimeModule(), new GraphitiGeneratorModule(), new GraphitiGeneratorUIModule(this), new SharedStateModule()/* , new SprayUiModule(this) */);
  43. injector = Guice.createInjector(module);
  44. injector.injectMembers(this);
  45. }
  46. }