markus.muehlbrandt@gmail.com 13 years ago
parent
commit
177b537afb

+ 2 - 14
examples/org.yakindu.sct.examples.trafficlight/GenModelJava.sgen

@@ -12,24 +12,13 @@ GeneratorModel for yakindu::java {
 		}
 
 		feature GeneralFeatures {
-			InterfaceObserverSupport = false
-			TimerService = true
 			RuntimeService = true
+			TimerService = true
 		}
- 
-//		feature FunctionInlining {
-//			inlineChoices = true
-//			inlineEnterSequences = true
-//			inlineEntryActions = true
-//			inlineExitActions = true
-//			inlineExitSequences = true
-//			inlineReactions = true
-//		}
-		
 		
 		feature LicenseHeader {
 			licenseText = "
-Copyright (c) 2011 committers of YAKINDU and others.
+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
@@ -39,6 +28,5 @@ Contributors:
     committers of YAKINDU - initial API and implementation
 �"
 		}
-		
 	}
 }

+ 18 - 18
examples/org.yakindu.sct.examples.trafficlight/TrafficLightWaiting.sct

@@ -111,7 +111,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_w85ZURA_EeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_w85ZUhA_EeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_w85ZWxA_EeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_w85ZUxA_EeGQ0KsLDV4EFg" x="247" y="8" width="262"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_w85ZUxA_EeGQ0KsLDV4EFg" x="243" y="-1" width="185"/>
                 </children>
                 <children xmi:id="_iAUP0BBAEeGQ0KsLDV4EFg" type="State" element="_iAKe0BBAEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_iAUP1BBAEeGQ0KsLDV4EFg" type="StateName">
@@ -144,7 +144,7 @@
                           <styles xsi:type="notation:ShapeStyle" xmi:id="_mjwl0RBAEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                           <styles xsi:type="notation:FontStyle" xmi:id="_mjwl0hBAEeGQ0KsLDV4EFg"/>
                           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_mjwl2xBAEeGQ0KsLDV4EFg"/>
-                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_mjwl0xBAEeGQ0KsLDV4EFg" y="52" width="185" height="80"/>
+                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_mjwl0xBAEeGQ0KsLDV4EFg" x="10" y="52" width="152" height="60"/>
                         </children>
                         <children xmi:id="_n6M0UBBAEeGQ0KsLDV4EFg" type="State" element="_n6DDUBBAEeGQ0KsLDV4EFg">
                           <children xsi:type="notation:DecorationNode" xmi:id="_n6M0VBBAEeGQ0KsLDV4EFg" type="StateName">
@@ -160,7 +160,7 @@
                           <styles xsi:type="notation:ShapeStyle" xmi:id="_n6M0URBAEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                           <styles xsi:type="notation:FontStyle" xmi:id="_n6M0UhBAEeGQ0KsLDV4EFg"/>
                           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_n6M0WxBAEeGQ0KsLDV4EFg"/>
-                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_n6M0UxBAEeGQ0KsLDV4EFg" x="273" y="52" width="188" height="80"/>
+                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_n6M0UxBAEeGQ0KsLDV4EFg" x="285" y="52" width="153" height="60"/>
                         </children>
                         <children xmi:id="_pqhicBBAEeGQ0KsLDV4EFg" type="Entry" element="_pqXxcBBAEeGQ0KsLDV4EFg">
                           <children xmi:id="_pqhicxBAEeGQ0KsLDV4EFg" type="BorderItemLabelContainer">
@@ -172,7 +172,7 @@
                             <layoutConstraint xsi:type="notation:Bounds" xmi:id="_pqhidRBAEeGQ0KsLDV4EFg"/>
                           </children>
                           <styles xsi:type="notation:ShapeStyle" xmi:id="_pqhicRBAEeGQ0KsLDV4EFg" fontName="Verdana" lineColor="4210752"/>
