lafros gui app a lafros gui app a monitoring and control
play

Lafros GUI-App: a Lafros GUI-App: a monitoring and control-oriented - PowerPoint PPT Presentation

Lafros GUI-App: a Lafros GUI-App: a monitoring and control-oriented monitoring and control-oriented Scala-Swing Scala-Swing application framework application framework Rob Dickens Rob Dickens // Latterfrosken // Latterfrosken


  1. Lafros GUI-App: a Lafros GUI-App: a monitoring and control-oriented monitoring and control-oriented Scala-Swing Scala-Swing application framework application framework Rob Dickens Rob Dickens // Latterfrosken // Latterfrosken software.development(limited); software.development(limited); Walsall, West Midlands, UK Walsall, West Midlands, UK

  2. Contents Contents ● 15 mins 15 mins Slides Slides ● 10 mins 10 mins Demo Demo ● 5 mins 5 mins Answers Answers Scala Days 2010 Lafros GUI-App 2/16

  3. What this software is for What this software is for ● intended to simplify writing monitoring and intended to simplify writing monitoring and control-oriented user interfaces for the control-oriented user interfaces for the desktop (in Scala) desktop (in Scala) – intend to use it to write the user interface for intend to use it to write the user interface for an impl'n of the Lafros MaCS remote an impl'n of the Lafros MaCS remote monitoring and control API monitoring and control API ● however, ought to be worth considering however, ought to be worth considering when writing any kind of desktop user when writing any kind of desktop user interface interface Scala Days 2010 Lafros GUI-App 3/16

  4. How it came to be written How it came to be written ● 1995: began writing C++/Motif framework as 1995: began writing C++/Motif framework as part of User Monitoring and Control module part of User Monitoring and Control module for EISCAT Svalbard Radar for EISCAT Svalbard Radar ● 1998: began writing Java version 1998: began writing Java version ● 2002: dev't of Java version continued inde 2002: dev't of Java version continued inde- - pendently => JUICe libraries pendently => JUICe libraries ● 2009: JUICe libraries rewritten in Scala => 2009: JUICe libraries rewritten in Scala => Lafros GUI-App, GUI-Cmds, GUI-Alerts Lafros GUI-App, GUI-Cmds, GUI-Alerts Scala Days 2010 Lafros GUI-App 4/16

  5. A framework depending A framework depending on two sub-frameworks on two sub-frameworks ● GUI-App: deploy same code as application or GUI-App: deploy same code as application or applet applet ● GUI-Cmds: define units of code to be invoked GUI-Cmds: define units of code to be invoked interactively interactively ● GUI-Alerts: monitor changeable values interact GUI-Alerts: monitor changeable values interact- - ively ively Scala Days 2010 Lafros GUI-App 5/16

  6. Deploy same code as Deploy same code as application or applet application or applet ● only need supply an init() method – default only need supply an init() method – default impl'ns are provided for the other methods the impl'ns are provided for the other methods the framework uses: displayApplication(), start(), framework uses: displayApplication(), start(), stopApplet(), restartApplet(), terminate() stopApplet(), restartApplet(), terminate() ● all will be called from a java.awt.EventQueue all will be called from a java.awt.EventQueue dispatch-thread dispatch-thread Scala Days 2010 Lafros GUI-App 6/16

  7. Define your GUI Cmds Define your GUI Cmds ● functions of type, Unit => Option[String] functions of type, Unit => Option[String] – return an optional feedback message return an optional feedback message ● define by extending Cmd trait, or one or define by extending Cmd trait, or one or more of its sub-traits more of its sub-traits – CheckFirstCmd: requests confirmation CheckFirstCmd: requests confirmation – EventDependentCmd: supplies the Event EventDependentCmd: supplies the Event – PwdProtectedCmd: requests password PwdProtectedCmd: requests password – SeqBgCmd: executed in the background SeqBgCmd: executed in the background – TogCmd: flips toggle upon return TogCmd: flips toggle upon return Scala Days 2010 Lafros GUI-App 7/16

  8. Executing GUI Cmds Executing GUI Cmds ● executed indirectly, via an Exer executed indirectly, via an Exer ● associate an AbstractButton via the Trig mix-in associate an AbstractButton via the Trig mix-in Scala Days 2010 Lafros GUI-App 8/16

  9. GUI-Cmds benefits GUI-Cmds benefits ● common functionality provided for you common functionality provided for you ● conditional toggles conditional toggles – only flip if Cmd returns only flip if Cmd returns ● robust robust – exceptions caught exceptions caught ● promote user feedback promote user feedback – feedback and exception messages relayed feedback and exception messages relayed via TheCmdsController to, for example, a via TheCmdsController to, for example, a Gui-App's MsgLine Gui-App's MsgLine Scala Days 2010 Lafros GUI-App 9/16

  10. The GUI-Alerts MonField The GUI-Alerts MonField ● a scala.swing.Label, specialised for display a scala.swing.Label, specialised for display- - ing values that are updated, and to which ing values that are updated, and to which the user's attention might need to be drawn the user's attention might need to be drawn ● has alert property, with the following values: has alert property, with the following values: – NoAlert: normal background colour NoAlert: normal background colour – NonIntrusive: red background NonIntrusive: red background – Intrusive: alternating background accom Intrusive: alternating background accom- - panied by alert sound panied by alert sound – Acknowledged: red background Acknowledged: red background Scala Days 2010 Lafros GUI-App 10/16

  11. Other MonField properties Other MonField properties ● valueToAlert: Any => Alert valueToAlert: Any => Alert ● value: Any value: Any – text = value.toString text = value.toString – alert = valueToAlert(value) alert = valueToAlert(value) ● templateText: String templateText: String – determines width (except when "") determines width (except when "") Scala Days 2010 Lafros GUI-App 11/16

  12. GUI-App/Scala vs JUICe/Java: GUI-App/Scala vs JUICe/Java: usage 1 usage 1 + the declarative style afforded by Scala's the declarative style afforded by Scala's properties makes GUI code far easier to un- - properties makes GUI code far easier to un derstand derstand Scala Days 2010 Lafros GUI-App 12/16

  13. GUI-App/Scala vs JUICe/Java: GUI-App/Scala vs JUICe/Java: usage 2 usage 2 + less work to define GUI Cmds, by virtue of less work to define GUI Cmds, by virtue of their default method impl'ns their default method impl'ns + None preferable to null when GUI Cmds re None preferable to null when GUI Cmds re- - turn no feedback message turn no feedback message + the main method required of applications is the main method required of applications is provided for you provided for you Scala Days 2010 Lafros GUI-App 13/16

  14. GUI-App/Scala vs JUICe/Java: GUI-App/Scala vs JUICe/Java: framework impl'n framework impl'n + whereas JUICe.cmds had to supply a cor whereas JUICe.cmds had to supply a cor- - responding class for every AbstractButton, responding class for every AbstractButton, GUI-Cmds needed supply only a single mix- GUI-Cmds needed supply only a single mix- in, Trig in, Trig + was able to implement SeqBgCmds in GUI- was able to implement SeqBgCmds in GUI- Cmds without recourse to synchronized Cmds without recourse to synchronized blocks, resulting in code which is straight- blocks, resulting in code which is straight- forward to reason about forward to reason about Scala Days 2010 Lafros GUI-App 14/16

  15. GUI-App/Scala vs JUICe/Java: GUI-App/Scala vs JUICe/Java: deployment deployment - dependency on scala-library.jar and scala- dependency on scala-library.jar and scala- swing.jar has implications for downloadable swing.jar has implications for downloadable apps (applets or Java Web Start applica- - apps (applets or Java Web Start applica tions) tions) – can extract only those classes which are ac can extract only those classes which are ac- - tually required, using e.g. ProGuard – see tually required, using e.g. ProGuard – see http://lafros.com/maven/plugins/proguard http://lafros.com/maven/plugins/proguard Scala Days 2010 Lafros GUI-App 15/16

  16. Availability Availability ● Maven project on github Maven project on github ● GPL or purchase per-app exception GPL or purchase per-app exception ● see see http://lafros.com/gui http://lafros.com/gui for further details... for further details... Scala Days 2010 Lafros GUI-App 16/16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend