blob: df567cfdc1e5142f01596b004e4891578c2f19ce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
* generated by Xtext
*/
package org.eclipse.papyrus.infra.gmfdiag.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 com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import java.util.concurrent.ExecutionException;
import org.eclipse.xtext.ui.shared.SharedStateModule;
/**
* This class was generated. Customizations should only happen in a newly
* introduced subclass.
*/
public class CSSActivator extends AbstractUIPlugin {
private static final Logger logger = Logger.getLogger(CSSActivator.class);
private Cache<String, Injector> injectors = CacheBuilder.newBuilder().build(new CacheLoader<String, Injector>() {
@Override
public Injector load(String language) throws Exception {
Module runtimeModule = getRuntimeModule(language);
Module sharedStateModule = getSharedStateModule();
Module uiModule = getUiModule(language);
Module mergedModule = override(override(runtimeModule).with(sharedStateModule)).with(uiModule);
return createInjector(mergedModule);
}
});
private static CSSActivator INSTANCE;
public static final String ORG_ECLIPSE_PAPYRUS_INFRA_GMFDIAG_CSS = "org.eclipse.papyrus.infra.gmfdiag.CSS";
public Injector getInjector(String languageName) {
try {
return injectors.get(languageName);
} catch(ExecutionException e) {
logger.error("Failed to create injector for " + languageName);
logger.error(e.getMessage(), e);
throw new RuntimeException("Failed to create injector for " + languageName, e);
}
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
INSTANCE = this;
}
@Override
public void stop(BundleContext context) throws Exception {
injectors.invalidateAll();
injectors.cleanUp();
INSTANCE = null;
super.stop(context);
}
public static CSSActivator getInstance() {
return INSTANCE;
}
protected Module getRuntimeModule(String grammar) {
if (ORG_ECLIPSE_PAPYRUS_INFRA_GMFDIAG_CSS.equals(grammar)) {
return new org.eclipse.papyrus.infra.gmfdiag.CSSRuntimeModule();
}
throw new IllegalArgumentException(grammar);
}
protected Module getUiModule(String grammar) {
if (ORG_ECLIPSE_PAPYRUS_INFRA_GMFDIAG_CSS.equals(grammar)) {
return new org.eclipse.papyrus.infra.gmfdiag.ui.CSSUiModule(this);
}
throw new IllegalArgumentException(grammar);
}
protected Module getSharedStateModule() {
return new SharedStateModule();
}
}
|