Browse Source

Share project "org.yakindu.sct.statechart.core.resource" into "https://svn.codespot.com/a/eclipselabs.org/yakindu"

Andreas Mülder 14 years ago
parent
commit
6ba8ed3ce5

+ 7 - 0
plugins/org.yakindu.sct.statechart.core.resource/.classpath

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

+ 28 - 0
plugins/org.yakindu.sct.statechart.core.resource/.project

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.yakindu.sct.statechart.core.resource</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 8 - 0
plugins/org.yakindu.sct.statechart.core.resource/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,8 @@
+#Sat May 21 17:21:25 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5

+ 15 - 0
plugins/org.yakindu.sct.statechart.core.resource/META-INF/MANIFEST.MF

@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Resource
+Bundle-SymbolicName: org.yakindu.sct.statechart.core.resource;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: YAKINDU
+Bundle-Activator: org.yakindu.sct.statechart.core.resource.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.yakindu.sct.statechart.expressions.ui;bundle-version="1.0.0",
+ org.yakindu.sct.model.statechart;bundle-version="1.0.0",
+ de.itemis.xtext.utils.gmf;bundle-version="1.0.0",
+ org.eclipse.gmf.runtime.emf.core;bundle-version="1.4.1"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy

+ 5 - 0
plugins/org.yakindu.sct.statechart.core.resource/build.properties

@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml

+ 14 - 0
plugins/org.yakindu.sct.statechart.core.resource/plugin.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+<!-- Resource   -->
+  <extension
+         point="org.eclipse.emf.ecore.extension_parser">
+      <parser
+            class="org.yakindu.sct.statechart.core.resource.InjectMembersResourceFactory"
+            type="sct">
+      </parser>
+   </extension>
+
+</plugin>

+ 50 - 0
plugins/org.yakindu.sct.statechart.core.resource/src/org/yakindu/sct/statechart/core/resource/Activator.java

@@ -0,0 +1,50 @@
+package org.yakindu.sct.statechart.core.resource;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.yakindu.sct.statechart.core.resource"; //$NON-NLS-1$
+
+	// The shared instance
+	private static Activator plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+}

+ 40 - 0
plugins/org.yakindu.sct.statechart.core.resource/src/org/yakindu/sct/statechart/core/resource/InjectMembersResourceFactory.java

@@ -0,0 +1,40 @@
+package org.yakindu.sct.statechart.core.resource;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.yakindu.sct.statechart.ExpressionsRuntimeModule;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import de.itemis.xtext.utils.gmf.resource.InjectMembersResource;
+
+/**
+ * 
+ * @author andreas muelder (andreas.muelder@itemis.de)
+ * 
+ */
+public class InjectMembersResourceFactory extends XMIResourceFactoryImpl {
+
+	@Override
+	public Resource createResource(URI uri) {
+		InjectMembersResource resource = new InjectMembersResource(uri);
+		System.out.println("Execute factory");
+		ExpressionsRuntimeModule module = new ExpressionsRuntimeModule();
+		Injector injector = Guice.createInjector(module);
+		// Add a Transition service
+		TransitionInjectionService transitionService = new TransitionInjectionService();
+		injector.injectMembers(transitionService);
+		resource.getServices().add(transitionService);
+		// Add a State service
+		StateInjectionService stateService = new StateInjectionService();
+		injector.injectMembers(stateService);
+		resource.getServices().add(stateService);
+		// Add a Statechart service
+		StatechartInjectionService statechartService = new StatechartInjectionService();
+		injector.injectMembers(statechartService);
+		resource.getServices().add(statechartService);
+		return resource;
+	}
+}

+ 57 - 0
plugins/org.yakindu.sct.statechart.core.resource/src/org/yakindu/sct/statechart/core/resource/StateInjectionService.java

