summaryrefslogtreecommitdiff
path: root/de.dhbw.horb.ksm.simulator
diff options
context:
space:
mode:
Diffstat (limited to 'de.dhbw.horb.ksm.simulator')
-rw-r--r--de.dhbw.horb.ksm.simulator/.classpath9
-rw-r--r--de.dhbw.horb.ksm.simulator/.gitignore1
-rw-r--r--de.dhbw.horb.ksm.simulator/.project28
-rw-r--r--de.dhbw.horb.ksm.simulator/.settings/org.eclipse.jdt.core.prefs8
-rw-r--r--de.dhbw.horb.ksm.simulator/META-INF/MANIFEST.MF16
-rw-r--r--de.dhbw.horb.ksm.simulator/build.properties7
-rw-r--r--de.dhbw.horb.ksm.simulator/icons/16/ksm-simulator.pngbin0 -> 1101 bytes
-rw-r--r--de.dhbw.horb.ksm.simulator/icons/32/ksm-simulator.pngbin0 -> 2200 bytes
-rw-r--r--de.dhbw.horb.ksm.simulator/lib/org.swtchart.ext_0.7.0.v20110128.jarbin0 -> 94661 bytes
-rw-r--r--de.dhbw.horb.ksm.simulator/lib/org.swtchart_0.7.0.v20110128.jarbin0 -> 173774 bytes
-rw-r--r--de.dhbw.horb.ksm.simulator/plugin.xml26
-rw-r--r--de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/Activator.java50
-rw-r--r--de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/perspective/SimulatorPerspective.java33
-rw-r--r--de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/view/SimulatorView.java184
14 files changed, 362 insertions, 0 deletions
diff --git a/de.dhbw.horb.ksm.simulator/.classpath b/de.dhbw.horb.ksm.simulator/.classpath
new file mode 100644
index 0000000..65582bc
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/.classpath
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib" path="lib/org.swtchart_0.7.0.v20110128.jar"/>
+ <classpathentry exported="true" kind="lib" path="lib/org.swtchart.ext_0.7.0.v20110128.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/de.dhbw.horb.ksm.simulator/.gitignore b/de.dhbw.horb.ksm.simulator/.gitignore
new file mode 100644
index 0000000..e660fd9
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/.gitignore
@@ -0,0 +1 @@
+bin/
diff --git a/de.dhbw.horb.ksm.simulator/.project b/de.dhbw.horb.ksm.simulator/.project
new file mode 100644
index 0000000..797d7bb
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>de.dhbw.horb.ksm.simulator</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>
diff --git a/de.dhbw.horb.ksm.simulator/.settings/org.eclipse.jdt.core.prefs b/de.dhbw.horb.ksm.simulator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..4741363
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Mon May 09 15:47:49 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/de.dhbw.horb.ksm.simulator/META-INF/MANIFEST.MF b/de.dhbw.horb.ksm.simulator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..727b6a8
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: KSM Simulator Prototype
+Bundle-SymbolicName: de.dhbw.horb.ksm.simulator;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: de.dhbw.horb.simulator.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ de.dhbw.horb.ksm.core;bundle-version="1.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Import-Package: de.dhbw.horb.ksm.model.api,
+ org.eclipse.gef.commands
+Bundle-ClassPath: lib/org.swtchart_0.7.0.v20110128.jar,
+ lib/org.swtchart.ext_0.7.0.v20110128.jar,
+ .
diff --git a/de.dhbw.horb.ksm.simulator/build.properties b/de.dhbw.horb.ksm.simulator/build.properties
new file mode 100644
index 0000000..2ba7ae7
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/build.properties
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ lib/org.swtchart_0.7.0.v20110128.jar,\
+ lib/org.swtchart.ext_0.7.0.v20110128.jar
diff --git a/de.dhbw.horb.ksm.simulator/icons/16/ksm-simulator.png b/de.dhbw.horb.ksm.simulator/icons/16/ksm-simulator.png
new file mode 100644
index 0000000..89d3780
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/icons/16/ksm-simulator.png
Binary files differ
diff --git a/de.dhbw.horb.ksm.simulator/icons/32/ksm-simulator.png b/de.dhbw.horb.ksm.simulator/icons/32/ksm-simulator.png
new file mode 100644
index 0000000..554de7e
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/icons/32/ksm-simulator.png
Binary files differ
diff --git a/de.dhbw.horb.ksm.simulator/lib/org.swtchart.ext_0.7.0.v20110128.jar b/de.dhbw.horb.ksm.simulator/lib/org.swtchart.ext_0.7.0.v20110128.jar
new file mode 100644
index 0000000..cb0d4e6
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/lib/org.swtchart.ext_0.7.0.v20110128.jar
Binary files differ
diff --git a/de.dhbw.horb.ksm.simulator/lib/org.swtchart_0.7.0.v20110128.jar b/de.dhbw.horb.ksm.simulator/lib/org.swtchart_0.7.0.v20110128.jar
new file mode 100644
index 0000000..6ee142b
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/lib/org.swtchart_0.7.0.v20110128.jar
Binary files differ
diff --git a/de.dhbw.horb.ksm.simulator/plugin.xml b/de.dhbw.horb.ksm.simulator/plugin.xml
new file mode 100644
index 0000000..2808e8c
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/plugin.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ allowMultiple="false"
+ category="ksm.core.views.KSMCategory"
+ class="de.dhbw.horb.simulator.view.SimulatorView"
+ icon="icons/16/ksm-simulator.png"
+ id="ksm.simulator.views.SimulatorView"
+ name="Simulator"
+ restorable="true">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ class="de.dhbw.horb.simulator.perspective.SimulatorPerspective"
+ fixed="true"
+ icon="icons/32/ksm-simulator.png"
+ id="ksm.simulator.perspectives.SimulatorPerspective"
+ name="Simulator">
+ </perspective>
+ </extension>
+</plugin>
diff --git a/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/Activator.java b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/Activator.java
new file mode 100644
index 0000000..274c2dd
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/Activator.java
@@ -0,0 +1,50 @@
+package de.dhbw.horb.simulator;
+
+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 = "Simulator"; //$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;
+ }
+
+}
diff --git a/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/perspective/SimulatorPerspective.java b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/perspective/SimulatorPerspective.java
new file mode 100644
index 0000000..c040bdc
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/perspective/SimulatorPerspective.java
@@ -0,0 +1,33 @@
+package de.dhbw.horb.simulator.perspective;
+
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+import de.dhbw.horb.simulator.view.SimulatorView;
+
+public class SimulatorPerspective implements IPerspectiveFactory {
+ public static final String ID = "ksm.simulator.perspectives.SimulatorPerspective"; //$NON-NLS-N$
+ private IPageLayout factory;
+
+ public SimulatorPerspective() {
+ super();
+ }
+
+ public void createInitialLayout(IPageLayout factory) {
+ this.factory = factory;
+ factory.setEditorAreaVisible(true);
+ addViews();
+ }
+
+ private void addViews() {
+ IFolderLayout topLeft = factory.createFolder("topLeft", //$NON-NLS-N$
+ IPageLayout.LEFT, 0.30f, factory.getEditorArea());
+
+ topLeft.addView(de.dhbw.horb.ksm.core.view.Navigator.VIEW_ID);
+
+ IFolderLayout topRight = factory.createFolder("bottom",
+ IPageLayout.BOTTOM, 0.30f, factory.getEditorArea());
+ topRight.addView(SimulatorView.VIEW_ID);
+ }
+} \ No newline at end of file
diff --git a/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/view/SimulatorView.java b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/view/SimulatorView.java
new file mode 100644
index 0000000..2cdf737
--- /dev/null
+++ b/de.dhbw.horb.ksm.simulator/src/de/dhbw/horb/simulator/view/SimulatorView.java
@@ -0,0 +1,184 @@
+package de.dhbw.horb.simulator.view;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.EventObject;
+
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gef.commands.CommandStackListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.part.MessagePage;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.PageBookView;
+import org.eclipse.ui.part.PageSite;
+import org.swtchart.Chart;
+import org.swtchart.ILineSeries;
+import org.swtchart.ISeries.SeriesType;
+
+import de.dhbw.horb.ksm.core.editor.model.ModelProperties;
+import de.dhbw.horb.ksm.core.editor.ui.DiagramEditor;
+import de.dhbw.horb.ksm.model.api.Node;
+
+public class SimulatorView extends PageBookView {
+ public final static String VIEW_ID = "ksm.simulator.views.SimulatorView";
+
+ private final String message = "No compatible Editor selected";
+
+ @Override
+ public void setFocus() {
+
+ }
+
+ @Override
+ protected IPage createDefaultPage(PageBook book) {
+ MessagePage page = new MessagePage();
+ initPage(page);
+ page.createControl(book);
+ page.setMessage(message);
+ return page;
+ }
+
+ @Override
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ if (part instanceof DiagramEditor) {
+ DiagramEditor editor = (DiagramEditor) part;
+ SimulatorPage page = new SimulatorPage(editor);
+ page.init(new PageSite(getViewSite()));
+ page.createControl(getPageBook());
+ return new PageRec(part, page);
+ }
+ return null;
+ }
+
+ @Override
+ protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
+ pageRecord.page.dispose();
+ pageRecord.dispose();
+ }
+
+ @Override
+ protected IWorkbenchPart getBootstrapPart() {
+ IWorkbenchPage page = getSite().getPage();
+ if (page != null) {
+ return page.getActiveEditor();
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean isImportant(IWorkbenchPart part) {
+ return (part instanceof DiagramEditor);
+ }
+
+ private class SimulatorPage extends Page implements CommandStackListener {
+ private Chart chart;
+ private ILineSeries xPositionSeries;
+ private final DiagramEditor editor;
+ private ILineSeries yPositionSeries;
+
+ public SimulatorPage(DiagramEditor editor) {
+ this.editor = editor;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ chart = new Chart(parent, SWT.NONE);
+
+ chart.getTitle().setVisible(false);
+ chart.getAxisSet().getXAxis(0).getTitle().setText("KSM Knoten");
+ chart.getAxisSet().getYAxis(0).getTitle().setText("Position");
+
+ xPositionSeries = (ILineSeries) chart.getSeriesSet().createSeries(
+ SeriesType.LINE, "X-Position");
+ xPositionSeries.setLineColor(Display.getCurrent().getSystemColor(
+ SWT.COLOR_BLUE));
+ yPositionSeries = (ILineSeries) chart.getSeriesSet().createSeries(
+ SeriesType.LINE, "Y-Position");
+ yPositionSeries.setLineColor(Display.getCurrent().getSystemColor(
+ SWT.COLOR_RED));
+
+ // Enable Strings as X-Axis Ticks
+ chart.getAxisSet().getXAxes()[0].enableCategory(true);
+
+ refresh();
+
+ ((CommandStack) editor.getAdapter(CommandStack.class))
+ .addCommandStackListener(this);
+ }
+
+ @Override
+ public void commandStackChanged(EventObject event) {
+ refresh();
+ }
+
+ private void refresh() {
+ ArrayList<int[]> listXY = new ArrayList<int[]>();
+ ArrayList<String> listCaptions = new ArrayList<String>();
+ for (Node n : editor.getModel().getAllNodes()) {
+ BigInteger locationX = n
+ .getProperties()
+ .getInteger(
+ ModelProperties.INSTANCE
+ .stripType(ModelProperties.INSTANCE.NODE_VISUAL_LOCATION_X));
+ BigInteger locationY = n
+ .getProperties()
+ .getInteger(
+ ModelProperties.INSTANCE
+ .stripType(ModelProperties.INSTANCE.NODE_VISUAL_LOCATION_Y));
+ listXY.add(new int[] { locationX.intValue(),
+ locationY.intValue() });
+
+ String caption = n
+ .getProperties()
+ .getString(
+ ModelProperties.INSTANCE
+ .stripType(ModelProperties.INSTANCE.NODE_VISUAL_CAPTION));
+ listCaptions.add(caption);
+ }
+ double[] seriesX = new double[listXY.size()];
+ double[] seriesY = new double[listXY.size()];
+ String[] xCaption = new String[listXY.size()];
+ for (int i = 0; i < listXY.size(); i++) {
+ seriesX[i] = listXY.get(i)[0];
+ seriesY[i] = listXY.get(i)[1];
+ xCaption[i] = listCaptions.get(i);
+ }
+
+ // Set Y-Axis Data
+ xPositionSeries.setYSeries(seriesX);
+ yPositionSeries.setYSeries(seriesY);
+
+ // Set X-Axis Description
+ chart.getAxisSet().getXAxes()[0].setCategorySeries(xCaption);
+
+ // adjust the axis range and redraw
+ chart.getAxisSet().adjustRange();
+ chart.redraw();
+ }
+
+ @Override
+ public Control getControl() {
+ return chart;
+ }
+
+ @Override
+ public void setFocus() {
+ chart.setFocus();
+ }
+
+ @Override
+ public void dispose() {
+ ((CommandStack) editor.getAdapter(CommandStack.class))
+ .removeCommandStackListener(this);
+ super.dispose();
+ chart.dispose();
+ }
+ }
+}