-                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_pqhichBAEeGQ0KsLDV4EFg" x="88" y="7"/>
+                          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_pqhichBAEeGQ0KsLDV4EFg" x="76" y="8"/>
                         </children>
                         <layoutConstraint xsi:type="notation:Bounds" xmi:id="_iBD2txBAEeGQ0KsLDV4EFg"/>
                       </children>
@@ -183,7 +183,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_iAUP0RBAEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_iAUP0hBAEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_iAUP2xBAEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_iAUP0xBAEeGQ0KsLDV4EFg" x="295" y="197" width="513" height="245"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_iAUP0xBAEeGQ0KsLDV4EFg" x="295" y="197" width="513" height="206"/>
                 </children>
                 <children xmi:id="_SKwP4BBBEeGQ0KsLDV4EFg" type="State" element="_SKct4BBBEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_SKwP5BBBEeGQ0KsLDV4EFg" type="StateName">
@@ -199,7 +199,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_SKwP4RBBEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_SKwP4hBBEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_SKwP6xBBEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_SKwP4xBBEeGQ0KsLDV4EFg" x="442" y="514" width="218"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_SKwP4xBBEeGQ0KsLDV4EFg" x="462" y="514" width="178"/>
                 </children>
                 <children xmi:id="_fPRkMBBDEeGQ0KsLDV4EFg" type="State" element="_fO-pQBBDEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_fPRkNBBDEeGQ0KsLDV4EFg" type="StateName">
@@ -215,7 +215,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_fPRkMRBDEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_fPRkMhBDEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_fPRkOxBDEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_fPRkMxBDEeGQ0KsLDV4EFg" x="3" y="514" width="222"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_fPRkMxBDEeGQ0KsLDV4EFg" x="3" y="514" width="170"/>
                 </children>
                 <children xmi:id="_12Y7ABBDEeGQ0KsLDV4EFg" type="State" element="_12GAEBBDEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_12Y7BBBDEeGQ0KsLDV4EFg" type="StateName">
@@ -231,7 +231,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_12Y7ARBDEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_12Y7AhBDEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_12Y7CxBDEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_12Y7AxBDEeGQ0KsLDV4EFg" x="1" y="409" width="224"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_12Y7AxBDEeGQ0KsLDV4EFg" x="1" y="409" width="172"/>
                 </children>
                 <children xmi:id="_K-JX4RBEEeGQ0KsLDV4EFg" type="State" element="_K-JX7RBEEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_K-JX4hBEEeGQ0KsLDV4EFg" type="StateName">
@@ -247,7 +247,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_K-JX6RBEEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_K-JX6hBEEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_K-JX6xBEEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_K-JX7BBEEeGQ0KsLDV4EFg" x="3" y="304" width="222"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_K-JX7BBEEeGQ0KsLDV4EFg" x="3" y="304" width="170"/>
                 </children>
                 <children xmi:id="_TfjYQRBEEeGQ0KsLDV4EFg" type="State" element="_TfjYTRBEEeGQ0KsLDV4EFg">
                   <children xsi:type="notation:DecorationNode" xmi:id="_TfjYQhBEEeGQ0KsLDV4EFg" type="StateName">
@@ -263,7 +263,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_TfjYSRBEEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_TfjYShBEEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_TfjYSxBEEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_TfjYTBBEEeGQ0KsLDV4EFg" x="1" y="179" width="224"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_TfjYTBBEEeGQ0KsLDV4EFg" x="1" y="179" width="172"/>
                 </children>
                 <children xmi:id="_xz9w8BBPEeGQ0KsLDV4EFg" type="Entry" element="_xz0nABBPEeGQ0KsLDV4EFg">
                   <children xmi:id="_xz9w8xBPEeGQ0KsLDV4EFg" type="BorderItemLabelContainer">
@@ -286,7 +286,7 @@
           <styles xsi:type="notation:ShapeStyle" xmi:id="_NPjBmxA-EeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
           <styles xsi:type="notation:FontStyle" xmi:id="_NPjBnBA-EeGQ0KsLDV4EFg"/>
           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_NPsyhRA-EeGQ0KsLDV4EFg"/>
