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
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 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

slide-2
SLIDE 2

Scala Days 2010 Lafros GUI-App 2/16

Contents Contents

  • 15 mins

15 mins Slides Slides

  • 10 mins

10 mins Demo Demo

  • 5 mins

5 mins Answers Answers

slide-3
SLIDE 3

Scala Days 2010 Lafros GUI-App 3/16

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

slide-4
SLIDE 4

Scala Days 2010 Lafros GUI-App 4/16

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

slide-5
SLIDE 5

Scala Days 2010 Lafros GUI-App 5/16

A framework depending A framework depending

  • n two sub-frameworks
  • n 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

slide-6
SLIDE 6

Scala Days 2010 Lafros GUI-App 6/16

Deploy same code as Deploy same code as application or applet application or applet

  • only need supply an init() method – default
  • nly 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

slide-7
SLIDE 7

Scala Days 2010 Lafros GUI-App 7/16

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

slide-8
SLIDE 8

Scala Days 2010 Lafros GUI-App 8/16

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

slide-9
SLIDE 9

Scala Days 2010 Lafros GUI-App 9/16

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

  • nly 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

slide-10
SLIDE 10

Scala Days 2010 Lafros GUI-App 10/16

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

slide-11
SLIDE 11

Scala Days 2010 Lafros GUI-App 11/16

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 "")

slide-12
SLIDE 12

Scala Days 2010 Lafros GUI-App 12/16

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

slide-13
SLIDE 13

Scala Days 2010 Lafros GUI-App 13/16

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

slide-14
SLIDE 14

Scala Days 2010 Lafros GUI-App 14/16

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

slide-15
SLIDE 15

Scala Days 2010 Lafros GUI-App 15/16

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

slide-16
SLIDE 16

Scala Days 2010 Lafros GUI-App 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...