X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=SampleERCP%2Fsrc%2Fsampleercp%2Fparts%2FLogicUIPart.java;fp=SampleERCP%2Fsrc%2Fsampleercp%2Fparts%2FLogicUIPart.java;h=fa18e2d3e292c0dc52089d578411ef15bc56d6a4;hb=939fbe02cf53a659f5f9fdd46394c4a79def73b1;hp=f725d5b62ff8480a8039f12f94d479ec07a103b6;hpb=583c5839cf0d0526268ccc527bfb72058039e403;p=Mograsim.git diff --git a/SampleERCP/src/sampleercp/parts/LogicUIPart.java b/SampleERCP/src/sampleercp/parts/LogicUIPart.java index f725d5b6..fa18e2d3 100644 --- a/SampleERCP/src/sampleercp/parts/LogicUIPart.java +++ b/SampleERCP/src/sampleercp/parts/LogicUIPart.java @@ -8,8 +8,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import era.mi.gui.LogicUICanvas; -import era.mi.gui.examples.RSLatchGUIExample; -import era.mi.logic.timeline.Timeline; +import era.mi.gui.model.ViewModel; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; public class LogicUIPart @@ -20,41 +19,41 @@ public class LogicUIPart @PostConstruct public void create(Composite parent) { - Timeline timeline = new Timeline(11); - LogicUICanvas ui = new LogicUICanvas(parent, SWT.NONE); - RSLatchGUIExample.addComponentsAndWires(ui, timeline); + ViewModel model = new ViewModel(); + LogicUICanvas ui = new LogicUICanvas(parent, SWT.NONE, model); +// RSLatchGUIExample.addComponentsAndWires(ui, timeline); ui.addTransformListener((x, y, z) -> part.setDirty(z < 1)); ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); userInput.buttonDrag = 3; userInput.buttonZoom = 2; userInput.enableUserInput(); - Thread simulationThread = new Thread(() -> - { - // TODO find a better condition - while (!ui.isDisposed()) - { - // always execute to keep timeline from "hanging behind" for too long - timeline.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); - long sleepTime; - if (timeline.hasNext()) - sleepTime = timeline.nextEventTime() - System.currentTimeMillis(); - else - sleepTime = 10; - try - { - if (sleepTime > 0) - Thread.sleep(sleepTime); - } - catch (InterruptedException e) - { - } // it is normal execution flow to be interrupted - } - }); - simulationThread.start(); - timeline.addEventAddedListener(event -> - { - if (event.getTiming() <= System.currentTimeMillis()) - simulationThread.interrupt(); - }); +// Thread simulationThread = new Thread(() -> +// { +// // TODO find a better condition +// while (!ui.isDisposed()) +// { +// // always execute to keep timeline from "hanging behind" for too long +// timeline.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); +// long sleepTime; +// if (timeline.hasNext()) +// sleepTime = timeline.nextEventTime() - System.currentTimeMillis(); +// else +// sleepTime = 10; +// try +// { +// if (sleepTime > 0) +// Thread.sleep(sleepTime); +// } +// catch (InterruptedException e) +// { +// } // it is normal execution flow to be interrupted +// } +// }); +// simulationThread.start(); +// timeline.addEventAddedListener(event -> +// { +// if (event.getTiming() <= System.currentTimeMillis()) +// simulationThread.interrupt(); +// }); } } \ No newline at end of file