-          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPsyhhA-EeGQ0KsLDV4EFg" x="4" y="43" width="856" height="716"/>
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPsyhhA-EeGQ0KsLDV4EFg" x="4" y="43" width="856" height="696"/>
         </children>
         <children xmi:id="_MGCXkBBFEeGQ0KsLDV4EFg" type="State" element="_MF4mkBBFEeGQ0KsLDV4EFg">
           <children xsi:type="notation:DecorationNode" xmi:id="_MGCXlBBFEeGQ0KsLDV4EFg" type="StateName">
@@ -319,7 +319,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_BV6ncRBGEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_BV6nchBGEeGQ0KsLDV4EFg"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_BV6nexBGEeGQ0KsLDV4EFg"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_BV6ncxBGEeGQ0KsLDV4EFg" x="22" y="40" width="235" height="89"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_BV6ncxBGEeGQ0KsLDV4EFg" x="22" y="40" width="181" height="62"/>
                 </children>
                 <children xmi:id="_EUppcBBGEeGQ0KsLDV4EFg" type="Entry" element="_EUWHcBBGEeGQ0KsLDV4EFg">
                   <children xmi:id="_EUppcxBGEeGQ0KsLDV4EFg" type="BorderItemLabelContainer">
@@ -331,7 +331,7 @@
                     <layoutConstraint xsi:type="notation:Bounds" xmi:id="_EUppdRBGEeGQ0KsLDV4EFg"/>
                   </children>
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_EUppcRBGEeGQ0KsLDV4EFg" fontName="Verdana" lineColor="4210752"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_EUppchBGEeGQ0KsLDV4EFg" x="129" y="4"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_EUppchBGEeGQ0KsLDV4EFg" x="102" y="4"/>
                 </children>
                 <children xmi:id="_B7onYBzuEeGEC4raFz1JbQ" type="State" element="_B6YqMBzuEeGEC4raFz1JbQ">
                   <children xsi:type="notation:DecorationNode" xmi:id="_B7s40BzuEeGEC4raFz1JbQ" type="StateName">
@@ -347,7 +347,7 @@
                   <styles xsi:type="notation:ShapeStyle" xmi:id="_B7onYRzuEeGEC4raFz1JbQ" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
                   <styles xsi:type="notation:FontStyle" xmi:id="_B7onYhzuEeGEC4raFz1JbQ"/>
                   <styles xsi:type="notation:BooleanValueStyle" xmi:id="_B7uG8RzuEeGEC4raFz1JbQ"/>
-                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_B7onYxzuEeGEC4raFz1JbQ" x="22" y="179" width="235"/>
+                  <layoutConstraint xsi:type="notation:Bounds" xmi:id="_B7onYxzuEeGEC4raFz1JbQ" x="22" y="150" width="181"/>
                 </children>
                 <layoutConstraint xsi:type="notation:Bounds" xmi:id="_xHQAdBBFEeGQ0KsLDV4EFg"/>
               </children>
@@ -358,12 +358,12 @@
           <styles xsi:type="notation:ShapeStyle" xmi:id="_MGCXkRBFEeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15981773" lineColor="12632256"/>
           <styles xsi:type="notation:FontStyle" xmi:id="_MGCXkhBFEeGQ0KsLDV4EFg"/>
           <styles xsi:type="notation:BooleanValueStyle" xmi:id="_MGMIlBBFEeGQ0KsLDV4EFg"/>
-          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_MGCXkxBFEeGQ0KsLDV4EFg" x="945" y="208" width="328" height="446"/>
+          <layoutConstraint xsi:type="notation:Bounds" xmi:id="_MGCXkxBFEeGQ0KsLDV4EFg" x="945" y="208" width="270" height="367"/>
         </children>
         <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPjBixA-EeGQ0KsLDV4EFg"/>
       </children>
       <styles xsi:type="notation:ShapeStyle" xmi:id="_NPjBhRA-EeGQ0KsLDV4EFg" fontName="Verdana" fillColor="15790320" lineColor="12632256"/>