@@ -0,0 +1,57 @@
+package org.yakindu.sct.statechart.core.resource;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.yakindu.model.sct.statechart.Declaration;
+import org.yakindu.model.sct.statechart.Scope;
+import org.yakindu.model.sct.statechart.State;
+import org.yakindu.model.sct.statechart.StatechartFactory;
+import org.yakindu.model.sct.statechart.StatechartPackage;
+import org.yakindu.sct.statechart.expressions.SimpleScope;
+
+import de.itemis.xtext.utils.gmf.resource.AbstractXtextMemberInjectionService;
+import de.itemis.xtext.utils.gmf.resource.IMemberInjectionService;
+
+/**
+ * Implementation if {@link IMemberInjectionService} interface to inject the
+ * members of the {@link State} from the textual expression.F
+ * 
+ * @author andreas muelder (andreas.muelder@itemis.de)
+ * 
+ */
+public class StateInjectionService extends
+		AbstractXtextMemberInjectionService<State, SimpleScope> {
+
+	@Override
+	public String getExpression(State object) {
+		return object.getExpression();
+	}
+
+	@Override
+	public String getParserRule() {
+		return SimpleScope.class.getSimpleName();
+	}
+
+	@Override
+	public void setFeatures(State original, SimpleScope rootAST) {
+		Scope localScope = StatechartFactory.eINSTANCE.createScope();
+		EList<Declaration> declarations = rootAST.getDeclarations();
+		localScope.getDeclarations().addAll(declarations);
+		original.getScopes().clear();
+		original.getScopes().add(localScope);
+		System.out.println("Setting features");
+		System.out.println("Declaratinos " + localScope.getDeclarations());
+		System.out.println("Events " + localScope.getEvents());
+		System.out.println(" Variables " + localScope.getVariables());
+	}
+
+	public boolean isServiceFor(EObject object) {
+		return object instanceof State;
+	}
+
+	public EStructuralFeature getSourceFeature() {
+		return StatechartPackage.eINSTANCE.getExpressionElement_Expression();
+	}
+
+}

+ 45 - 0
plugins/org.yakindu.sct.statechart.core.resource/src/org/yakindu/sct/statechart/core/resource/StatechartInjectionService.java

@@ -0,0 +1,45 @@
+package org.yakindu.sct.statechart.core.resource;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.yakindu.model.sct.statechart.Scope;
+import org.yakindu.model.sct.statechart.State;
+import org.yakindu.model.sct.statechart.Statechart;
+import org.yakindu.model.sct.statechart.StatechartPackage;
+import org.yakindu.sct.statechart.expressions.StatechartDefinition;
+
+import de.itemis.xtext.utils.gmf.resource.AbstractXtextMemberInjectionService;
+import de.itemis.xtext.utils.gmf.resource.IMemberInjectionService;
+
+/**
+ * Implementation if {@link IMemberInjectionService} interface to inject the
+ * members of the {@link State} from the textual expression.F
+ * 
+ * @author andreas muelder (andreas.muelder@itemis.de)
+ * 
+ */
+public class StatechartInjectionService extends
+		AbstractXtextMemberInjectionService<Statechart, StatechartDefinition> {
+
+	public boolean isServiceFor(EObject object) {
+		return object instanceof Statechart;
+	}
+
+	@Override
+	public void setFeatures(Statechart original, StatechartDefinition rootAST) {
+		EList<Scope> definitionScopes = rootAST.getDefinitionScopes();
+		original.getScopes().clear();
+		original.getScopes().addAll(definitionScopes);
+	}
+
+	public EStructuralFeature getSourceFeature() {
+		return StatechartPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION;
+	}
+
+	@Override
+	public String getParserRule() {
+		return StatechartDefinition.class.getSimpleName();
+	}
+
+}

+ 39 - 0
plugins/org.yakindu.sct.statechart.core.resource/src/org/yakindu/sct/statechart/core/resource/TransitionInjectionService.java

@@ -0,0 +1,39 @@
+package org.yakindu.sct.statechart.core.resource;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.yakindu.model.sct.statechart.StatechartPackage;
+import org.yakindu.model.sct.statechart.Transition;
+import org.yakindu.sct.statechart.expressions.TransitionReaction;
+
+import de.itemis.xtext.utils.gmf.resource.AbstractXtextMemberInjectionService;
+
+/**
+ * 
+ * @author andreas muelder (andreas.muelder@itemis.de)
+ * 
+ */
+public class TransitionInjectionService extends
+		AbstractXtextMemberInjectionService<Transition, TransitionReaction> {
+
+	@Override
+	public String getParserRule() {
+		return TransitionReaction.class.getSimpleName();
+	}
+
+	@Override
+	public void setFeatures(Transition original, TransitionReaction rootAST) {
+		original.setTrigger(rootAST.getTrigger());
+		original.setEffect(rootAST.getEffect());
+
+	}
+
+	public boolean isServiceFor(EObject object) {
+		return object instanceof Transition;
+	}
+
+	public EAttribute getSourceFeature() {
+		return StatechartPackage.Literals.EXPRESSION_ELEMENT__EXPRESSION;
+	}
+
+}