Преглед изворни кода

Removed Java SWT Example since we do not bundle PDE in product anymore

Andreas Muelder пре 9 година
родитељ
комит
bb9bfda1b7

+ 1 - 2
examples/org.yakindu.sct.examples.trafficlight/.classpath

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

+ 1 - 0
examples/org.yakindu.sct.examples.trafficlight/.settings/org.eclipse.jdt.core.prefs

@@ -1,5 +1,6 @@
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.7

+ 0 - 9
examples/org.yakindu.sct.examples.trafficlight/META-INF/MANIFEST.MF

@@ -1,9 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: YAKINDU TrafficLight Example
-Bundle-SymbolicName: org.yakindu.sct.examples.trafficlight
-Bundle-Version: 2.5.0.qualifier
-Export-Package: org.yakindu.sct.examples.java.trafficlight
-Require-Bundle: org.eclipse.draw2d;bundle-version="3.7.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Bundle-Vendor: statecharts.org

+ 2 - 4
examples/org.yakindu.sct.examples.trafficlight/build.properties

@@ -1,4 +1,2 @@
-source.. = src/,\
-           src-gen/
-bin.includes = META-INF/,\
-               .
+source.. = src-gen/
+bin.includes = .

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

@@ -1,134 +0,0 @@
-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();
-			}
-
-		});
-	}
-
-}

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

@@ -1,83 +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.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;
-	
-	private TimerService timer;
-
-	public static void main(String[] args) {
-
-		new CrossingDemoCycleBased().runTrafficLight();
-	}
-
-	@Override
-	protected void setUpAndRunStatemachine() {
-
-		statemachine = new TrafficLightWaitingStatemachine();
-		timer = new TimerService();
-		statemachine.setTimer(timer);
-		statemachine.init();
-		statemachine.enter();
-		
-		RuntimeService.getInstance().registerStatemachine(statemachine, 100);
-	}
-
-	@Override
-	protected void tearDownStatemachine() {
-		// End TimerHandler and RuntimeService.
-		timer.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
-	}
-
-}

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

@@ -1,58 +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.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);
-		}
-
-	}
-}

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

@@ -1,78 +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.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);
-
-	}
-}

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

@@ -1,77 +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.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);
-	}
-}