-      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPjBjBA-EeGQ0KsLDV4EFg" x="192" y="10" width="1321" height="803"/>
+      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPjBjBA-EeGQ0KsLDV4EFg" x="192" y="10" width="1279" height="783"/>
     </children>
     <children xsi:type="notation:Shape" xmi:id="_NPsyjxA-EeGQ0KsLDV4EFg" type="StatechartText" fontName="Verdana" lineColor="4210752">
       <children xsi:type="notation:DecorationNode" xmi:id="_NPsykRA-EeGQ0KsLDV4EFg" type="StatechartName">
@@ -373,7 +373,7 @@
       <children xsi:type="notation:Shape" xmi:id="_NPsylBA-EeGQ0KsLDV4EFg" type="StatechartTextExpression" fontName="Verdana" lineColor="4210752">
         <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPsylRA-EeGQ0KsLDV4EFg"/>
       </children>
-      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPsylhA-EeGQ0KsLDV4EFg" x="-7" y="10" width="183" height="411"/>
+      <layoutConstraint xsi:type="notation:Bounds" xmi:id="_NPsylhA-EeGQ0KsLDV4EFg" x="10" y="10" width="183" height="215"/>
     </children>
     <styles xsi:type="notation:DiagramStyle" xmi:id="_NPjBghA-EeGQ0KsLDV4EFg"/>
     <edges xmi:id="_NPsyiBA-EeGQ0KsLDV4EFg" type="Transition" element="_NPsyhxA-EeGQ0KsLDV4EFg" source="_NPjBjhA-EeGQ0KsLDV4EFg" target="_NPjBmhA-EeGQ0KsLDV4EFg">
@@ -539,7 +539,7 @@
     <edges xmi:id="_P65-oBzuEeGEC4raFz1JbQ" type="Transition" element="_P6yC0BzuEeGEC4raFz1JbQ" source="_BV6ncBBGEeGQ0KsLDV4EFg" target="_B7onYBzuEeGEC4raFz1JbQ">
       <children xsi:type="notation:DecorationNode" xmi:id="_P66lsRzuEeGEC4raFz1JbQ" type="TransitionExpression">
         <styles xsi:type="notation:ShapeStyle" xmi:id="_P66lshzuEeGEC4raFz1JbQ"/>
-        <layoutConstraint xsi:type="notation:Location" xmi:id="_P66lsxzuEeGEC4raFz1JbQ" x="-7" y="-47"/>
+        <layoutConstraint xsi:type="notation:Location" xmi:id="_P66lsxzuEeGEC4raFz1JbQ" x="-11" y="-32"/>
       </children>
       <styles xsi:type="notation:ConnectorStyle" xmi:id="_P65-oRzuEeGEC4raFz1JbQ" lineColor="4210752"/>
       <styles xsi:type="notation:FontStyle" xmi:id="_P66lsBzuEeGEC4raFz1JbQ" fontName="Verdana"/>

File diff suppressed because it is too large
+ 511 - 255
examples/org.yakindu.sct.examples.trafficlight/src-gen/org/yakindu/sct/examples/trafficlight/cyclebased/trafficlightwaiting/TrafficLightWaitingStatemachine.java


+ 134 - 0
examples/org.yakindu.sct.examples.trafficlight/src/org/yakindu/sct/examples/java/trafficlight/CrossingDemoBase.java

