diff options
author | 2017-06-10 20:39:40 +0200 | |
---|---|---|
committer | 2017-06-10 20:39:40 +0200 | |
commit | 10d272818443979dbb15972b397e8ac1bbbd5cd2 (patch) | |
tree | 0e6bafd1a1dabad2affefdaed295f780fcc6f65b /Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal | |
parent | Migrating Additional projects (diff) | |
download | VIATRA-Generator-10d272818443979dbb15972b397e8ac1bbbd5cd2.tar.gz VIATRA-Generator-10d272818443979dbb15972b397e8ac1bbbd5cd2.tar.zst VIATRA-Generator-10d272818443979dbb15972b397e8ac1bbbd5cd2.zip |
Added generated Xtext artefacts
Diffstat (limited to 'Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal')
-rw-r--r-- | Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java new file mode 100644 index 00000000..5f7c26a8 --- /dev/null +++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * generated by Xtext | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.ui.internal; | ||
5 | |||
6 | import java.util.Collections; | ||
7 | import java.util.Map; | ||
8 | |||
9 | import org.apache.log4j.Logger; | ||
10 | import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
11 | import org.eclipse.xtext.ui.shared.SharedStateModule; | ||
12 | import org.eclipse.xtext.util.Modules2; | ||
13 | import org.osgi.framework.BundleContext; | ||
14 | |||
15 | import com.google.common.collect.Maps; | ||
16 | import com.google.inject.Guice; | ||
17 | import com.google.inject.Injector; | ||
18 | import com.google.inject.Module; | ||
19 | |||
20 | /** | ||
21 | * This class was generated. Customizations should only happen in a newly | ||
22 | * introduced subclass. | ||
23 | */ | ||
24 | public class AlloyLanguageActivator extends AbstractUIPlugin { | ||
25 | |||
26 | public static final String HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE = "hu.bme.mit.inf.dslreasoner.AlloyLanguage"; | ||
27 | |||
28 | private static final Logger logger = Logger.getLogger(AlloyLanguageActivator.class); | ||
29 | |||
30 | private static AlloyLanguageActivator INSTANCE; | ||
31 | |||
32 | private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1)); | ||
33 | |||
34 | @Override | ||
35 | public void start(BundleContext context) throws Exception { | ||
36 | super.start(context); | ||
37 | INSTANCE = this; | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public void stop(BundleContext context) throws Exception { | ||
42 | injectors.clear(); | ||
43 | INSTANCE = null; | ||
44 | super.stop(context); | ||
45 | } | ||
46 | |||
47 | public static AlloyLanguageActivator getInstance() { | ||
48 | return INSTANCE; | ||
49 | } | ||
50 | |||
51 | public Injector getInjector(String language) { | ||
52 | synchronized (injectors) { | ||
53 | Injector injector = injectors.get(language); | ||
54 | if (injector == null) { | ||
55 | injectors.put(language, injector = createInjector(language)); | ||
56 | } | ||
57 | return injector; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | protected Injector createInjector(String language) { | ||
62 | try { | ||
63 | Module runtimeModule = getRuntimeModule(language); | ||
64 | Module sharedStateModule = getSharedStateModule(); | ||
65 | Module uiModule = getUiModule(language); | ||
66 | Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule); | ||
67 | return Guice.createInjector(mergedModule); | ||
68 | } catch (Exception e) { | ||
69 | logger.error("Failed to create injector for " + language); | ||
70 | logger.error(e.getMessage(), e); | ||
71 | throw new RuntimeException("Failed to create injector for " + language, e); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | protected Module getRuntimeModule(String grammar) { | ||
76 | if (HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE.equals(grammar)) { | ||
77 | return new hu.bme.mit.inf.dslreasoner.AlloyLanguageRuntimeModule(); | ||
78 | } | ||
79 | |||
80 | throw new IllegalArgumentException(grammar); | ||
81 | } | ||
82 | |||
83 | protected Module getUiModule(String grammar) { | ||
84 | if (HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE.equals(grammar)) { | ||
85 | return new hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageUiModule(this); | ||
86 | } | ||
87 | |||
88 | throw new IllegalArgumentException(grammar); | ||
89 | } | ||
90 | |||
91 | protected Module getSharedStateModule() { | ||
92 | return new SharedStateModule(); | ||
93 | } | ||
94 | |||
95 | } | ||