Analysis
Overview
In order to improve usability of the templates, introduce a dialog that appears when user adds an object as a template. There the user should select which of the options will be templated.
Task requirements
- Create a dialog that pops up when the "Add to template" halo is clicked. The dialog should contain
- Text field for the name of the template; By default this name should be the same as the element name
- "Select all" and "Select none" buttons for the list of the checkboxes
- List of all objects and properties of the object with identation and checkboxes that allow to choose which of these will be added to the template
- By default, all of the checkboxes will be checked
- For pages - list of frames, groups
- For frames - properties
- List items should be indented as there are no tree views in the application. See implementation idea
- Optional - a preview box will be useful, but probably will take time
- "Add" and "Cancel" buttons at the bottom of the dialog
- The dialog should display scrollbars where needed
Only the properties that are with checked checkboxes will be applied when applying the template to an existing object.
Task result
Code
Implementation idea
Example1: A page with 3 frames (Frame A, Frame B, Frame C). The list in the Dialog should look the following way 3 spaces for identation, none and all checkboxes. The checkboxes should be 3 state checkboxes:
Also, where a checkbox refers to a collection of objects, a greyed-out checkbox indicates that some objects in the collection test as true (checked) while others test false (empty).
Page A [ ] Frame A [ ] Properties [ ] Size [ ] Position [ ] Orientation [ ] Margins [ ] Padding [ ] Appearence [ ] Border style [ ] Background style [ ] Content [ ] Group A [ ] Properties [ ] Position [ ] Frame B [ ] Properties [ ] Size [ ] Position [ ] Orientation [ ] Margins [ ] Padding [ ] Appearence [ ] Border style [ ] Background style [ ] Content [ ] Frame C [ ] Properties [ ] Size [ ] Position [ ] Orientation [ ] Margins [ ] Padding [ ] Appearence [ ] Border style [ ] Background style [ ] Content [ ]
Example2: A frame that is added as a template
Frame C [ ] Properties [ ] Size [ ] Position [ ] Orientation [ ] Margins [ ] Padding [ ] Appearence [ ] Border style [ ] Background style [ ] Content [ ]
Related
GROUP_TEMPLATES_R2
GROUP_TEMPLATES_R1
How to demo
Select a frame, add only it's border style as a template and apply it to another frame with other content.
Design
Dialog and HALO
- An AddTemplate Dialog should be introduced. It should contain the controls from the wireframe in the analysis.
- The old AddTemplateHaloButton should invoke the dialog.
- The dialog should contain a list of TemplatedKeys. If the dialog is displayed when a single frame is selected, the list should contain the templated keys of the frame, otherwise - the templated keys of the current page.
- The list of TemplatedKeys can be obtained with the following code. Maybe, ResourceH is a good place for such a method:
Class<? extends ResourceR4> resClass = ResourceR4.getClassByKind(ResourceR4.KEY_KIND.get(access)); List<TemplatedKey<?>> tempKeys = ResourceR4.getKnownTemplatedKeys(resClass);
- The dialog should contain a BaseSwingVisualElement which will contain the list of checkboxes. It will depend on the list of TemplatedKeys.
BoundCheckBox
- We need a specific type of BoundCheckBox which somewhat contains other sub checkboxes.
- Extend the BoundCheckBox class:
- It should contain a list property of BoundCheckBox, called subControls.
- Its state should be auto-computed based on the state of the sub controls. If all checkboxes are checked, the main one is checked. If all are unchecked, the main one is unchecked. Otherwise it is grayed out, indicating a mix of the states of the sub controls.
Dialog logic
- The Add buttons will do the following (let's say that a frame is selected):
- Create a new resource of a frame kind.
- Iterate over the checkboxes of the dialog and if NOT set, set the appropriate raw value of the key to the default one. This will be the indicator that this templated key is not going to be applied. By default, all raw values of the keys are null.
- Set the selected frame as a template of the newly created one. By iterating over all the TemplatedKeys, check the raw values of the template. If the value is null, then set the raw value of the key to null and remove the lock (if any). This will ensure that the mode is set to USE TEMPLATE.
- Add the new frame to the frameTemplates list of the current book.
- The same applies if a page is selected.
- The Cancel button closes the dialog.
- The Select all/none buttons iterate over the checkboxes and set the appropriate state.
Tests & demos
Implementation
Testing
(Place the testing results here.)
Comments
- This task is not related with book templates as they should not be applied to existing books.
- Templating the sub elements of a page still creates a lot of problems, which i am unable to fix for now. Maybe we can make that key normal (not templated) and "manually" add the frames from the template on applying?
Attachments
- templatedialog.png (41.2 KB) - added by deyan 16 years ago.