@@ -0,0 +1,134 @@
+package org.yakindu.sct.examples.java.trafficlight;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.draw2d.LightweightSystem;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This class cares about setting up the UI of the pesestrian crossing and
+ * delegates the state machine handling to the concrete subcasses.
+ * 
+ * @author terfloth
+ */
+public abstract class CrossingDemoBase {
+
+	protected Shell shell;
+	protected Display display;
+	protected CrossingFigure crossing;
+	protected TrafficLightFigure trafficLightFigure;
+	protected PedestrianLightFigure pedestrianLightFigure;
+
+	public CrossingDemoBase() {
+		super();
+	}
+
+	protected abstract void setUpAndRunStatemachine();
+
+	protected abstract void tearDownStatemachine();
+
+	protected abstract void readStatemachineOutput();
+
+	protected abstract void pedestrianRequestButtonClicked();
+
+	protected abstract void onOffButtonClicked();
+
+	public void runTrafficLight() {
+
+		setUpAndRunStatemachine();
+		createUIContent();
+
+		shell.open();
+		while (!shell.isDisposed()) {
+			// update traffic lights
+			readStatemachineOutput();
+
+			crossing.repaint();
+
+			if (!display.readAndDispatch()) {
+				display.sleep();
+			}
+		}
+
+		tearDownStatemachine();
+	}
+
+	protected void createUIContent() {
+		display = Display.getDefault();
+		shell = new Shell(display);
+		shell.setSize(400, 400);
+		shell.setText("Traffic Light Demo");
+		GridLayout shellLayout = new GridLayout();
+		shellLayout.numColumns = 1;
+		shell.setLayout(shellLayout);
+
+		LightweightSystem lws = createLightweightsystem(shell);
+		createButtonComposite(shell);
+
+		crossing = new CrossingFigure();
+		lws.setContents(crossing);
+		trafficLightFigure = new TrafficLightFigure();
+		crossing.add(trafficLightFigure);
+		crossing.getLayoutManager().setConstraint(trafficLightFigure,
+				new Rectangle(275, 75, 35, 90));
+
+		pedestrianLightFigure = new PedestrianLightFigure();
+		crossing.add(pedestrianLightFigure);
+		crossing.getLayoutManager().setConstraint(pedestrianLightFigure,
+				new Rectangle(50, 10, 70, 20));
+	}
+
+	protected LightweightSystem createLightweightsystem(Shell shell) {
+
+		FigureCanvas canvas = new FigureCanvas(shell);
+		GridData canvasGridData = new GridData();
+		canvasGridData.horizontalAlignment = GridData.FILL;
+		canvasGridData.verticalAlignment = GridData.FILL;
+		canvasGridData.grabExcessVerticalSpace = true;
+		canvasGridData.grabExcessHorizontalSpace = true;
+		canvas.setLayoutData(canvasGridData);
+		LightweightSystem lws = new LightweightSystem(canvas);
+		return lws;
+	}
+
+	protected void createButtonComposite(Shell shell) {
+		// create a composite to hold the buttons
+		Composite buttonComposite = new Composite(shell, SWT.NO_SCROLL);
+		GridData buttonCompositeGridData = new GridData();
+		buttonCompositeGridData.horizontalAlignment = GridData.FILL;
+		buttonCompositeGridData.grabExcessHorizontalSpace = true;
+		buttonComposite.setLayoutData(buttonCompositeGridData);
+		FillLayout buttonCompositeLayout = new FillLayout();
+		buttonCompositeLayout.type = SWT.HORIZONTAL;
+		buttonComposite.setLayout(new FillLayout());
+
+		// create a button and event handlers
+
+		Button pedestrianRequest = new Button(buttonComposite, SWT.PUSH);
+		pedestrianRequest.setText("pedestrian request");
+		pedestrianRequest.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(final org.eclipse.swt.widgets.Event event) {
+				pedestrianRequestButtonClicked();
+			}
+
+		});
+
+		Button onOff = new Button(buttonComposite, SWT.PUSH);
+		onOff.setText("on / off");
+		onOff.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(final org.eclipse.swt.widgets.Event event) {
+				onOffButtonClicked();
+			}
+
+		});
+	}
+
+}

+ 79 - 0
examples/org.yakindu.sct.examples.trafficlight/src/org/yakindu/sct/examples/java/trafficlight/CrossingDemoCycleBased.java

