Просмотр исходного кода

Introduce interface to post-configure a domain module (#1907)

Rene Beckmann 8 лет назад
Родитель
Сommit
36b4ebfb1b

+ 8 - 4
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/execution/GeneratorExecutorLookup.java

@@ -6,7 +6,7 @@
  * http://www.eclipse.org/legal/epl-v10.html
  * Contributors:
  * 	committers of YAKINDU - initial API and implementation
- * 
+ *
  */
 package org.yakindu.sct.generator.core.execution;
 
@@ -29,9 +29,9 @@ import com.google.inject.Module;
 import com.google.inject.util.Modules;
 
 /**
- * 
+ *
  * @author andreas muelder - Initial contribution and API
- * 
+ *
  */
 public class GeneratorExecutorLookup {
 
@@ -89,7 +89,11 @@ public class GeneratorExecutorLookup {
 	}
 
 	protected Module getDomainGeneratorModule(GeneratorEntry entry, String generatorId) {
-		return DomainRegistry.getDomain(entry.getElementRef()).getModule(IDomain.FEATURE_GENERATOR,
+		Module module = DomainRegistry.getDomain(entry.getElementRef()).getModule(IDomain.FEATURE_GENERATOR,
 				generatorId);
+		if (module instanceof IGeneratorEntryModuleExtension) {
+			((IGeneratorEntryModuleExtension) module).setGeneratorEntry(entry);
+		}
+		return module;
 	}
 }

+ 21 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/execution/IGeneratorEntryModuleExtension.java

@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2018 committers of YAKINDU and others.
+ * 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:
+ * 	rbeckmann - initial API and implementation
+ *
+ */
+package org.yakindu.sct.generator.core.execution;
+
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+/**
+ * @author rbeckmann
+ *
+ */
+public interface IGeneratorEntryModuleExtension {
+	public void setGeneratorEntry(GeneratorEntry entry);
+}

+ 4 - 2
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/extensions/GeneratorExtensions.java

@@ -71,7 +71,8 @@ public class GeneratorExtensions {
 		@Override
 		public Module getBindings(GeneratorEntry entry) {
 			try {
-				IGeneratorModule module = (IGeneratorModule) configElement.createExecutableExtension(ATTRIBUTE_BINDINGS);
+				IGeneratorModule module = (IGeneratorModule) configElement
+						.createExecutableExtension(ATTRIBUTE_BINDINGS);
 				return new GeneratorModuleAdapter(module, entry);
 			} catch (CoreException e) {
 				e.printStackTrace();
@@ -81,7 +82,7 @@ public class GeneratorExtensions {
 
 		@Override
 		public List<String> getLibraryIDs() {
-			List<String> libs = new ArrayList<String>();
+			List<String> libs = new ArrayList<>();
 			for (IConfigurationElement child : configElement.getChildren(LIBRARY_CONFIG_ELEMENT)) {
 				String lib_id = child.getAttribute(ATTRIBUTE_LIBRARY_ID);
 				if (lib_id != null && !lib_id.isEmpty()) {
@@ -160,6 +161,7 @@ public class GeneratorExtensions {
 	public static IGeneratorDescriptor getGeneratorDescriptor(final String generatorId) {
 		try {
 			return Iterables.find(getGeneratorDescriptors(), new Predicate<IGeneratorDescriptor>() {
+				@Override
 				public boolean apply(IGeneratorDescriptor input) {
 					return input != null && input.getId() != null && input.getId().equals(generatorId);
 				}