Skip to content

RulesEditorBoxDesign

Trac2Gollum edited this page Jun 20, 2013 · 3 revisions

Design for a Rules Editor Box

Scope

Four different rule set properties have been identified for use with BOY widgets:

  • Visibility Rules
  • Color Rules
  • Enable Rules
  • Linked Container Rules

I think effort can be minimized and BOY usability maximized by creating a generic rules editor box that can be used for all these cases.

Graphical Appearance

From a user perspective, I would like to see such a box like this: Right hand side: Input PVs selector.(XXX macro: "BR") Similar to the right hand side of the "Attach Scripts" box. Each PV gets assigned an uppercase letter. Left hand side: Rules selector.(XXX macro: "BR") Top: "Default Value: " <value_selector>(XXX macro: "BR") Then a table similar to the right hand side (with "Add", "Remove", "Up", "Down" buttons).(XXX macro: "BR") Left column: "Expression" (text field), right column "Value" (<value_selector>).(XXX macro: "BR") Each expression is a Java expression, the uppercase letters of the PVs can be used as variables. The value will be used if the expression is true. Bottom: Save/Load/Edit'' - ''OK/Cancel(XXX macro: "BR") Save/Load/Edit buttons to enable file based rules.(XXX macro: "BR") "Save" saves to a file, then makes the tables read/only (greyed out). In this state the rules file will be used for this widget.(XXX macro: "BR") "Edit" removes the link to the rules file (thus making the rules local), and activates the rules tables for editing.(XXX macro: "BR") "Load" reads in a rules file, leaving the tables read/only.(XXX macro: "BR") OK/Cancel are obvious. <value_selector>:(XXX macro: "BR") Whatever is necessary to select a value for the property.(XXX macro: "BR") Color: Color field with a button to open the color picker.(XXX macro: "BR") Visibility, Enable: Check box.(XXX macro: "BR") Linked Container opi selection: File name plus browse button that opens a file picker.

Runtime Behavior

The lines are evaluated in order, the first match gets executed and the value configured with it is set.(XXX macro: "BR") (So that the table works like a large if'' - ''else if'' - ''else if - ... block.)

Implementation Idea

The rules are stored within the panel (for local rules) or in the rules file as data (XML).

When the panel is opened, the rules data is used to create a Javascript on-the-fly. The script is attached to the widget and executed using the existing methods.

Advantages:

  • Development-safe: Javascript always matches widget code, as it is generated by the widget on-the-fly
  • Named (site-wide) rules files are possible, but not mandatory
  • Easy conversion from existing medm/dm2k/edm panels' visibility, enable and color rules

Clone this wiki locally