@@ -0,0 +1,79 @@
+/**
+ * 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.examples.java.trafficlight;
+
+import org.yakindu.sct.examples.trafficlight.cyclebased.RuntimeService;
+import org.yakindu.sct.examples.trafficlight.cyclebased.TimerService;
+import org.yakindu.sct.examples.trafficlight.cyclebased.trafficlightwaiting.TrafficLightWaitingStatemachine;
+
+/**
+ * Example to show how to integrate the generated statemachine code into
+ * existing projects.
+ * 
+ * @author a.nyssen - initial API and implementation
+ * @author m.muehlbrandt - adaptions to new statemachine code.
+ * @author terfloth - refactoring
+ */
+
+public class CrossingDemoCycleBased extends CrossingDemoBase {
+
+	private TrafficLightWaitingStatemachine statemachine;
+
+	public static void main(String[] args) {
+
+		new CrossingDemoCycleBased().runTrafficLight();
+	}
+
+	@Override
+	protected void setUpAndRunStatemachine() {
+
+		statemachine = new TrafficLightWaitingStatemachine();
+		statemachine.setTimerService(new TimerService());
+		statemachine.enter();
+		
+		RuntimeService.getInstance().registerStatemachine(statemachine, 100);
+	}
+
+	@Override
+	protected void tearDownStatemachine() {
+		// End TimerHandler and RuntimeService.
+		statemachine.getTimerService().cancel();
+		RuntimeService.getInstance().cancelTimer();
+	}
+
+	@Override
+	protected void readStatemachineOutput() {
+		trafficLightFigure.setRed(statemachine.getSCITrafficLight()
+				.getRed());
+		trafficLightFigure.setYellow(statemachine.getSCITrafficLight()
+				.getYellow());
+		trafficLightFigure.setGreen(statemachine.getSCITrafficLight()
+				.getGreen());
+
+		pedestrianLightFigure.setWhite(statemachine.getSCIPedestrian()
+				.getRequest());
+		pedestrianLightFigure.setRed(statemachine.getSCIPedestrian()
+				.getRed());
+		pedestrianLightFigure.setGreen(statemachine.getSCIPedestrian()
+				.getGreen());
+	}
+
+	@Override
+	protected void pedestrianRequestButtonClicked() {
+		statemachine.raisePedestrianRequest(); // raise event in statemachine
+	}
+
+	@Override
+	protected void onOffButtonClicked() {
+		statemachine.raiseOnOff(); // raise event in statemachine
+	}
+
+}

+ 58 - 0
examples/org.yakindu.sct.examples.trafficlight/src/org/yakindu/sct/examples/java/trafficlight/CrossingFigure.java

@@ -0,0 +1,58 @@
+/**
+ * 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.examples.java.trafficlight;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Draw2d figure for the crossing. Used by CrossingDemo. 
+ * 
+ * @author a.nyssen
+ *
+ */
+public class CrossingFigure extends Figure {
+
+	public CrossingFigure() {
+		this.setLayoutManager(new XYLayout());
+
+	}
+
+	@Override
+	protected void paintFigure(Graphics graphics) {
+		Rectangle bounds = getBounds();
+
+		graphics
+				.setBackgroundColor(org.eclipse.draw2d.ColorConstants.lightGreen); // street
+																					// is
+																					// within
+																					// countryside
+																					// :-)
+		graphics.fillRectangle(bounds);
+
+		// paint street
+		graphics.setBackgroundColor(ColorConstants.lightGray);
+		graphics.fillRectangle(bounds.x + bounds.width / 3, bounds.y,
+				bounds.width / 3, bounds.height);
+
+		// paint crossing
+		graphics.setBackgroundColor(ColorConstants.white);
+		for (int i = 0; i <= 10; i += 2) {
+			graphics.fillRectangle(bounds.x + bounds.width / 3 + i
+					* bounds.width / 33, bounds.y + bounds.height / 11,
+					bounds.width / 30, bounds.height / 10);
+		}
+
+	}
+}

