Analysis
Overview
Part of GROUP_GUI_REDESIGN_R0 connected with bound controls. The goal of the task is to introduce LogicR3 to all bound controls and to improve their behavior.
Task requirements
- All bound controls should use LogicR3 and EventR3.
- There is a bug with bound combobox - it submits twice on change. Fix it.
- Provide opportunity for setting a custom layout to the bound controls.
Task result
- The result should be source code.
Implementation idea
- Fire an event on every change registered from the swing GUI listeners.
- Examine the reason for the bugs and prevent them.
- Provide opportunity for setting a custom layout to the bound controls by either creating an enum with fixed number of layouts or provide method for changing the layout.
Related
How to demo
- Run BoundControlsDemo class in order to see the new layouts.
- Examine the source code and explain the changes connected with LogicR3 and bound combobox bug.
Design
- All bound controls should use LogicR3 and EventR3:
- Create enums that implements OperationDef for each bound control and provide two members in each of them - PROCEED_VALIDATION and PROCEED_SUBMIT. The first one provides logic for validating the raw input from the GUI listeners and fires an event for submit, when the validation is successful. The second one provides logic for setting the model. If validation for some group of bound controls is not necessary, the first member should be ommited. The validation for all controls of the group should be handled at one place as its logic is common for the whole group (BoundCheckBox, BoundSlider).
- Create enums in BaseBoundControl that provides the event ids. Two are needed:
- VALIDATE - indicating that there is an input for validation, it must be fired from the GUI listeners in the bound control.
- SUBMIT - indicating that an input should be submitted in the model.
- There is a bug with bound combobox - it submits twice on change:
- It submits twice through the itemStateChanged() method - once on deselecting the previous item and once on selecting the new one. Add a check and make it to submit only for selecting.
- Provide opportunity for setting a custom layout to the bound controls:
- Create an enum LayoutMode containg four members for setting four different types of layout - FLOW, ROW, COLUMN, SQUARE.
- The FLOW type will be the type used so far.
- The ROW type will display the components in a row one next to each other.
- The COLUMN type will display the components vertically one under another.
- The SQUARE type will put the label on the first line and the control and the icon on the second line under the label, forming a square.
- Make a property layoutType() for the layout type, it should be of type LayoutMode. Its default value should be FLOW as the flow type of layout is the one used so far.
- Create private methods layoutRow(JPanel), layoutColumn(JPanel), layoutSquare(JPanel) and layoutFlow(JPanel) and call the appropriate one in the setup() method to lay out the components according to the layoutType() property.
- Use BoundControlsDemo class to show the new layouts, BoundComboBoxTest to check the bug with the combo box and BoundTextFieldTest to check the LogicR3 proper behavior.
Implementation
Implementation in:
svn://sophie2.org/sophie2/branches/private/velizar/bound
Change sets [4955], [4999], [5003], [5004]
All bound controls extending BaseBoundControl should call BaseBoundControl.settingModelFinished at the end of their submit handler to avoid locking the control.
A swallow events property has been added to BaseBoundControl that will ignore subsequent events with the same source and parameter. Class deriving from BaseBoundControl can override this to provide custom behaviour.
Class extending BaseBoundControl should call BaseBoundControl.fireValidate instead of firing the VALIDATE event themselves and call BaseBoundControl.fireSubmit from their validation handler.
Change sets [5029], [5038], [5046]
Fixed problem with reader - logic for zoom was loaded only in author mode - [5349].
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)