1 | |
---|
2 | /* |
---|
3 | * generated by Xtext |
---|
4 | */ |
---|
5 | package de.ugoe.cs.swe.bnftools.ui.internal; |
---|
6 | |
---|
7 | import org.apache.log4j.Logger; |
---|
8 | |
---|
9 | import org.eclipse.ui.plugin.AbstractUIPlugin; |
---|
10 | import org.osgi.framework.BundleContext; |
---|
11 | |
---|
12 | import com.google.inject.Guice; |
---|
13 | import com.google.inject.Injector; |
---|
14 | import com.google.inject.Module; |
---|
15 | import com.google.inject.util.Modules; |
---|
16 | |
---|
17 | import java.util.Map; |
---|
18 | import java.util.HashMap; |
---|
19 | |
---|
20 | /** |
---|
21 | * Generated |
---|
22 | */ |
---|
23 | public class EbnfActivator extends AbstractUIPlugin { |
---|
24 | |
---|
25 | private Map<String,Injector> injectors = new HashMap<String,Injector>(); |
---|
26 | private static EbnfActivator INSTANCE; |
---|
27 | |
---|
28 | public Injector getInjector(String languageName) { |
---|
29 | return injectors.get(languageName); |
---|
30 | } |
---|
31 | |
---|
32 | @Override |
---|
33 | public void start(BundleContext context) throws Exception { |
---|
34 | super.start(context); |
---|
35 | INSTANCE = this; |
---|
36 | try { |
---|
37 | |
---|
38 | injectors.put("de.ugoe.cs.swe.bnftools.Ebnf", Guice.createInjector( |
---|
39 | Modules.override(Modules.override(getRuntimeModule("de.ugoe.cs.swe.bnftools.Ebnf")).with(getUiModule("de.ugoe.cs.swe.bnftools.Ebnf"))).with(getSharedStateModule()) |
---|
40 | )); |
---|
41 | |
---|
42 | } catch (Exception e) { |
---|
43 | Logger.getLogger(getClass()).error(e.getMessage(), e); |
---|
44 | throw e; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | public static EbnfActivator getInstance() { |
---|
49 | return INSTANCE; |
---|
50 | } |
---|
51 | |
---|
52 | protected Module getRuntimeModule(String grammar) { |
---|
53 | |
---|
54 | if ("de.ugoe.cs.swe.bnftools.Ebnf".equals(grammar)) { |
---|
55 | return new de.ugoe.cs.swe.bnftools.EbnfRuntimeModule(); |
---|
56 | } |
---|
57 | |
---|
58 | throw new IllegalArgumentException(grammar); |
---|
59 | } |
---|
60 | protected Module getUiModule(String grammar) { |
---|
61 | |
---|
62 | if ("de.ugoe.cs.swe.bnftools.Ebnf".equals(grammar)) { |
---|
63 | return new de.ugoe.cs.swe.bnftools.ui.EbnfUiModule(this); |
---|
64 | } |
---|
65 | |
---|
66 | throw new IllegalArgumentException(grammar); |
---|
67 | } |
---|
68 | |
---|
69 | protected Module getSharedStateModule() { |
---|
70 | return new org.eclipse.xtext.ui.shared.SharedStateModule(); |
---|
71 | } |
---|
72 | |
---|
73 | } |
---|