+ 78 - 0
examples/org.yakindu.sct.examples.trafficlight/src/org/yakindu/sct/examples/java/trafficlight/PedestrianLightFigure.java

@@ -0,0 +1,78 @@
+/**
+ * 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.examples.java.trafficlight;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Draw2d figure for the pedestrian traffic light. Used by CrossingDemo. 
+ * 
+ * @author a.nyssen
+ *
+ */
+public class PedestrianLightFigure extends Figure {
+
+	boolean white = false;
+	boolean red = false;
+	boolean green = false;
+
+	public boolean isWhite() {
+		return white;
+	}
+
+	public void setWhite(boolean white) {
+		this.white = white;
+	}
+
+	public boolean isRed() {
+		return red;
+	}
+
+	public void setRed(boolean red) {
+		this.red = red;
+	}
+
+	public boolean isGreen() {
+		return green;
+	}
+
+	public void setGreen(boolean green) {
+		this.green = green;
+	}
+
+	@Override
+	protected void paintFigure(Graphics graphics) {
+		Rectangle bounds = getBounds().getShrinked(new Insets(4, 4, 4, 4));
+
+		graphics.setBackgroundColor(ColorConstants.darkGray);
+		graphics.fillRectangle(getBounds());
+
+		graphics.setBackgroundColor(white ? ColorConstants.white
+				: ColorConstants.black);
+		graphics.fillRectangle(bounds.x, bounds.y, bounds.width / 5,
+				bounds.width / 5);
+
+		graphics.setBackgroundColor(red ? ColorConstants.red
+				: ColorConstants.black);
+		graphics.fillOval(bounds.x + 2 * bounds.width / 5, bounds.y,
+				bounds.width / 5, bounds.width / 5);
+
+		graphics.setBackgroundColor(green ? ColorConstants.green
+				: ColorConstants.black);
+		graphics.fillOval(bounds.x + 4 * bounds.width / 5, bounds.y,
+				bounds.width / 5, bounds.width / 5);
+
+	}
+}

+ 77 - 0
examples/org.yakindu.sct.examples.trafficlight/src/org/yakindu/sct/examples/java/trafficlight/TrafficLightFigure.java

@@ -0,0 +1,77 @@
+/**
+ * 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.examples.java.trafficlight;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Draw2d figure for the traffic light. Used by CrossingDemo. 
+ * 
+ * @author a.nyssen
+ *
+ */
+public class TrafficLightFigure extends Figure {
+
+	private boolean red = false;
+	private boolean yellow = false;
+	private boolean green = false;
+
+	public boolean isRed() {
+		return red;
+	}
+
+	public void setRed(boolean red) {
+		this.red = red;
+	}
+
+	public boolean isYellow() {
+		return yellow;
+	}
+
+	public void setYellow(boolean yellow) {
+		this.yellow = yellow;
+	}
+
+	public boolean isGreen() {
+		return green;
+	}
+
+	public void setGreen(boolean green) {
+		this.green = green;
+	}
+
+	@Override
+	protected void paintFigure(Graphics graphics) {
+		Rectangle bounds = getBounds().getShrinked(new Insets(10, 10, 10, 10));
+
+		graphics.setBackgroundColor(ColorConstants.darkGray);
+		graphics.fillRectangle(getBounds());
+
+		graphics.setBackgroundColor(red ? ColorConstants.red
+				: ColorConstants.black);
+		graphics.fillOval(bounds.x, bounds.y, bounds.height / 5,
+				bounds.height / 5);
+
+		graphics.setBackgroundColor(yellow ? ColorConstants.yellow
+				: ColorConstants.black);
+		graphics.fillOval(bounds.x, bounds.y + 2 * bounds.height / 5,
+				bounds.height / 5, bounds.height / 5);
+
+		graphics.setBackgroundColor(green ? ColorConstants.green
+				: ColorConstants.black);
+		graphics.fillOval(bounds.x, bounds.y + 4 * bounds.height / 5,
+				bounds.height / 5, bounds.height / 5);
+	}
+}