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

#366 : decouple EFS aspects from generator.core (WORK IN PROGRESS)

- introduced SCTFileSystemAccess to get minimal dependencies to
xtext.FileSystemAccess dependencies
-- implementations: EFS & Headless
- introduced SGen utils for convenience access features
- removed IGeneratorBridge


known issues: 
- EFSResourceFileSystemAccess
-- public static IProject getTargetProject(GeneratorEntry entry)
-- some generators have to be migrated to SctFileSystemAccess
Johannes Dicks 10 лет назад
Родитель
Сommit
be69cb4e64
34 измененных файлов с 1294 добавлено и 926 удалено
  1. 10 2
      plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java
  2. 1 3
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java
  3. 7 9
      plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Types.xtend
  4. 4 0
      plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF
  5. 9 28
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/AbstractWorkspaceGenerator.java
  6. 18 21
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/GeneratorExecutor.java
  7. 0 39
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/IGeneratorBridge.java
  8. 204 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/EFSResourceFileSystemAccess.java
  9. 186 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/HeadlessFileSystemAccess.java
  10. 68 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/SCTFileSystemAccess.java
  11. 26 13
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java
  12. 33 104
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java
  13. 185 163
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractXpandBasedCodeGenerator.java
  14. 20 27
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java
  15. 1 1
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericXPandCodeGenerator.java
  16. 11 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/IGeneratorLog.java
  17. 0 71
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/SimpleResourceFileSystemAccess.java
  18. 36 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/BaseSGenFeatureHelper.java
  19. 34 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/DebugFeatureHelperImpl.java
  20. 25 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/IDebugFeatureHelper.java
  21. 30 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/IOutletFeatureHelper.java
  22. 51 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/OutletFeatureHelperImpl.java
  23. 69 0
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/util/EclipseConsoleLog.java
  24. 0 137
      plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/util/GeneratorUtils.java
  25. 53 57
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java
  26. 4 4
      plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend
  27. 0 35
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/AbstractJavaCodeGenerator.java
  28. 3 5
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/IStatemachine.xtend
  29. 4 6
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ITimer.xtend
  30. 3 6
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ITimerCallback.xtend
  31. 5 11
      plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java
  32. 12 0
      plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/resource/AbstractSCTResource.java
  33. 87 86
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/partitioning/DiagramEditorInput.java
  34. 95 98
      test-plugins/org.yakindu.sct.generator.java.test/src/org/yakindu/sct/generator/java/util/AbstractJavaGeneratorTest.java

+ 10 - 2
plugins/org.yakindu.sct.domain.generic/src/org/yakindu/sct/domain/generic/extension/GenericDomainInjectorProvider.java

@@ -10,9 +10,11 @@
  */
 package org.yakindu.sct.domain.generic.extension;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.ui.shared.SharedStateModule;
 import org.yakindu.sct.domain.extension.IDomainInjectorProvider;
@@ -33,6 +35,7 @@ import org.yakindu.sct.model.stext.stext.TransitionSpecification;
 import org.yakindu.sct.model.stext.ui.STextUiModule;
 import org.yakindu.sct.model.stext.ui.internal.STextActivator;
 
