diff options
author | Ralf Mollik | 2018-04-04 08:46:13 +0000 |
---|---|---|
committer | Ralf Mollik | 2018-04-04 08:46:13 +0000 |
commit | 135e2f3f6ea5306b6edc09a5d28b05e8fc597cce (patch) | |
tree | 574bdc72bec8863c31435dd17d04ad0e7abbdfcd | |
parent | bb2e78b9d0cda94e617f1e910397c099ce16d2ac (diff) | |
download | org.eclipse.osbp.xtext.topology-135e2f3f6ea5306b6edc09a5d28b05e8fc597cce.tar.gz org.eclipse.osbp.xtext.topology-135e2f3f6ea5306b6edc09a5d28b05e8fc597cce.tar.xz org.eclipse.osbp.xtext.topology-135e2f3f6ea5306b6edc09a5d28b05e8fc597cce.zip |
rename file
-rw-r--r-- | org.eclipse.osbp.xtext.topologydsl.ui/src-gen/org/eclipse/osbp/xtext/topologydsl/ui/internal/TopologydslActivator.java | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/org.eclipse.osbp.xtext.topologydsl.ui/src-gen/org/eclipse/osbp/xtext/topologydsl/ui/internal/TopologydslActivator.java b/org.eclipse.osbp.xtext.topologydsl.ui/src-gen/org/eclipse/osbp/xtext/topologydsl/ui/internal/TopologydslActivator.java new file mode 100644 index 0000000..a41abad --- /dev/null +++ b/org.eclipse.osbp.xtext.topologydsl.ui/src-gen/org/eclipse/osbp/xtext/topologydsl/ui/internal/TopologydslActivator.java @@ -0,0 +1,106 @@ +/** + * + * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation + * + * generated by Xtext 2.11.0 + * + */ + +package org.eclipse.osbp.xtext.topologydsl.ui.internal; + +import com.google.common.collect.Maps; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Module; +import java.util.Collections; +import java.util.Map; +import org.apache.log4j.Logger; +import org.eclipse.osbp.xtext.topologydsl.TopologyDSLRuntimeModule; +import org.eclipse.osbp.xtext.topologydsl.ui.TopologyDSLUiModule; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.xtext.ui.shared.SharedStateModule; +import org.eclipse.xtext.util.Modules2; +import org.osgi.framework.BundleContext; + +/** + * This class was generated. Customizations should only happen in a newly + * introduced subclass. + */ +public class TopologydslActivator extends AbstractUIPlugin { + + public static final String ORG_ECLIPSE_OSBP_XTEXT_TOPOLOGYDSL_TOPOLOGYDSL = "org.eclipse.osbp.xtext.topologydsl.TopologyDSL"; + + private static final Logger logger = Logger.getLogger(TopologydslActivator.class); + + private static TopologydslActivator INSTANCE; + + private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1)); + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + INSTANCE = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + injectors.clear(); + INSTANCE = null; + super.stop(context); + } + + public static TopologydslActivator getInstance() { + return INSTANCE; + } + + public Injector getInjector(String language) { + synchronized (injectors) { + Injector injector = injectors.get(language); + if (injector == null) { + injectors.put(language, injector = createInjector(language)); + } + return injector; + } + } + + protected Injector createInjector(String language) { + try { + Module runtimeModule = getRuntimeModule(language); + Module sharedStateModule = getSharedStateModule(); + Module uiModule = getUiModule(language); + Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule); + return Guice.createInjector(mergedModule); + } catch (Exception e) { + logger.error("Failed to create injector for " + language); + logger.error(e.getMessage(), e); + throw new RuntimeException("Failed to create injector for " + language, e); + } + } + + protected Module getRuntimeModule(String grammar) { + if (ORG_ECLIPSE_OSBP_XTEXT_TOPOLOGYDSL_TOPOLOGYDSL.equals(grammar)) { + return new TopologyDSLRuntimeModule(); + } + throw new IllegalArgumentException(grammar); + } + + protected Module getUiModule(String grammar) { + if (ORG_ECLIPSE_OSBP_XTEXT_TOPOLOGYDSL_TOPOLOGYDSL.equals(grammar)) { + return new TopologyDSLUiModule(this); + } + throw new IllegalArgumentException(grammar); + } + + protected Module getSharedStateModule() { + return new SharedStateModule(); + } + +} |