X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=SampleERCP%2Fsrc%2Fsampleercp%2Fparts%2FLogicUIPart.java;h=fa18e2d3e292c0dc52089d578411ef15bc56d6a4;hb=939fbe02cf53a659f5f9fdd46394c4a79def73b1;hp=c142cb6727b22602fa5de7b26aa9ab9a560b62e8;hpb=cc5749d29d0a2e37262ec10925676c812a2fa734;p=Mograsim.git diff --git a/SampleERCP/src/sampleercp/parts/LogicUIPart.java b/SampleERCP/src/sampleercp/parts/LogicUIPart.java index c142cb67..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.Simulation; +import era.mi.gui.model.ViewModel; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; public class LogicUIPart @@ -20,40 +19,41 @@ public class LogicUIPart @PostConstruct public void create(Composite parent) { - LogicUICanvas ui = new LogicUICanvas(parent, SWT.NONE); - RSLatchGUIExample.addComponentsAndWires(ui); + 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 - Simulation.TIMELINE.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); - long sleepTime; - if (Simulation.TIMELINE.hasNext()) - sleepTime = Simulation.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(); - Simulation.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