+import com.google.common.collect.Lists;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Module;
@@ -124,8 +127,13 @@ public class GenericDomainInjectorProvider implements IDomainInjectorProvider {
 	
 	@Override
 	public Injector getSequencerInjector(Module overrides) {
-		if(overrides != null) {
-			return Guice.createInjector(Modules.override(getSequencerModule()).with(overrides));
+		ArrayList<Module> tmpOverrides = Lists.newArrayList(overrides);
+		//FIXME !!! argh... get rid of that :)
+		if(Platform.isRunning()){
+			tmpOverrides.add(getSharedStateModule());
+		}
+		if(tmpOverrides != null) {
+			return Guice.createInjector(Modules.override(getSequencerModule()).with(tmpOverrides));
 		}
 		return getSequencerInjector();
 	}

+ 1 - 3
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/CCodeGenerator.java

@@ -12,8 +12,6 @@
  */
 package org.yakindu.sct.generator.c;
 
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
-
 import org.yakindu.sct.domain.generic.modules.GenericSequencerModule;
 import org.yakindu.sct.generator.c.features.ICFeatureConstants;
 import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
@@ -43,7 +41,7 @@ public class CCodeGenerator extends GenericJavaBasedGenerator {
 	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
 		CGenerator delegate = getInjector(entry).getInstance(CGenerator.class);
 		ExecutionFlow flow = createExecutionFlow(statechart, entry);
-		if (isDumpSexec(entry)) {
+		if (debugFeatureHelper.isDumpSexec(entry)) {
 			dumpSexec(entry, flow);
 		}
 		delegate.generate(flow, entry, getFileSystemAccess(entry));

+ 7 - 9
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/Types.xtend

@@ -15,12 +15,11 @@ import org.eclipse.core.resources.ResourcesPlugin
 import org.eclipse.core.runtime.Path
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
-import org.yakindu.sct.generator.core.impl.SimpleResourceFileSystemAccess
-import org.yakindu.sct.generator.core.util.GeneratorUtils
+import org.yakindu.sct.model.sgraph.Statechart
+import org.yakindu.sct.generator.core.filesystem.EFSResourceFileSystemAccess
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
-import org.yakindu.sct.model.sgraph.Statechart
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl
 
 class Types {
 
@@ -28,21 +27,20 @@ class Types {
 	@Inject extension GenmodelEntries
 
 	def generateTypesH(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
-		if (GeneratorUtils.getOutletFeatureConfiguration(entry).getParameterValue(
-			OUTLET_FEATURE_LIBRARY_TARGET_FOLDER) != null) {
+		if (new OutletFeatureHelperImpl().getLibraryTargetFolderValue(entry) != null) {
 			// sc_types.h is static, so we use the library target folder in case its configured
 			fsa.generateFile(flow.typesModule.h, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT,
 				flow.typesHContent(entry))
 		} else {
 			// use default target folder path in case no library target folder is specified (the file will be overwritten there)
-			if (fsa instanceof SimpleResourceFileSystemAccess &&
-				!exists(flow.typesModule.h, fsa as SimpleResourceFileSystemAccess)) {
+			if (fsa instanceof EFSResourceFileSystemAccess &&
+				!exists(flow.typesModule.h, fsa as EFSResourceFileSystemAccess)) {
 				fsa.generateFile(flow.typesModule.h, flow.typesHContent(entry))
 			}
 		}
 	}
 
-	def protected exists(String filename, SimpleResourceFileSystemAccess fsa) {
+	def protected exists(String filename, EFSResourceFileSystemAccess fsa) {
 		val uri = fsa.getURI(filename);
 		val file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true)));
 		return file.exists;

+ 4 - 0
plugins/org.yakindu.sct.generator.core/META-INF/MANIFEST.MF

@@ -24,6 +24,7 @@ Require-Bundle: org.eclipse.ui,
  org.yakindu.sct.commons,
  org.yakindu.sct.domain,
  org.yakindu.sct.domain.generic,
+ com.google.guava,
  org.eclipse.emf.workspace
 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
 Bundle-ActivationPolicy: lazy
@@ -31,6 +32,9 @@ Export-Package: org.yakindu.sct.builder.nature,
  org.yakindu.sct.generator.core,
  org.yakindu.sct.generator.core.extensions,
  org.yakindu.sct.generator.core.features,
+ org.yakindu.sct.generator.core.features.impl,
+ org.yakindu.sct.generator.core.filesystem,
  org.yakindu.sct.generator.core.impl,
+ org.yakindu.sct.generator.core.library,
  org.yakindu.sct.generator.core.types,
  org.yakindu.sct.generator.core.util

+ 9 - 28
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/AbstractWorkspaceGenerator.java

@@ -12,49 +12,30 @@ package org.yakindu.sct.generator.core;
 
 import java.io.File;
 
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.generator.core.impl.AbstractSExecModelGenerator;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 
 /**
  * Base class for generators that are executed inside the workspace
  * 
  * @author holger willebrandt - Initial contribution and API
- */
-public abstract class AbstractWorkspaceGenerator implements IGeneratorBridge {
-
-	private IGeneratorBridge bridge;
-
-	public final void setBridge(IGeneratorBridge bridge) {
-		this.bridge = bridge;
-	}
-
-	public final void writeToConsole(String s) {
-		bridge.writeToConsole(s);
-	}
-
-	public final void writeToConsole(Throwable t) {
-		bridge.writeToConsole(t);
-	}
-
-	public final FeatureParameterValue getFeatureParameter(
-			GeneratorEntry entry, String featureName, String paramName) {
-		return bridge.getFeatureParameter(entry, featureName, paramName);
-	}
-
+ */ 
+//FIXME !!! used in generator samples (Xtend2 & Java)
+public abstract class AbstractWorkspaceGenerator extends AbstractSExecModelGenerator {
+	
 	public final void refreshTargetProject(GeneratorEntry entry) {
-		bridge.refreshTargetProject(entry);
+		
 	}
 
 	public final File getTargetProject(GeneratorEntry entry) {
-		return bridge.getTargetProject(entry);
+		return null;
 	}
 
 	public final File getTargetFolder(GeneratorEntry entry) {
-		return bridge.getTargetFolder(entry);
+		return null;
 	}
 	
 	public final File getLibraryTargetFolder(GeneratorEntry entry) {
-		return bridge.getLibraryTargetFolder(entry);
+		return null;
 	}
-
 }

+ 18 - 21
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/GeneratorExecutor.java

@@ -37,24 +37,12 @@ public class GeneratorExecutor {
 		if (resource == null || resource.getContents().size() == 0
 				|| resource.getErrors().size() > 0)
 			return;
-		GeneratorModel model = (GeneratorModel) resource.getContents().get(0);
-
-		String generatorId = model.getGeneratorId();
-		IGeneratorDescriptor description = GeneratorExtensions
-				.getGeneratorDescriptor(generatorId);
-		if (description == null)
-			return;
-		final ISCTGenerator generator = description.createGenerator();
-		final EList<GeneratorEntry> entries = model.getEntries();
+		final GeneratorModel model = (GeneratorModel) resource.getContents().get(0);
+		
 		Job generatorJob = new Job("Execute SCT Genmodel " + file.getName()) {
 			@Override
 			protected IStatus run(IProgressMonitor monitor) {
-				for (GeneratorEntry generatorEntry : entries) {
-					if (monitor.isCanceled()) {
-						break;
-					}
-					generator.generate(generatorEntry);
-				}
+				executeGenerator(model);
 				return Status.OK_STATUS;
 			}
 		};
@@ -65,12 +53,8 @@ public class GeneratorExecutor {
 
 	public void executeGenerator(GeneratorModel model) {
 
-		String generatorId = model.getGeneratorId();
-		IGeneratorDescriptor description = GeneratorExtensions
-				.getGeneratorDescriptor(generatorId);
-		if (description == null)
-			throw new RuntimeException("No generator registered for ID: " + generatorId);
-		final ISCTGenerator generator = description.createGenerator();
+		final ISCTGenerator generator = getGenerator(model);
+		
 		final EList<GeneratorEntry> entries = model.getEntries();
 
 		for (GeneratorEntry generatorEntry : entries) {
@@ -78,6 +62,19 @@ public class GeneratorExecutor {
 		}
 	}
 
+	protected ISCTGenerator getGenerator(GeneratorModel model) {
+		String generatorId = model.getGeneratorId();
+		IGeneratorDescriptor description = GeneratorExtensions
+				.getGeneratorDescriptor(generatorId);
+		if (description == null)
+			throw new RuntimeException("No generator registered for ID: " + generatorId);
+		final ISCTGenerator generator = description.createGenerator();
+			if(generator == null)
+				throw new RuntimeException("Failed to create Generator instance for ID:"+generatorId);
+			
+		return generator;
+	}
+	
 	protected Resource loadResource(IFile file) {
 		Resource resource = null;
 		URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(),

+ 0 - 39
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/IGeneratorBridge.java

@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2011 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:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.generator.core;
-
-import java.io.File;
-
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-
-/**
- * bridges common generator functionality between plugin and runtime workspace
- * 
- * @author holger willebrandt - Initial contribution and API
- */
-public interface IGeneratorBridge {
-
-	void writeToConsole(String s);
-
-	void writeToConsole(Throwable t);
-
-	FeatureParameterValue getFeatureParameter(GeneratorEntry entry,
-			String featureName, String paramName);
-
-	void refreshTargetProject(GeneratorEntry entry);
-
-	File getTargetProject(GeneratorEntry entry);
-
-	File getTargetFolder(GeneratorEntry entry);
-	
-	File getLibraryTargetFolder(GeneratorEntry entry);
-}

+ 204 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/EFSResourceFileSystemAccess.java

@@ -0,0 +1,204 @@
+/** 
+ * Copyright (c) 2015 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:
+ * committers of YAKINDU - initial API and implementation
+ *
+*/
+package org.yakindu.sct.generator.core.filesystem;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.OutputConfiguration;
+import org.eclipse.xtext.util.StringInputStream;
+import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl;
+import org.yakindu.sct.generator.core.util.ClasspathChanger;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+public class EFSResourceFileSystemAccess extends EclipseResourceFileSystemAccess2 implements SCTFileSystemAccess {
+
+	/**
+	 * Returns an IProject for the configured target project. The
+	 * {@link IProject} is returned even if the project does not exist yet.
+	 * 
+	 * @param entry
+	 * @return
+	 */
+	public static IProject getTargetProject(GeneratorEntry entry) {
+		String stringValue = new OutletFeatureHelperImpl().getTargetProjectValue(entry).getStringValue();
+		if (Platform.isRunning()) {
+
+			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(stringValue);
+
+			return project;
+		} else
+			throw new IllegalStateException("The " + EFSResourceFileSystemAccess.class.getSimpleName()
+					+ " needs a running " + Platform.class.getName());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.xtext.generator.AbstractFileSystemAccess#setOutputPath(java.
+	 * lang.String, java.lang.String)
+	 */
+	@Override
+	public void setOutputPath(String outputName, String path) {
+		super.setOutputPath(outputName, path);
+		// FIXME !!! ??? setting the targetProject has to be done firstly
+		trySetTargetProject(outputName, path);
+		// otherwise java classpath extension will fail, MSG?
+//		if (isOutputFolder(outputName)) {
+			IProject project = getProject();
+			if (isValidProject(project)) {
+				// FIXME !!! classpathchanger!?
+				if (hasJavaNature(project) && hasClasspath(project)) {
+					new ClasspathChanger().addFolderToClassPath(project, path);
+				}
+			}
+//		}
+	}
+//FIXME !!! ???
+//	protected boolean isOutputFolder(String outputName) {
+//		return outputName.equals(IFileSystemAccess.DEFAULT_OUTPUT)
+//				|| outputName.equals(ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER)
+//				|| outputName.equals(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER);
+//	}
+
+	protected void trySetTargetProject(String outputName, String path) {
+		if (outputName.equals(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT)) {
+			IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path);
+			if (!project.exists()) {
+				createProject(project);
+			}
+			setProject(project);
+		}
+	}
+
+	protected boolean isValidProject(IProject project) {
+		return project != null && project.exists();
+	}
+
+	public boolean hasJavaNature(IProject project) {
+		try {
+			String[] natures = project.getDescription().getNatureIds();
+			for (String s : natures) {
+				if (s.equals(JavaCore.NATURE_ID))
+					return true;
+			}
+		} catch (CoreException e1) {
+			e1.printStackTrace();
+		}
+		return false;
+	}
+
+	public boolean hasClasspath(IProject project) {
+		return project.getFile(".classpath").exists();
+	}
+
+	/**
+	 * The default implementation only creates a new default project. Clients
+	 * may override if they want to contribute generator specific project setup
+	 */
+	protected void createProject(IProject project) {
+		if (!project.exists()) {
+			try {
+				NullProgressMonitor monitor = new NullProgressMonitor();
+				project.create(monitor);
+				project.open(monitor);
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public void generateFile(String fileName, String outputName, CharSequence contents) {
+
+		OutputConfiguration outputConfig = getOutputConfig(outputName);
+
+		IContainer container = getContainer(outputConfig);
+
+		if (!container.exists()) {
+			if (outputConfig.isCreateOutputDirectory()) {
+				try {
+					createContainer(container);
+				} catch (CoreException e) {
+					throw new RuntimeException(e);
+				}
+			} else {
+				return;
+			}
+		}
+
+		IFile file = getFile(fileName, outputName);
+		CharSequence postProcessedContent = postProcess(fileName, outputName, contents);
+		String contentsAsString = postProcessedContent.toString();
+		if (file.exists()) {
+			if (outputConfig.isOverrideExistingResources()) {
+				try {
+					StringInputStream newContent = getInputStream(contentsAsString, getEncoding(file));
+					if (hasContentsChanged(file, newContent)) {
+						newContent.reset();
+						file.setContents(newContent, true, true, null);
+						if (file.isDerived() != outputConfig.isSetDerivedProperty()) {
+							setDerived(file, outputConfig.isSetDerivedProperty());
+						}
+					}
+				} catch (CoreException e) {
+					throw new RuntimeException(e);
+				}
+			}
+		} else {
+			try {
+				ensureParentExists(file);
+				file.create(getInputStream(contentsAsString, getEncoding(file)), true, null);
+				if (outputConfig.isSetDerivedProperty()) {
+					setDerived(file, true);
+				}
+			} catch (CoreException e) {
+				throw new RuntimeException(e);
+			}
+		}
+	}
+
+	@Override
+	public IFileSystemAccess getIFileSystemAccess() {
+		return this;
+	}
+
+	@Override
+	public void afterGeneration() {
+		IProject project = getProject();
+		if (isValidProject(project)) {
+			try {
+				project.refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
+			} catch (CoreException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	@Override
+	public URI getURI(String path) {
+		IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromPortableString(path));
+		if (file != null) {
+			return URI.createFileURI(file.getLocationURI().getPath());
+		}
+		return super.getURI(path);
+	}
+}

+ 186 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/HeadlessFileSystemAccess.java

@@ -0,0 +1,186 @@
+package org.yakindu.sct.generator.core.filesystem;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.generator.AbstractFileSystemAccess;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.OutputConfiguration;
+import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+public class HeadlessFileSystemAccess extends AbstractFileSystemAccess implements SCTFileSystemAccess {
+	public static final String BASE_DIR = "filesystemAccess.absolute.baseDir";
+	public static final String ENCODING = "filesystemAccess.encoding";
+
+	@Inject
+	@Named(ENCODING)
+	protected String ENCODING_UTF_8;
+	@Inject
+	@Named(BASE_DIR)
+	protected String absoluteBaseDir;
+
+	@Override
+	public void generateFile(String fileName, String outputConfigurationName, CharSequence contents) {
+		// validate setup
+		validateFileSystemAccess();
+
+		OutputConfiguration outputConfig = getOutputConfig(outputConfigurationName);
+
+		File outputDir = getOutputDir(outputConfig);
+
+		String contentsAsString = doPostProcesses(fileName, outputConfigurationName, contents);
+
+		File outputFile = new File(outputDir, fileName);
+		if (outputFile.exists()) {
+			if (outputConfig.isOverrideExistingResources()) {
+				tryOverride(contentsAsString, outputFile);
+			}
+		} else {
+			outputFile.getParentFile().mkdirs();
+			try {
+				outputFile.createNewFile();
+			} catch (IOException e) {
+				throw new RuntimeException(e);
+			}
+			writeContent(contentsAsString, outputFile, ENCODING_UTF_8);
+		}
+	}
+
+	protected void validateFileSystemAccess() {
+		if (this.absoluteBaseDir == null || this.absoluteBaseDir.isEmpty())
+			throw new IllegalStateException("the base dir must have been set");
+	}
+
+	protected void tryOverride(String contentsAsString, File outputFile) {
+		String currentContent = getCurrentContent(outputFile);
+		if (isSame(contentsAsString, currentContent)) {
+			writeContent(contentsAsString, outputFile, ENCODING_UTF_8);
+		} else {
+			// ignore same content...
+		}
+	}
+
+	/**
+	 * Respects 'Pigeonhole_principle'.
+	 * @see https://en.wikipedia.org/wiki/Pigeonhole_principle
+	 * @param newContent
+	 * @param currentContent
+	 * @return
+	 */
+	protected boolean isSame(String newContent, String currentContent) {
+		return currentContent.hashCode() != newContent.hashCode() &&
+				/* Pigeonhole_principle */currentContent.equals(newContent);
+	}
+
+	protected String getCurrentContent(File outputFile) {
+		String currentContent = null;
+		BufferedReader reader = null;
+		try {
+			reader = new BufferedReader(new FileReader(outputFile));
+			String line = null;
+			StringBuilder stringBuilder = new StringBuilder();
+			String ls = System.getProperty("line.separator");
+			while ((line = reader.readLine()) != null) {
+				stringBuilder.append(line);
+				stringBuilder.append(ls);
+			}
+			currentContent = stringBuilder.toString();
+		} catch (FileNotFoundException e1) {
+			throw new RuntimeException("Error during load of current file", e1);
+		} catch (IOException e) {
+			throw new RuntimeException("Error during load of current file", e);
+		} finally {
+			try {
+				reader.close();
+			} catch (IOException e) {
+				// ignore
+			}
+		}
+		return currentContent;
+	}
+
+	protected String doPostProcesses(String fileName, String outputConfigurationName, CharSequence contents) {
+		CharSequence postProcessedContent = postProcess(fileName, outputConfigurationName, contents);
+		String contentsAsString = postProcessedContent.toString();
+		return contentsAsString;
+	}
+
+	protected File getOutputDir(OutputConfiguration outputConfig) {
+		String fullPath = getFullPath(outputConfig);
+		File outputDir = new File(fullPath);
+		if (!outputDir.exists()) {
+			if (outputConfig.isCreateOutputDirectory()) {
+				outputDir.mkdirs();
+			} else {
+				outputDir = null;
+			}
+		}
+		return outputDir;
+	}
+
+	protected String getFullPath(OutputConfiguration outputConfig) {
+		String outputDirectory = outputConfig.getOutputDirectory();
+		String fullPath = absoluteBaseDir + File.separator
+				+ getOutputConfig(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT).getOutputDirectory()
+				+ File.separator + outputDirectory;
+		return fullPath;
+	}
+
+	protected void writeContent(String contentsAsString, File outputFile, String encoding) {
+		Writer out = null;
+		try {
+			out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), encoding));
+			out.write(contentsAsString);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		} finally {
+			try {
+				if (out != null)
+					out.close();
+			} catch (IOException e) {
+				// ignore
+			}
+
+		}
+	}
+
+	@Override
+	public URI getURI(String path, String outputConfiguration) {
+		OutputConfiguration outputConfig = getOutputConfig(outputConfiguration);
+		return URI.createFileURI(getFullPath(outputConfig) + File.separator + path);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.yakindu.sct.generator.core.filesystem.SCTFileSystemAccess#
+	 * getIFileSystemAccess()
+	 */
+	@Override
+	public IFileSystemAccess getIFileSystemAccess() {
+		return this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.yakindu.sct.generator.core.filesystem.SCTFileSystemAccess#
+	 * afterGeneration()
+	 */
+	@Override
+	public void afterGeneration() {
+		// currently nothing
+	}
+
+}

+ 68 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/filesystem/SCTFileSystemAccess.java

@@ -0,0 +1,68 @@
+/**
+ * Copyright (c) 2016 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:
+ * 		committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.filesystem;
+
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.eclipse.xtext.generator.OutputConfiguration;
+
+/**
+ * Is meant to be some kind of bridge between file system
+ * mappings within SCT (SGEN) & the xtext.generator.IFileSystemAccess.
+ *
+ * The SCT M2T generators use the minimal functionality provided by the
+ * basic interface xtext.generator.IFileSystemAccess during transformation.
+ * 
+ * So the methods 
+ * 
+ * @see {@link org.eclipse.xtext.generator.IFileSystemAccess}
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public interface SCTFileSystemAccess {
+
+	/**
+	 * Provides an absolute URI for further processing.
+	 * 
+	 * @param string
+	 * @return
+	 */
+	URI getURI(String path);
+
+	/**
+	 * @param outletFeatureTargetProject
+	 * @param stringValue
+	 */
+	void setOutputPath(String outputName, String path);
+
+	/**
+	 * @return
+	 */
+	Map<String, OutputConfiguration> getOutputConfigurations();
+
+	/**
+	 * For convenience... and compatibility reasons, might be removed in further
+	 * versions
+	 * 
+	 * @return
+	 * 
+	 */
+	IFileSystemAccess getIFileSystemAccess();
+
+	/**
+	 * @param entry
+	 */
+	void afterGeneration();
+
+}

+ 26 - 13
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSExecModelGenerator.java

@@ -20,7 +20,6 @@ import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.F
 import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION;
 import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES;
 import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.FUNCTION_INLINING_FEATURE_INLINE_REACTIONS;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.getBoolValue;
 
 import java.io.IOException;
 import java.util.Collections;
@@ -95,23 +94,37 @@ public abstract class AbstractSExecModelGenerator extends AbstractSGraphModelGen
 
 		FlowOptimizer optimizer = injector.getInstance(FlowOptimizer.class);
 
-		optimizer.inlineReactions(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_REACTIONS, false));
-		optimizer.inlineExitActions(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_ACTIONS, false));
-		optimizer.inlineEntryActions(
-				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRY_ACTIONS, false));
-		optimizer.inlineEnterSequences(
-				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_SEQUENCES, false));
-		optimizer.inlineExitSequences(
-				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES, false));
-		optimizer.inlineChoices(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_CHOICES, false));
-		optimizer.inlineEntries(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRIES, false));
-		optimizer.inlineEnterRegion(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTER_REGION, false));
-		optimizer.inlineExitRegion(getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION, false));
+		optimizer.inlineReactions(
+				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_REACTIONS, false));
+		optimizer.inlineExitActions(getBoolValue(optimizeConfig,
+				FUNCTION_INLINING_FEATURE_INLINE_EXIT_ACTIONS, false));
+		optimizer.inlineEntryActions(getBoolValue(optimizeConfig,
+				FUNCTION_INLINING_FEATURE_INLINE_ENTRY_ACTIONS, false));
+		optimizer.inlineEnterSequences(getBoolValue(optimizeConfig,
+				FUNCTION_INLINING_FEATURE_INLINE_ENTER_SEQUENCES, false));
+		optimizer.inlineExitSequences(getBoolValue(optimizeConfig,
+				FUNCTION_INLINING_FEATURE_INLINE_EXIT_SEQUENCES, false));
+		optimizer.inlineChoices(
+				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_CHOICES, false));
+		optimizer.inlineEntries(
+				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_ENTRIES, false));
+		optimizer.inlineEnterRegion(getBoolValue(optimizeConfig,
+				FUNCTION_INLINING_FEATURE_INLINE_ENTER_REGION, false));
+		optimizer.inlineExitRegion(
+				getBoolValue(optimizeConfig, FUNCTION_INLINING_FEATURE_INLINE_EXIT_REGION, false));
 
 		flow = optimizer.transform(flow);
 
 		return flow;
 	}
+	
+	protected boolean getBoolValue(FeatureConfiguration conf, String param, boolean defaultValue) {
+		if (conf != null && conf.getParameterValue(param) != null) {
+			return conf.getParameterValue(param).getBooleanValue();
+		}
+
+		return defaultValue;
+	}
 
 	protected void dumpSexec(GeneratorEntry entry, ExecutionFlow flow) {
 		ResourceSet resourceSet = new ResourceSetImpl();

+ 33 - 104
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractSGraphModelGenerator.java

@@ -11,27 +11,22 @@
  */
 package org.yakindu.sct.generator.core.impl;
 
-import java.io.File;
-import java.io.PrintWriter;
-
-import org.eclipse.core.resources.IProject;
 import org.eclipse.emf.ecore.EObject;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
 import org.yakindu.sct.domain.extension.DomainRegistry;
-import org.yakindu.sct.generator.core.IGeneratorBridge;
 import org.yakindu.sct.generator.core.ISCTGenerator;
-import org.yakindu.sct.generator.core.util.GeneratorUtils;
+import org.yakindu.sct.generator.core.filesystem.EFSResourceFileSystemAccess;
+import org.yakindu.sct.generator.core.filesystem.SCTFileSystemAccess;
+import org.yakindu.sct.generator.core.library.DebugFeatureHelperImpl;
+import org.yakindu.sct.generator.core.library.IDebugFeatureHelper;
+import org.yakindu.sct.generator.core.library.IOutletFeatureHelper;
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl;
+import org.yakindu.sct.generator.core.util.EclipseConsoleLog;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
 
 import com.google.inject.Binder;
+import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.Module;
 
@@ -45,40 +40,15 @@ import com.google.inject.Module;
 public abstract class AbstractSGraphModelGenerator implements ISCTGenerator {
 
 	public static final String SCT_GENERATOR_CONSOLE = "SCT Generator Console";
-	private final MessageConsoleStream info;
-	private final MessageConsoleStream error;
-
-	protected final IGeneratorBridge bridge = new IGeneratorBridge() {
-
-		public void writeToConsole(Throwable t) {
-			AbstractSGraphModelGenerator.this.writeToConsole(t);
-		}
-
-		public void writeToConsole(String s) {
-			AbstractSGraphModelGenerator.this.writeToConsole(s);
-		}
-
-		public FeatureParameterValue getFeatureParameter(GeneratorEntry entry, String featureName, String paramName) {
-			return GeneratorUtils.getFeatureParameter(entry, featureName, paramName);
-		}
 
-		public void refreshTargetProject(GeneratorEntry entry) {
-			GeneratorUtils.refreshTargetProject(entry);
-		}
-
-		public File getTargetProject(GeneratorEntry entry) {
-			IProject targetProject = AbstractSGraphModelGenerator.this.getTargetProject(entry);
-			return targetProject.getLocation().toFile();
-		}
-
-		public File getTargetFolder(GeneratorEntry entry) {
-			return GeneratorUtils.getTargetFolder(entry);
-		}
-
-		public File getLibraryTargetFolder(GeneratorEntry entry) {
-			return GeneratorUtils.getLibraryTargetFolder(entry);
-		}
-	};
+	@Inject
+	protected IGeneratorLog log;
+	@Inject
+	protected IOutletFeatureHelper outletFeatureHelper;
+	@Inject
+	protected DebugFeatureHelperImpl debugFeatureHelper;
+	@Inject
+	protected SCTFileSystemAccess sctFileSystemAccess;
 
 	protected void runGenerator(Statechart statechart, GeneratorEntry entry) {
 		if (this instanceof ISGraphGenerator) {
@@ -89,32 +59,30 @@ public abstract class AbstractSGraphModelGenerator implements ISCTGenerator {
 
 	public AbstractSGraphModelGenerator() {
 		super();
-		info = getConsole().newMessageStream();
-		error = getConsole().newMessageStream();
-		error.setActivateOnWrite(true);
 	}
 
 	@Override
 	protected void finalize() throws Throwable {
-		info.close();
-		error.close();
+		log.close();
 		super.finalize();
 	}
 
 	public final void generate(GeneratorEntry entry) {
+		getInjector(entry).injectMembers(this);
+
 		EObject element = entry.getElementRef();
 		if (element == null || !(element instanceof Statechart)) {
-			writeToConsole("No Statechart selected in genmodel (" + entry + ")");
+			log.writeToConsole("No Statechart selected in genmodel (" + entry + ")");
 			return;
 		}
 		Statechart statechart = (Statechart) element;
 		try {
-			writeToConsole(String.format("Generating Statechart %s ...", statechart.getName()));
+			log.writeToConsole(String.format("Generating Statechart %s ...", statechart.getName()));
 			prepareGenerator(entry);
 			runGenerator(statechart, entry);
-			writeToConsole("Done.");
+			log.writeToConsole("Done.");
 		} catch (Exception e) {
-			writeToConsole(e);
+			log.writeToConsole(e);
 		} finally {
 			finishGenerator(entry);
 			injector = null;
@@ -125,30 +93,34 @@ public abstract class AbstractSGraphModelGenerator implements ISCTGenerator {
 	 * override this method to do any setup needed before generation
 	 */
 	protected void prepareGenerator(GeneratorEntry entry) {
-		// override if needed
 	}
 
 	/**
 	 * override this method to do any cleanup needed after generation
 	 */
 	protected void finishGenerator(GeneratorEntry entry) {
-		// override if needed
+		sctFileSystemAccess.afterGeneration();
 	}
 
 	private Injector injector;
 
 	protected Injector createInjector(GeneratorEntry entry) {
+		//FIXME !!! right injector, why? 
 		return DomainRegistry.getDomainDescriptor(entry.getElementRef()).getDomainInjectorProvider()
 				.getSequencerInjector(getOverridesModule(entry));
 	}
 
-	protected Module getOverridesModule(GeneratorEntry entry) {
-		Module bridgeModule = new Module() {
+	protected Module getOverridesModule(final GeneratorEntry entry) {
+		Module baseModule = new Module() {
+			@Override
 			public void configure(Binder binder) {
-				binder.bind(IGeneratorBridge.class).toInstance(bridge);
+				binder.bind(SCTFileSystemAccess.class).to(EFSResourceFileSystemAccess.class);
+				binder.bind(IGeneratorLog.class).to(EclipseConsoleLog.class);
+				binder.bind(IOutletFeatureHelper.class).to(OutletFeatureHelperImpl.class);
+				binder.bind(IDebugFeatureHelper.class).to(DebugFeatureHelperImpl.class);
 			}
 		};
-		return bridgeModule;
+		return baseModule;
 	}
 
 	protected Injector getInjector(GeneratorEntry entry) {
@@ -158,47 +130,4 @@ public abstract class AbstractSGraphModelGenerator implements ISCTGenerator {
 		return injector;
 	}
 
-	protected final void writeToConsole(Throwable t) {
-		PrintWriter printWriter = new PrintWriter(error);
-		t.printStackTrace(printWriter);
-		printWriter.flush();
-		printWriter.close();
-	}
-
-	protected final void writeToConsole(String line) {
-		if (!info.isClosed() && PlatformUI.isWorkbenchRunning()) {
-			info.println(line);
-		}
-	}
-
-	private MessageConsole getConsole() {
-		ConsolePlugin plugin = ConsolePlugin.getDefault();
-		IConsoleManager conMan = plugin.getConsoleManager();
-		IConsole[] existing = conMan.getConsoles();
-		for (int i = 0; i < existing.length; i++) {
-			if (SCT_GENERATOR_CONSOLE.equals(existing[i].getName())) {
-				return (MessageConsole) existing[i];
-			}
-		}
-		MessageConsole myConsole = new MessageConsole(SCT_GENERATOR_CONSOLE, null);
-		conMan.addConsoles(new IConsole[]{myConsole});
-		return myConsole;
-	}
-
-	protected final IProject getTargetProject(GeneratorEntry entry) {
-		IProject project = GeneratorUtils.getTargetProject(entry);
-		if (!project.exists()) {
-			createProject(project, entry);
-		}
-		return project;
-	}
-
-	/**
-	 * The default implementation only creates a new default project. Clients
-	 * may override if they want to contribute generatorspecific project setup
-	 */
-	protected void createProject(IProject project, GeneratorEntry entry) {
-		GeneratorUtils.createEmptyProject(project);
-	}
-
 }

+ 185 - 163
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/AbstractXpandBasedCodeGenerator.java

@@ -1,163 +1,185 @@
-/**
- * Copyright (c) 2011 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:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.generator.core.impl;
-
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.getOutletFeatureConfiguration;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.refreshTargetProject;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.xpand2.XpandExecutionContext;
-import org.eclipse.xpand2.XpandExecutionContextImpl;
-import org.eclipse.xpand2.XpandFacade;
-import org.eclipse.xpand2.output.Outlet;
-import org.eclipse.xpand2.output.Output;
-import org.eclipse.xpand2.output.OutputImpl;
-import org.eclipse.xpand2.output.PostProcessor;
-import org.eclipse.xtend.expression.Variable;
-import org.eclipse.xtend.typesystem.Type;
-import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel;
-import org.yakindu.base.base.BasePackage;
-import org.yakindu.base.types.TypesPackage;
-import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sexec.SexecPackage;
-import org.yakindu.sct.model.sgen.FeatureConfiguration;
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-import org.yakindu.sct.model.sgen.SGenPackage;
-import org.yakindu.sct.model.sgraph.SGraphPackage;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.stext.stext.StextPackage;
-
-/**
- * abstract base class for all code generators using Xpand as the template
- * language.
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public abstract class AbstractXpandBasedCodeGenerator extends
-		AbstractSExecModelGenerator {
-
-	public static final String CONTEXT_INJECTOR_PROPERTY_NAME = "AbstractXpandBasedCodeGenerator.Injector";
-
-	public static final String LIBRARY_TARGET_FOLDER_OUTLET = "LIBRARY_TARGET_FOLDER";
-
-	public abstract String getTemplatePath();
-
-	/**
-	 * Invokes XPands template engine to generate resources
-	 */
-	public final void runGenerator(Statechart statechart, GeneratorEntry entry) {
-		Output output = createOutput(entry);
-
-		String templatePath = getTemplatePath();
-
-		writeToConsole("Executing Template " + templatePath);
-		XpandExecutionContext context = createXpandContext(entry, output);
-		XpandFacade facade = XpandFacade.create(context);
-
-		// Check, if method exists
-		boolean generatorFound = false;
-		Type targetType = context.getTypeForName("sexec::ExecutionFlow");
-		final Type[] paramTypes = new Type[1];
-		paramTypes[0] = context.getType(entry);
-		if (context.findDefinition(templatePath, targetType, paramTypes) != null) {
-			generatorFound = true;
-			ExecutionFlow flow = createExecutionFlow(statechart, entry);
-			if (isDumpSexec(entry)) {
-				dumpSexec(entry, flow);
-			}
-			facade.evaluate(templatePath, flow, entry);
-		}
-
-		targetType = context.getTypeForName("sgraph::Statechart");
-		if (context.findDefinition(templatePath, targetType, paramTypes) != null) {
-			generatorFound = true;
-			facade.evaluate(templatePath, statechart, entry);
-		}
-		if (!generatorFound) {
-			writeToConsole("!!! No matching define in Template found.");
-		}
-
-		// refresh the project to get external updates:
-		refreshTargetProject(entry);
-	}
-
-	protected XpandExecutionContext createXpandContext(GeneratorEntry entry,
-			Output output) {
-		XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(
-				output, null, null, null, null);
-		EmfRegistryMetaModel metamodel = new EmfRegistryMetaModel() {
-			@Override
-			protected EPackage[] allPackages() {
-				return new EPackage[] { SGraphPackage.eINSTANCE,
-						StextPackage.eINSTANCE, EcorePackage.eINSTANCE,
-						SexecPackage.eINSTANCE, SGenPackage.eINSTANCE,
-						TypesPackage.eINSTANCE, BasePackage.eINSTANCE };
-			}
-		};
-		execCtx.registerMetaModel(metamodel);
-		execCtx.getGlobalVariables()
-				.put(CONTEXT_INJECTOR_PROPERTY_NAME,
-						new Variable(CONTEXT_INJECTOR_PROPERTY_NAME,
-								getInjector(entry)));
-		return execCtx;
-	}
-
-	protected Output createOutput(GeneratorEntry entry) {
-		FeatureConfiguration outletConfig = getOutletFeatureConfiguration(entry);
-		
-		FeatureParameterValue targetFolderValue = outletConfig
-				.getParameterValue(OUTLET_FEATURE_TARGET_FOLDER);
-		FeatureParameterValue libraryTargetFolderValue = outletConfig
-				.getParameterValue(OUTLET_FEATURE_LIBRARY_TARGET_FOLDER);
-
-		String absoluteTargetFolder = getTargetProject(entry).getLocation()
-				.toOSString() + File.separator + targetFolderValue.getExpression().toString();
-
-		Output output = new OutputImpl();
-		
-		Outlet targetFolderOutlet = new Outlet(absoluteTargetFolder);
-		for (PostProcessor postProcessor : getPostProcessors()) {
-			targetFolderOutlet.addPostprocessor(postProcessor);
-		}
-		targetFolderOutlet.setOverwrite(true);
-		output.addOutlet(targetFolderOutlet);
-
-		if(libraryTargetFolderValue != null){
-			String absoluteLibraryTargetFolder = getTargetProject(entry).getLocation()
-					.toOSString() + File.separator + libraryTargetFolderValue.getExpression().toString();
-			Outlet libraryTargetFolderOutlet = new Outlet(false, null, LIBRARY_TARGET_FOLDER_OUTLET, false, absoluteLibraryTargetFolder);
-			output.addOutlet(libraryTargetFolderOutlet);
-		}
-		
-		return output;
-	}
-
-	/**
-	 * Override this Method to add some {@link PostProcessor}s to the XPand
-	 * outlet.
-	 * 
-	 * @return An empty {@link Set} for {@link PostProcessor}s
-	 */
-	protected Set<PostProcessor> getPostProcessors() {
-		return Collections.emptySet();
-	}
-
-}
+/**
+ * Copyright (c) 2011 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.core.impl;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.xpand2.XpandExecutionContext;
+import org.eclipse.xpand2.XpandExecutionContextImpl;
+import org.eclipse.xpand2.XpandFacade;
+import org.eclipse.xpand2.output.Outlet;
+import org.eclipse.xpand2.output.Output;
+import org.eclipse.xpand2.output.OutputImpl;
+import org.eclipse.xpand2.output.PostProcessor;
+import org.eclipse.xtend.expression.Variable;
+import org.eclipse.xtend.typesystem.Type;
+import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel;
+import org.eclipse.xtext.generator.IFileSystemAccess;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.base.types.TypesPackage;
+import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
+import org.yakindu.sct.generator.core.filesystem.EFSResourceFileSystemAccess;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.SexecPackage;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgen.SGenPackage;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.stext.StextPackage;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+/**
+ * abstract base class for all code generators using Xpand as the template
+ * language.
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractXpandBasedCodeGenerator extends AbstractSExecModelGenerator {
+
+	public static final String CONTEXT_INJECTOR_PROPERTY_NAME = "AbstractXpandBasedCodeGenerator.Injector";
+
+	public static final String LIBRARY_TARGET_FOLDER_OUTLET = "LIBRARY_TARGET_FOLDER";
+
+	public abstract String getTemplatePath();
+
+	/**
+	 * Invokes XPands template engine to generate resources
+	 */
+	public final void runGenerator(Statechart statechart, GeneratorEntry entry) {
+		Output output = createOutput(entry);
+
+		String templatePath = getTemplatePath();
+
+		log.writeToConsole("Executing Template " + templatePath);
+		XpandExecutionContext context = createXpandContext(entry, output);
+		XpandFacade facade = XpandFacade.create(context);
+
+		// Check, if method exists
+		boolean generatorFound = false;
+		Type targetType = context.getTypeForName("sexec::ExecutionFlow");
+		final Type[] paramTypes = new Type[1];
+		paramTypes[0] = context.getType(entry);
+		if (context.findDefinition(templatePath, targetType, paramTypes) != null) {
+			generatorFound = true;
+			ExecutionFlow flow = createExecutionFlow(statechart, entry);
+			if (debugFeatureHelper.isDumpSexec(entry)) {
+				dumpSexec(entry, flow);
+			}
+			facade.evaluate(templatePath, flow, entry);
+		}
+
+		targetType = context.getTypeForName("sgraph::Statechart");
+		if (context.findDefinition(templatePath, targetType, paramTypes) != null) {
+			generatorFound = true;
+			facade.evaluate(templatePath, statechart, entry);
+		}
+		if (!generatorFound) {
+			log.writeToConsole("!!! No matching define in Template found.");
+		}
+
+		// refresh the project to get external updates:
+
+		refreshTargetProject(entry);
+	}
+
+	protected XpandExecutionContext createXpandContext(GeneratorEntry entry, Output output) {
+		XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl(output, null, null, null, null);
+		EmfRegistryMetaModel metamodel = new EmfRegistryMetaModel() {
+			@Override
+			protected EPackage[] allPackages() {
+				return new EPackage[]{SGraphPackage.eINSTANCE, StextPackage.eINSTANCE, EcorePackage.eINSTANCE,
+						SexecPackage.eINSTANCE, SGenPackage.eINSTANCE, TypesPackage.eINSTANCE, BasePackage.eINSTANCE};
+			}
+		};
+		execCtx.registerMetaModel(metamodel);
+		execCtx.getGlobalVariables().put(CONTEXT_INJECTOR_PROPERTY_NAME,
+				new Variable(CONTEXT_INJECTOR_PROPERTY_NAME, getInjector(entry)));
+		return execCtx;
+	}
+
+	protected Output createOutput(GeneratorEntry entry) {
+		//FIXME !!! unify, this is duplicate see ...Java*Generic*Something
+		sctFileSystemAccess.setOutputPath(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT,
+				outletFeatureHelper.getTargetProjectValue(entry).getStringValue());
+		
+		sctFileSystemAccess.setOutputPath(IFileSystemAccess.DEFAULT_OUTPUT,
+				outletFeatureHelper.getTargetFolderValue(entry).getExpression().toString());
+		
+		String outputPath = outletFeatureHelper.getRelativeTargetFolder(entry);
+
+		String absoluteTargetFolder = sctFileSystemAccess.getURI(outputPath).toFileString();
+
+		Output output = new OutputImpl();
+
+		Outlet targetFolderOutlet = new Outlet(absoluteTargetFolder);
+		for (PostProcessor postProcessor : getPostProcessors()) {
+			targetFolderOutlet.addPostprocessor(postProcessor);
+		}
+		targetFolderOutlet.setOverwrite(true);
+		output.addOutlet(targetFolderOutlet);
+
+		String relativeLibraryTargetFolder = outletFeatureHelper.getRelativeLibraryFolder(entry);
+
+		String absoluteLibraryTargetFolder = sctFileSystemAccess.getURI(relativeLibraryTargetFolder).toFileString();
+		
+		Outlet libraryTargetFolderOutlet = new Outlet(false, null, LIBRARY_TARGET_FOLDER_OUTLET, false,
+				absoluteLibraryTargetFolder);
+		output.addOutlet(libraryTargetFolderOutlet);
+
+		return output;
+	}
+
+	@Override
+	protected Module getOverridesModule(GeneratorEntry entry) {
+		Module baseModule = super.getOverridesModule(entry);
+
+		return Modules.override(baseModule).with(new Module() {
+
+			@Override
+			public void configure(Binder binder) {
+
+			}
+
+		});
+	}
+
+	/**
+	 * Override this Method to add some {@link PostProcessor}s to the XPand
+	 * outlet.
+	 * 
+	 * @return An empty {@link Set} for {@link PostProcessor}s
+	 */
+	protected Set<PostProcessor> getPostProcessors() {
+		return Collections.emptySet();
+	}
+
+	protected void refreshTargetProject(GeneratorEntry entry) {
+		try {
+			IProject project = EFSResourceFileSystemAccess.getTargetProject(entry);
+			if (project != null)
+				project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+		} catch (CoreException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 20 - 27
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericJavaBasedGenerator.java

@@ -10,14 +10,10 @@
  */
 package org.yakindu.sct.generator.core.impl;
 
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER;
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER;
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.CONFIGURATION_MODULE;
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.GENERATOR_CLASS;
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.GENERATOR_PROJECT;
 import static org.yakindu.sct.generator.core.features.impl.IGenericJavaFeatureConstants.TEMPLATE_FEATURE;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.getOutletFeatureConfiguration;
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
@@ -27,7 +23,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess;
 import org.eclipse.xtext.generator.OutputConfiguration;
 import org.eclipse.xtext.util.Strings;
 import org.yakindu.sct.commons.WorkspaceClassLoaderFactory;
-import org.yakindu.sct.generator.core.AbstractWorkspaceGenerator;
+import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
 import org.yakindu.sct.model.sexec.ExecutionFlow;
 import org.yakindu.sct.model.sgen.FeatureConfiguration;
 import org.yakindu.sct.model.sgen.FeatureParameterValue;
@@ -54,7 +50,7 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 			FeatureParameterValue parameterValue = featureConfiguration.getParameterValue(CONFIGURATION_MODULE);
 			if (parameterValue != null) {
 				overridingModuleClass = parameterValue.getStringValue();
-			}
+			} 
 		}
 		if (!Strings.isEmpty(overridingModuleClass)) {
 			try {
@@ -65,7 +61,8 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 				}
 			} catch (Exception e) {
 				e.printStackTrace();
-				writeToConsole("Overriding module not found: " + overridingModuleClass);
+				log.writeToConsole("Overriding module not found: " + overridingModuleClass);
+				log.writeToConsole(e);
 			}
 		}
 		return defaultModule;
@@ -95,13 +92,10 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 
 			ExecutionFlow flow = createExecutionFlow(statechart, entry);
 
-			if (isDumpSexec(entry)) {
+			if (debugFeatureHelper.isDumpSexec(entry)) {
 				dumpSexec(entry, flow);
 			}
 
-			if (delegate instanceof AbstractWorkspaceGenerator) {
-				((AbstractWorkspaceGenerator) delegate).setBridge(bridge);
-			}
 
 			if (delegate instanceof IExecutionFlowGenerator) {
 				IExecutionFlowGenerator flowGenerator = (IExecutionFlowGenerator) delegate;
@@ -117,7 +111,7 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 			}
 		} catch (Exception e) {
 			e.printStackTrace();
-			writeToConsole(e);
+			log.writeToConsole(e);
 		}
 	}
 
@@ -147,24 +141,23 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 	 * Provides a pre configured IFileSystemAccess instance
 	 */
 	public IFileSystemAccess getFileSystemAccess(GeneratorEntry entry) {
-
-		SimpleResourceFileSystemAccess fileSystemAccess = new SimpleResourceFileSystemAccess();
-		fileSystemAccess.setProject(getTargetProject(entry));
-
-		FeatureConfiguration outletConfig = getOutletFeatureConfiguration(entry);
-
-		String targetFolder = outletConfig.getParameterValue(OUTLET_FEATURE_TARGET_FOLDER).getExpression().toString();
-		fileSystemAccess.setOutputPath(IFileSystemAccess.DEFAULT_OUTPUT, targetFolder);
-
-		FeatureParameterValue libraryTargetFolderValue = outletConfig
-				.getParameterValue(OUTLET_FEATURE_LIBRARY_TARGET_FOLDER);
+		// set target project value
+		sctFileSystemAccess.setOutputPath(ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT,
+				outletFeatureHelper.getTargetProjectValue(entry).getStringValue());
+		// set target folder
+		sctFileSystemAccess.setOutputPath(IFileSystemAccess.DEFAULT_OUTPUT,
+				outletFeatureHelper.getTargetFolderValue(entry).getExpression().toString());
+
+		FeatureParameterValue libraryTargetFolderValue = outletFeatureHelper
+				.getLibraryTargetFolderValue(entry);
+		
 		if (libraryTargetFolderValue != null) {
-			fileSystemAccess.setOutputPath(IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT,
+			sctFileSystemAccess.setOutputPath(IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT,
 					libraryTargetFolderValue.getExpression().toString());
 		}
 
-		fileSystemAccess.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT).setCreateOutputDirectory(true);
-		OutputConfiguration librarytargetFolderOutputConfiguration = fileSystemAccess.getOutputConfigurations()
+		sctFileSystemAccess.getOutputConfigurations().get(IFileSystemAccess.DEFAULT_OUTPUT).setCreateOutputDirectory(true);
+		OutputConfiguration librarytargetFolderOutputConfiguration = sctFileSystemAccess.getOutputConfigurations()
 				.get(IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT);
 		if (librarytargetFolderOutputConfiguration != null) {
 			librarytargetFolderOutputConfiguration.setCreateOutputDirectory(true);
@@ -174,7 +167,7 @@ public class GenericJavaBasedGenerator extends AbstractSExecModelGenerator {
 			librarytargetFolderOutputConfiguration.setOverrideExistingResources(false);
 		}
 
-		return fileSystemAccess;
+		return sctFileSystemAccess.getIFileSystemAccess();
 	}
 
 }

+ 1 - 1
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/GenericXPandCodeGenerator.java

@@ -45,7 +45,7 @@ public class GenericXPandCodeGenerator extends AbstractXpandBasedCodeGenerator {
 	@Override
 	protected void finishGenerator(GeneratorEntry entry) {
 		ResourceLoaderFactory.setCurrentThreadResourceLoader(null);
-	}
+	} 
 
 	/**
 	 * create a {@link ResourceLoader} for the XPandFacade

+ 11 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/IGeneratorLog.java

@@ -0,0 +1,11 @@
+package org.yakindu.sct.generator.core.impl;
+
+public interface IGeneratorLog {
+
+	void writeToConsole(Throwable t);
+
+	void writeToConsole(String line);
+
+	void close() throws Throwable;
+
+}

+ 0 - 71
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/impl/SimpleResourceFileSystemAccess.java

@@ -1,71 +0,0 @@
-/** 
- * Copyright (c) 2015 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:
- * committers of YAKINDU - initial API and implementation
- *
-*/
-package org.yakindu.sct.generator.core.impl;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2;
-import org.eclipse.xtext.generator.OutputConfiguration;
-import org.eclipse.xtext.util.StringInputStream;
-
-public class SimpleResourceFileSystemAccess extends EclipseResourceFileSystemAccess2 {
-
-	
-	public void generateFile(String fileName, String outputName, CharSequence contents) {
-
-		OutputConfiguration outputConfig = getOutputConfig(outputName);
-		
-		IContainer container = getContainer(outputConfig);
-		
-		if ( !container.exists()) {
-			if (outputConfig.isCreateOutputDirectory()) {
-				try {
-					createContainer(container);
-				} catch (CoreException e) {
-					throw new RuntimeException(e);
-				}
-			} else {
-				return;
-			}
-		}
-		
-		IFile file = getFile(fileName, outputName);
-		CharSequence postProcessedContent = postProcess(fileName, outputName, contents);
-		String contentsAsString = postProcessedContent.toString(); 
-		if (file.exists()) {
-			if (outputConfig.isOverrideExistingResources()) {
-				try {
-					StringInputStream newContent = getInputStream(contentsAsString, getEncoding(file));
-					if (hasContentsChanged(file, newContent)) {
-						newContent.reset();
-						file.setContents(newContent, true, true, null);
-						if (file.isDerived() != outputConfig.isSetDerivedProperty()) {
-							setDerived(file, outputConfig.isSetDerivedProperty());
-						}
-					} 
-				} catch (CoreException e) {
-					throw new RuntimeException(e);
-				}
-			}
-		} else {
-			try {
-				ensureParentExists(file);
-				file.create(getInputStream(contentsAsString, getEncoding(file)), true, null);
-				if (outputConfig.isSetDerivedProperty()) {
-					setDerived(file, true);
-				}
-			} catch (CoreException e) {
-				throw new RuntimeException(e);
-			}
-		}
-	}
-}

+ 36 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/BaseSGenFeatureHelper.java

@@ -0,0 +1,36 @@
+/**
+ * Copyright (c) 2016 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:
+ * 		committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library;
+
+import org.yakindu.sct.model.sgen.FeatureConfiguration;
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+/**
+ * Convenience...
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public class BaseSGenFeatureHelper {
+
+	public FeatureParameterValue getFeatureParameter(GeneratorEntry entry, String featureName, String paramName) {
+		FeatureConfiguration feature = entry.getFeatureConfiguration(featureName);
+
+		if (feature != null) {
+			return feature.getParameterValue(paramName);
+		}
+
+		return null;
+	}
+	
+	
+}

+ 34 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/DebugFeatureHelperImpl.java

@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2016 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:
+ * 		committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library;
+
+import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.DEBUG_FEATURE;
+import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.DEBUG_FEATURE_DUMP_SEXEC;
+
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+/**
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public class DebugFeatureHelperImpl extends BaseSGenFeatureHelper implements IDebugFeatureHelper {
+	
+	@Override
+	public boolean isDumpSexec(GeneratorEntry entry) {
+		FeatureParameterValue dumpSexec = getFeatureParameter(entry, DEBUG_FEATURE, DEBUG_FEATURE_DUMP_SEXEC);
+		if (dumpSexec == null) {
+			return false;
+		}
+		return dumpSexec.getBooleanValue();
+	}
+}

+ 25 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/IDebugFeatureHelper.java

@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2016 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:
+ * 		committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library;
+
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+/**
+ *Provides convenience access to SGen debug features.
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public interface IDebugFeatureHelper {
+
+	boolean isDumpSexec(GeneratorEntry entry);
+
+}

+ 30 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/IOutletFeatureHelper.java

@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2016 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:
+ * 		committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library;
+
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+/**
+ * Provides convenience access to SGen outlet features.
+ * 
+ * @author Johannes Dicks - Initial contribution and API
+ *
+ */
+public interface IOutletFeatureHelper {
+	FeatureParameterValue getTargetFolderValue(GeneratorEntry entry);
+	FeatureParameterValue getLibraryTargetFolderValue(GeneratorEntry entry);
+	FeatureParameterValue getTargetProjectValue(GeneratorEntry entry);
+	String getRelativeTargetFolder(GeneratorEntry entry);
+	String getRelativeLibraryFolder(GeneratorEntry entry);
+
+}

+ 51 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/library/OutletFeatureHelperImpl.java

@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2014 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.generator.core.library;
+
+import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE;
+
+import org.eclipse.core.runtime.Path;
+import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+
+public class OutletFeatureHelperImpl extends BaseSGenFeatureHelper implements IOutletFeatureHelper {
+
+	@Override
+	public FeatureParameterValue getTargetFolderValue(GeneratorEntry entry) {
+		return getFeatureParameter(entry, OUTLET_FEATURE, ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER);
+	}
+
+	@Override
+	public FeatureParameterValue getLibraryTargetFolderValue(GeneratorEntry entry) {
+		return getFeatureParameter(entry, OUTLET_FEATURE, ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER);
+	}
+
+	@Override
+	public FeatureParameterValue getTargetProjectValue(GeneratorEntry entry) {
+		return getFeatureParameter(entry, OUTLET_FEATURE, ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT);
+	}
+
+	@Override
+	public String getRelativeTargetFolder(GeneratorEntry entry) {
+		String projectFolderName = getTargetProjectValue(entry).getExpression().toString();
+		String targetFolderValue = getTargetFolderValue(entry).getExpression().toString();
+		return projectFolderName + Path.SEPARATOR + targetFolderValue;
+	}
+
+	@Override
+	public String getRelativeLibraryFolder(GeneratorEntry entry) {
+		String projectFolderName = getTargetProjectValue(entry).getStringValue();
+		String libraryFolderName = getLibraryTargetFolderValue(entry).getExpression().toString();
+		return projectFolderName + Path.SEPARATOR
+				+ libraryFolderName;
+	}
+}

+ 69 - 0
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/util/EclipseConsoleLog.java

@@ -0,0 +1,69 @@
+package org.yakindu.sct.generator.core.util;
+
+import java.io.PrintWriter;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.yakindu.sct.generator.core.impl.AbstractSGraphModelGenerator;
+import org.yakindu.sct.generator.core.impl.IGeneratorLog;
+
+public class EclipseConsoleLog implements IGeneratorLog {
+	
+	private MessageConsoleStream info;
+	private MessageConsoleStream error;
+	
+	public EclipseConsoleLog() {
+		init();
+	}
+	
+	public void init() {
+		if (Platform.isRunning()) {
+			info = getConsole().newMessageStream();
+			error = getConsole().newMessageStream();
+			error.setActivateOnWrite(true);
+		}
+	}
+
+	private MessageConsole getConsole() {
+		ConsolePlugin plugin = ConsolePlugin.getDefault();
+		IConsoleManager conMan = plugin.getConsoleManager();
+		IConsole[] existing = conMan.getConsoles();
+		for (int i = 0; i < existing.length; i++) {
+			if (AbstractSGraphModelGenerator.SCT_GENERATOR_CONSOLE.equals(existing[i].getName())) {
+				return (MessageConsole) existing[i];
+			} 
+		}
+		MessageConsole myConsole = new MessageConsole(AbstractSGraphModelGenerator.SCT_GENERATOR_CONSOLE, null);
+		conMan.addConsoles(new IConsole[]{myConsole});
+		return myConsole;
+	}
+	public void close() throws Throwable {
+		info.close();
+		error.close();
+
+	}
+
+	@Override
+	public void writeToConsole(Throwable t) {
+		if (error != null && !error.isClosed() && PlatformUI.isWorkbenchRunning()) {
+			PrintWriter printWriter = new PrintWriter(error);
+			t.printStackTrace(printWriter);
+			printWriter.flush();
+			printWriter.close();
+		}
+
+	}
+
+	@Override
+	public void writeToConsole(String line) {
+		if (info != null && !info.isClosed() && PlatformUI.isWorkbenchRunning()) {
+			info.println(line);
+		}
+
+	}
+}

+ 0 - 137
plugins/org.yakindu.sct.generator.core/src/org/yakindu/sct/generator/core/util/GeneratorUtils.java

@@ -1,137 +0,0 @@
-/**
- * Copyright (c) 2014 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.generator.core.util;
-
-import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.DEBUG_FEATURE;
-import static org.yakindu.sct.generator.core.features.ISCTBaseFeatureConstants.DEBUG_FEATURE_DUMP_SEXEC;
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE;
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_TARGET_PROJECT;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
-import org.yakindu.sct.model.sgen.FeatureConfiguration;
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-
-public class GeneratorUtils {
-
-	public static boolean getBoolValue(FeatureConfiguration conf, String param,
-			boolean defaultValue) {
-		if (conf != null && conf.getParameterValue(param) != null) {
-			return conf.getParameterValue(param).getBooleanValue();
-		}
-
-		return defaultValue;
-	}
-
-	public static final void refreshTargetProject(GeneratorEntry entry) {
-		try {
-			IProject project = getTargetProject(entry);
-			project.refreshLocal(IResource.DEPTH_INFINITE,
-					new NullProgressMonitor());
-		} catch (CoreException e) {
-			e.printStackTrace();
-		}
-	}
-
-	/**
-	 * Create an empty project if this project does not exist.
-	 * 
-	 * @param project
-	 * @return true, if the project was created. false if it already exists.
-	 */
-	public static boolean createEmptyProject(IProject project) {
-		if (!project.exists()) {
-			try {
-				NullProgressMonitor monitor = new NullProgressMonitor();
-				project.create(monitor);
-				project.open(monitor);
-				return true;
-			} catch (CoreException e) {
-				e.printStackTrace();
-			}
-		}
-		return false;
-	}
-
-	/**
-	 * Returns an IProject for the configured target project. The
-	 * {@link IProject} is returned even if the project does not exist yet.
-	 * 
-	 * @param entry
-	 * @return
-	 */
-	public static final IProject getTargetProject(GeneratorEntry entry) {
-		FeatureConfiguration outletConfig = getOutletFeatureConfiguration(entry);
-		String projectName = outletConfig.getParameterValue(
-				OUTLET_FEATURE_TARGET_PROJECT).getStringValue();
-		IProject project = ResourcesPlugin.getWorkspace().getRoot()
-				.getProject(projectName);
-
-		return project;
-	}
-
-	/** Gets the target folder path as a File that includes the project location */
-	public static File getTargetFolder(GeneratorEntry entry) {
-		String targetFolder = getOutletFeatureConfiguration(entry)
-				.getParameterValue(
-						ICoreFeatureConstants.OUTLET_FEATURE_TARGET_FOLDER)
-				.getStringValue();
-		return new File(getTargetProject(entry).getLocation().toFile()
-				.getPath()
-				+ File.separator + targetFolder);
-	}
-	
-	/** Gets the target folder path as a File that includes the project location */
-	public static File getLibraryTargetFolder(GeneratorEntry entry) {
-		String targetFolder = getOutletFeatureConfiguration(entry)
-				.getParameterValue(
-						ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER)
-				.getStringValue();
-		return new File(getTargetProject(entry).getLocation().toFile()
-				.getPath()
-				+ File.separator + targetFolder);
-	}
-
-	public static FeatureConfiguration getOutletFeatureConfiguration(
-			GeneratorEntry entry) {
-		FeatureConfiguration outletConfig = entry
-				.getFeatureConfiguration(OUTLET_FEATURE);
-		return outletConfig;
-	}
-
-	public static boolean isDumpSexec(GeneratorEntry entry) {
-		FeatureParameterValue dumpSexec = getFeatureParameter(entry,
-				DEBUG_FEATURE, DEBUG_FEATURE_DUMP_SEXEC);
-		if (dumpSexec == null) {
-			return false;
-		}
-		return dumpSexec.getBooleanValue();
-	}
-
-	public static FeatureParameterValue getFeatureParameter(
-			GeneratorEntry entry, String featureName, String paramName) {
-		FeatureConfiguration feature = entry
-				.getFeatureConfiguration(featureName);
-
-		if (feature != null) {
-			return feature.getParameterValue(paramName);
-		}
-
-		return null;
-	}
-}

+ 53 - 57
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/CppCodeGenerator.java

@@ -1,57 +1,53 @@
-/**
- * Copyright (c) 2011 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:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.generator.cpp;
-
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
-
-import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
-import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
-import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
-import org.yakindu.sct.model.sexec.ExecutionFlow;
-import org.yakindu.sct.model.sexec.naming.INamingService;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-import org.yakindu.sct.model.sgraph.Statechart;
-
-import com.google.inject.Binder;
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-/**
- * 
- * @author Markus Mühlbrandt - Initial contribution and API
- * 
- */
-public class CppCodeGenerator extends GenericJavaBasedGenerator {
-
-	@Override
-	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
-		CppGenerator delegate = getInjector(entry).getInstance(
-				CppGenerator.class);
-		ExecutionFlow flow = createExecutionFlow(statechart, entry);
-		if (isDumpSexec(entry)) {
-			dumpSexec(entry, flow);
-		}
-		delegate.generate(flow, entry, getFileSystemAccess(entry));
-	}
-
-	@Override
-	protected Module getOverridesModule(final GeneratorEntry entry) {
-		Module module = super.getOverridesModule(entry);
-		return Modules.override(module).with(new Module() {
-			public void configure(Binder binder) {
-				binder.bind(ICodegenTypeSystemAccess.class).to(
-						CTypeSystemAccess.class);
-				binder.bind(INamingService.class).to(CppNamingService.class);
-				binder.bind(GeneratorEntry.class).toInstance(entry);
-			}
-		});
-	}
-}
+/**
+ * Copyright (c) 2011 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.cpp;
+
+import org.yakindu.sct.generator.c.types.CTypeSystemAccess;
+import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
+import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
+import org.yakindu.sct.model.sexec.ExecutionFlow;
+import org.yakindu.sct.model.sexec.naming.INamingService;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+/**
+ * 
+ * @author Markus Mühlbrandt - Initial contribution and API
+ * 
+ */
+public class CppCodeGenerator extends GenericJavaBasedGenerator {
+
+	@Override
+	public void runGenerator(Statechart statechart, GeneratorEntry entry) {
+		CppGenerator delegate = getInjector(entry).getInstance(CppGenerator.class);
+		ExecutionFlow flow = createExecutionFlow(statechart, entry);
+		if (debugFeatureHelper.isDumpSexec(entry)) {
+			dumpSexec(entry, flow);
+		}
+		delegate.generate(flow, entry, getFileSystemAccess(entry));
+	}
+
+	@Override
+	protected Module getOverridesModule(final GeneratorEntry entry) {
+		Module module = super.getOverridesModule(entry);
+		return Modules.override(module).with(new Module() {
+			public void configure(Binder binder) {
+				binder.bind(ICodegenTypeSystemAccess.class).to(CTypeSystemAccess.class);
+				binder.bind(INamingService.class).to(CppNamingService.class);
+				binder.bind(GeneratorEntry.class).toInstance(entry);
+			}
+		});
+	}
+}

+ 4 - 4
plugins/org.yakindu.sct.generator.cpp/src/org/yakindu/sct/generator/cpp/Types.xtend

@@ -16,9 +16,9 @@ import org.eclipse.xtext.generator.IFileSystemAccess
 import com.google.inject.Inject
 import org.yakindu.sct.model.sgen.GeneratorEntry
 import org.yakindu.sct.generator.c.GenmodelEntries
-import org.yakindu.sct.generator.core.impl.SimpleResourceFileSystemAccess
 import org.eclipse.core.resources.ResourcesPlugin
 import org.eclipse.core.runtime.Path
+import org.yakindu.sct.generator.core.filesystem.EFSResourceFileSystemAccess
 
 class Types {
 	
@@ -26,13 +26,13 @@ class Types {
 	@Inject extension GenmodelEntries
 	 
 	def generateTypesHpp(ExecutionFlow flow, Statechart sc, IFileSystemAccess fsa, GeneratorEntry entry) {
-		if (fsa instanceof SimpleResourceFileSystemAccess &&
-			!exists(flow.typesModule.h, fsa as SimpleResourceFileSystemAccess)) {
+		if (fsa instanceof EFSResourceFileSystemAccess &&
+			!exists(flow.typesModule.h, fsa as EFSResourceFileSystemAccess)) {
 			fsa.generateFile(flow.typesModule.h, flow.typesHContent(entry))	
 		}
 	}
 	
-	def protected exists(String filename, SimpleResourceFileSystemAccess fsa) {
+	def protected exists(String filename, EFSResourceFileSystemAccess fsa) {
 		val uri = fsa.getURI(filename);
 		val file = ResourcesPlugin.getWorkspace().getRoot()
 					.getFile(new Path(uri.toPlatformString(true)));

+ 0 - 35
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/AbstractJavaCodeGenerator.java

@@ -10,14 +10,8 @@
  */
 package org.yakindu.sct.generator.java;
 
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.JavaCore;
 import org.yakindu.sct.generator.core.features.ICoreFeatureConstants;
 import org.yakindu.sct.generator.core.impl.GenericJavaBasedGenerator;
-import org.yakindu.sct.generator.core.util.ClasspathChanger;
-import org.yakindu.sct.generator.core.util.GeneratorUtils;
 import org.yakindu.sct.model.sgen.FeatureConfiguration;
 import org.yakindu.sct.model.sgen.GeneratorEntry;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -26,18 +20,8 @@ abstract public class AbstractJavaCodeGenerator extends GenericJavaBasedGenerato
 
 	abstract public void generate(Statechart statechart, GeneratorEntry entry);
 
-	private ClasspathChanger classpathChanger = new ClasspathChanger();
-
 	@Override
 	public final void runGenerator(Statechart statechart, GeneratorEntry entry) {
-
-		IProject project = GeneratorUtils.getTargetProject(entry);
-
-		if (hasJavaNature(project) && hasClasspath(project)) {
-			IProject targetProject = GeneratorUtils.getTargetProject(entry);
-			String targetFolderString = getTargetFolderString(entry);
-			classpathChanger.addFolderToClassPath(targetProject, targetFolderString);
-		}
 		generate(statechart, entry);
 	}
 
@@ -47,23 +31,4 @@ abstract public class AbstractJavaCodeGenerator extends GenericJavaBasedGenerato
 				.getStringValue();
 		return projectName;
 	}
-
-	public boolean hasJavaNature(IProject project) {
-		Assert.isNotNull(project);
-		Assert.isTrue(project.exists());
-		try {
-			String[] natures = project.getDescription().getNatureIds();
-			for (String s : natures) {
-				if (s.equals(JavaCore.NATURE_ID))
-					return true;
-			}
-		} catch (CoreException e1) {
-			e1.printStackTrace();
-		}
-		return false;
-	}
-
-	public boolean hasClasspath(IProject project) {
-		return project.getFile(".classpath").exists();
-	}
 }

+ 3 - 5
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/IStatemachine.xtend

@@ -12,11 +12,10 @@ package org.yakindu.sct.generator.java
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
-import org.yakindu.sct.generator.core.util.GeneratorUtils
 import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
 
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl
 
 class IStatemachine {
 	
@@ -25,10 +24,9 @@ class IStatemachine {
 	
 	@Inject
 	extension GenmodelEntries
-	
+	 
 	def generateIStatemachine(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
-		if (GeneratorUtils.getOutletFeatureConfiguration(entry).getParameterValue(
-			OUTLET_FEATURE_LIBRARY_TARGET_FOLDER) != null) {	
+		if (new OutletFeatureHelperImpl().getLibraryTargetFolderValue(entry) != null) {	
 			// generate into library target folder in case one is specified, as the contents are static
 			fsa.generateFile(entry.basePackagePath + '/' + iStatemachine.java, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
 		} else {

+ 4 - 6
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ITimer.xtend

@@ -12,11 +12,10 @@ package org.yakindu.sct.generator.java
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
-import org.yakindu.sct.generator.core.util.GeneratorUtils
-import org.yakindu.sct.model.sexec.ExecutionFlow
-import org.yakindu.sct.model.sgen.GeneratorEntry
 
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER
+import org.yakindu.sct.model.sgen.GeneratorEntry
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl
 
 class ITimer {
 	
@@ -27,8 +26,7 @@ class ITimer {
 	extension GenmodelEntries
 	
 	def generateITimer(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
-		if (GeneratorUtils.getOutletFeatureConfiguration(entry).getParameterValue(
-			OUTLET_FEATURE_LIBRARY_TARGET_FOLDER) != null) {	
+		if (new OutletFeatureHelperImpl().getLibraryTargetFolderValue(entry) != null) {	
 			// generate into library target folder in case one is specified, as the contents are static
 			fsa.generateFile(entry.basePackagePath + '/' + iTimer.java, IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))
 		} else {

+ 3 - 6
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/ITimerCallback.xtend

@@ -12,11 +12,9 @@ package org.yakindu.sct.generator.java
 import com.google.inject.Inject
 import org.eclipse.xtext.generator.IFileSystemAccess
 import org.yakindu.sct.generator.core.impl.IExecutionFlowGenerator
-import org.yakindu.sct.generator.core.util.GeneratorUtils
-import org.yakindu.sct.model.sexec.ExecutionFlow
 import org.yakindu.sct.model.sgen.GeneratorEntry
-
-import static org.yakindu.sct.generator.core.features.ICoreFeatureConstants.OUTLET_FEATURE_LIBRARY_TARGET_FOLDER
+import org.yakindu.sct.model.sexec.ExecutionFlow
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl
 
 class ITimerCallback {
 
@@ -27,8 +25,7 @@ class ITimerCallback {
 	extension GenmodelEntries
 
 	def generateITimerCallback(ExecutionFlow flow, GeneratorEntry entry, IFileSystemAccess fsa) {
-		if (GeneratorUtils.getOutletFeatureConfiguration(entry).getParameterValue(
-			OUTLET_FEATURE_LIBRARY_TARGET_FOLDER) != null) {
+		if (new OutletFeatureHelperImpl().getLibraryTargetFolderValue(entry) != null) {
 			// generate into library target folder in case one is specified, as the contents are static
 			fsa.generateFile(entry.basePackagePath + '/' + iTimerCallback.java,
 				IExecutionFlowGenerator.LIBRARY_TARGET_FOLDER_OUTPUT, content(entry))

+ 5 - 11
plugins/org.yakindu.sct.generator.java/src/org/yakindu/sct/generator/java/JavaCodeGenerator.java

@@ -9,8 +9,6 @@
  */
 package org.yakindu.sct.generator.java;
 
-import static org.yakindu.sct.generator.core.util.GeneratorUtils.isDumpSexec;
-
 import org.yakindu.sct.generator.core.types.ICodegenTypeSystemAccess;
 import org.yakindu.sct.generator.java.types.JavaTypeSystemAccess;
 import org.yakindu.sct.generator.java.types.OldJavaTypeSystemAccess;
@@ -28,12 +26,11 @@ public class JavaCodeGenerator extends AbstractJavaCodeGenerator {
 
 	@Override
 	public void generate(Statechart statechart, GeneratorEntry entry) {
-		JavaGenerator delegate = getInjector(entry).getInstance(
-				JavaGenerator.class);
+		JavaGenerator delegate = getInjector(entry).getInstance(JavaGenerator.class);
 
 		ExecutionFlow flow = createExecutionFlow(statechart, entry);
 
-		if (isDumpSexec(entry)) {
+		if (debugFeatureHelper.isDumpSexec(entry)) {
 			dumpSexec(entry, flow);
 		}
 
@@ -47,14 +44,11 @@ public class JavaCodeGenerator extends AbstractJavaCodeGenerator {
 		return Modules.override(module).with(new Module() {
 			public void configure(Binder binder) {
 				if (entries.useJavaInt(entry)) {
-					binder.bind(ICodegenTypeSystemAccess.class).to(
-							OldJavaTypeSystemAccess.class);
+					binder.bind(ICodegenTypeSystemAccess.class).to(OldJavaTypeSystemAccess.class);
 				} else {
-					binder.bind(ICodegenTypeSystemAccess.class).to(
-							JavaTypeSystemAccess.class);
+					binder.bind(ICodegenTypeSystemAccess.class).to(JavaTypeSystemAccess.class);
 				}
-				binder.bind(INamingService.class).to(JavaNamingService.class)
-						.in(Scopes.SINGLETON);
+				binder.bind(INamingService.class).to(JavaNamingService.class).in(Scopes.SINGLETON);
 			}
 		});
 

+ 12 - 0
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/resource/AbstractSCTResource.java

@@ -467,4 +467,16 @@ public abstract class AbstractSCTResource extends GMFResource {
 		}
 
 	}
+	/**
+	 * overridden because original calls 'Util.denormalizeURI(uri,
+	 * getResourceSet())' which leads into error if there is no platform
+	 * available
+	 */
+	@Override
+	public void setURI(URI uri) {
+
+		if (getResourceSet() != null) {
+			setRawURI(uri);
+		}
+	}
 }

+ 87 - 86
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/partitioning/DiagramEditorInput.java

@@ -1,86 +1,87 @@
-/**
- * Copyright (c) 2013 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:
- * 	committers of YAKINDU - initial API and implementation
- * 
- */
-package org.yakindu.sct.ui.editor.partitioning;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput;
-import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.MEditingDomainElement;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.part.FileEditorInput;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public class DiagramEditorInput extends FileEditorInput implements IDiagramEditorInput, MEditingDomainElement {
-
-	private Diagram diagram;
-
-	public DiagramEditorInput(Diagram diagram) {
-		super(WorkspaceSynchronizer.getFile(diagram.eResource()));
-		this.diagram = diagram;
-
-	}
-
-	public Diagram getDiagram() {
-		return diagram;
-	}
-
-	@Override
-	public int hashCode() {
-		final int prime = 31;
-		int result = super.hashCode();
-		result = prime * result + ((diagram == null) ? 0 : diagram.hashCode());
-		return result;
-	}
-
-	@Override
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (!super.equals(obj))
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		DiagramEditorInput other = (DiagramEditorInput) obj;
-		if (diagram == null) {
-			if (other.diagram != null)
-				return false;
-		} else if (!diagram.equals(other.diagram))
-			return false;
-		return true;
-	}
-
-	public TransactionalEditingDomain getEditingDomain() {
-		return DiagramPartitioningUtil.getSharedDomain();
-	}
-
-	@Override
-	public IPersistableElement getPersistable() {
-		// TODO: It is currently not possible to restore Editors with open
-		// DiagramEditorInput cause they will not act on the shared editing
-		// domain
-		return null;
-	}
-
-	@Override
-	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
-		if (adapter == IStorage.class) {
-			return WorkspaceSynchronizer.getFile(diagram.eResource());
-		}
-		return super.getAdapter(adapter);
-	}
-
-}
+/**
+ * Copyright (c) 2013 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:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
+package org.yakindu.sct.ui.editor.partitioning;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditorInput;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.MEditingDomainElement;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class DiagramEditorInput extends FileEditorInput implements IDiagramEditorInput, MEditingDomainElement {
+
+	private Diagram diagram;
+
+	public DiagramEditorInput(Diagram diagram) {
+		super(WorkspaceSynchronizer.getFile(diagram.eResource()));
+		this.diagram = diagram;
+
+	}
+
+	public Diagram getDiagram() {
+		return diagram;
+	}
+
+	@Override
+	public int hashCode() {
+		final int prime = 31;
+		int result = super.hashCode();
+		result = prime * result + ((diagram == null) ? 0 : diagram.hashCode());
+		return result;
+	}
+
+	@Override
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (!super.equals(obj))
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		DiagramEditorInput other = (DiagramEditorInput) obj;
+		if (diagram == null) {
+			if (other.diagram != null)
+				return false;
+		} else if (!diagram.equals(other.diagram))
+			return false;
+		return true;
+	}
+
+	public TransactionalEditingDomain getEditingDomain() {
+		return DiagramPartitioningUtil.getSharedDomain();
+	}
+
+	@Override
+	public IPersistableElement getPersistable() {
+		// TODO: It is currently not possible to restore Editors with open
+		// DiagramEditorInput cause they will not act on the shared editing
+		// domain
+		return null;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+		if (adapter == IStorage.class) {
+			return WorkspaceSynchronizer.getFile(diagram.eResource());
+		}
+		return super.getAdapter(adapter);
+	}
+
+}

+ 95 - 98
test-plugins/org.yakindu.sct.generator.java.test/src/org/yakindu/sct/generator/java/util/AbstractJavaGeneratorTest.java

@@ -1,98 +1,95 @@
-/**
- * Copyright (c) 2012 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:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.generator.java.util;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IJavaModelMarker;
-import org.yakindu.sct.generator.core.util.GeneratorUtils;
-import org.yakindu.sct.generator.java.JavaCodeGenerator;
-import org.yakindu.sct.model.sgen.FeatureConfiguration;
-import org.yakindu.sct.model.sgen.FeatureParameter;
-import org.yakindu.sct.model.sgen.FeatureParameterValue;
-import org.yakindu.sct.model.sgen.FeatureType;
-import org.yakindu.sct.model.sgen.GeneratorEntry;
-import org.yakindu.sct.model.sgen.SGenFactory;
-import org.yakindu.sct.model.sgraph.Statechart;
-
-import com.google.inject.Inject;
-
-/**
- * 
- * @author andreas muelder - Initial contribution and API
- * 
- */
-public abstract class AbstractJavaGeneratorTest {
-
-	private static final String SRC_GEN = "src-gen";
-	private static final String TARGET_PROJECT = "targetProject";
-	private static final String CONTENT_TYPE = "statechart";
-	private static final String OUTLET_FEATURE = "Outlet";
-	private static final String TARGET_FOLDER = "targetFolder";
-
-	@Inject
-	protected JavaCodeGenerator generator;
-
-	public IMarker[] generateAndCompile(Statechart statechart) throws Exception {
-		GeneratorEntry entry = createGeneratorEntry(statechart.getName(),
-				SRC_GEN);
-		entry.setElementRef(statechart);
-		IProject targetProject = GeneratorUtils.getTargetProject(entry);
-		targetProject.delete(true, new NullProgressMonitor());
-		generator.generate(entry);
-		targetProject.getWorkspace().build(
-				IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
-		targetProject = GeneratorUtils.getTargetProject(entry);
-		if (!targetProject.exists()) {
-			targetProject.create(new NullProgressMonitor());
-			targetProject.open(new NullProgressMonitor());
-		}
-		targetProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,
-				new NullProgressMonitor());
-		IMarker[] markers = targetProject.findMarkers(
-				IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
-				IResource.DEPTH_INFINITE);
-		return markers;
-	}
-
-	private GeneratorEntry createGeneratorEntry(String targetProject,
-			String targetFolder) {
-		GeneratorEntry entry = SGenFactory.eINSTANCE.createGeneratorEntry();
-		entry.setContentType(CONTENT_TYPE);
-		FeatureConfiguration config = SGenFactory.eINSTANCE
-				.createFeatureConfiguration();
-		FeatureType type = SGenFactory.eINSTANCE.createFeatureType();
-		type.setName(OUTLET_FEATURE);
-		config.setType(type);
-		FeatureParameterValue project = SGenFactory.eINSTANCE
-				.createFeatureParameterValue();
-		FeatureParameter projectParameter = SGenFactory.eINSTANCE
-				.createFeatureParameter();
-		projectParameter.setName(TARGET_PROJECT);
-		project.setParameter(projectParameter);
-		project.setValue(targetProject);
-		config.getParameterValues().add(project);
-		FeatureParameterValue targetFolderValue = SGenFactory.eINSTANCE
-				.createFeatureParameterValue();
-		FeatureParameter targetParameter = SGenFactory.eINSTANCE
-				.createFeatureParameter();
-		targetParameter.setName(TARGET_FOLDER);
-		targetFolderValue.setParameter(targetParameter);
-		targetFolderValue.setValue(targetFolder);
-		config.getParameterValues().add(targetFolderValue);
-		entry.getFeatures().add(config);
-		return entry;
-	}
-
-}
+/**
+ * Copyright (c) 2012 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:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.generator.java.util;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaModelMarker;
+import org.yakindu.sct.generator.core.library.IOutletFeatureHelper;
+import org.yakindu.sct.generator.core.library.OutletFeatureHelperImpl;
+import org.yakindu.sct.generator.java.JavaCodeGenerator;
+import org.yakindu.sct.model.sgen.FeatureConfiguration;
+import org.yakindu.sct.model.sgen.FeatureParameter;
+import org.yakindu.sct.model.sgen.FeatureParameterValue;
+import org.yakindu.sct.model.sgen.FeatureType;
+import org.yakindu.sct.model.sgen.GeneratorEntry;
+import org.yakindu.sct.model.sgen.SGenFactory;
+import org.yakindu.sct.model.sgraph.Statechart;
+
+import com.google.inject.Inject;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public abstract class AbstractJavaGeneratorTest {
+
+	private static final String SRC_GEN = "src-gen";
+	private static final String TARGET_PROJECT = "targetProject";
+	private static final String CONTENT_TYPE = "statechart";
+	private static final String OUTLET_FEATURE = "Outlet";
+	private static final String TARGET_FOLDER = "targetFolder";
+	private static final IOutletFeatureHelper outletFeatureConfigurationHelper = new OutletFeatureHelperImpl();
+
+	@Inject
+	protected JavaCodeGenerator generator;
+
+	public IMarker[] generateAndCompile(Statechart statechart) throws Exception {
+		GeneratorEntry entry = createGeneratorEntry(statechart.getName(), SRC_GEN);
+		entry.setElementRef(statechart);
+		IProject targetProject = getProject(entry);
+		targetProject.delete(true, new NullProgressMonitor());
+		generator.generate(entry);
+		targetProject.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+		targetProject = getProject(entry);
+		if (!targetProject.exists()) {
+			targetProject.create(new NullProgressMonitor());
+			targetProject.open(new NullProgressMonitor());
+		}
+		targetProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
+		IMarker[] markers = targetProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
+				IResource.DEPTH_INFINITE);
+		return markers;
+	}
+
+	protected IProject getProject(GeneratorEntry entry) {
+		return ResourcesPlugin.getWorkspace().getRoot().getProject(outletFeatureConfigurationHelper.getTargetProjectValue(entry).getStringValue());
+	}
+
+	private GeneratorEntry createGeneratorEntry(String targetProject, String targetFolder) {
+		GeneratorEntry entry = SGenFactory.eINSTANCE.createGeneratorEntry();
+		entry.setContentType(CONTENT_TYPE);
+		FeatureConfiguration config = SGenFactory.eINSTANCE.createFeatureConfiguration();
+		FeatureType type = SGenFactory.eINSTANCE.createFeatureType();
+		type.setName(OUTLET_FEATURE);
+		config.setType(type);
+		FeatureParameterValue project = SGenFactory.eINSTANCE.createFeatureParameterValue();
+		FeatureParameter projectParameter = SGenFactory.eINSTANCE.createFeatureParameter();
+		projectParameter.setName(TARGET_PROJECT);
+		project.setParameter(projectParameter);
+		project.setValue(targetProject);
+		config.getParameterValues().add(project);
+		FeatureParameterValue targetFolderValue = SGenFactory.eINSTANCE.createFeatureParameterValue();
+		FeatureParameter targetParameter = SGenFactory.eINSTANCE.createFeatureParameter();
+		targetParameter.setName(TARGET_FOLDER);
+		targetFolderValue.setParameter(targetParameter);
+		targetFolderValue.setValue(targetFolder);
+		config.getParameterValues().add(targetFolderValue);
+		entry.getFeatures().add(config);
+		return entry;
+	}
+
+}