Ticket #2394 (closed tweak: obsolete)
template-dialog-tree -- Create a tree inside template dialog
Reported by: | deyan | Owned by: | boyanl |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | uncategorized | Version: | 2.0 |
Keywords: | Cc: | ||
Category: | unknown | Effort: | |
Importance: | Ticket_group: | ||
Estimated Number of Hours: | 0 | Add Hours to Ticket: | 0 |
Billable?: | yes | Total Hours: | 0 |
Analysis_owners: | deyan | Design_owners: | boyanl |
Imp._owners: | boyanl | Test_owners: | |
Analysis_reviewers: | todor | Changelog: | Changelog |
Design_reviewers: | meddle | Imp._reviewers: | meddle, meddle, todor |
Test_reviewers: | Analysis_score: | 3.5 | |
Design_score: | 4 | Imp._score: | 0 |
Test_score: | 3.5 |
Description (last modified by boyanl) (diff)
Replace the existing template dialog with a collapsable tree.
- The tree should have three state checkboxes
- Selected state
- Not selected state
- Gray-out state (some of the children are selected)
- Selecting a child of empty parent should make the parent grayed out (if there are other unselected checkboxes) or selected (if all of the children are selected)
- Selecting/deselecting a parent selects/deselects all of its children
- The root and the first level should be seen on opening of the dialog
- Opened nodes and states of the nodes should be selectable by developers
Attachments
Change History
comment:1 Changed 15 years ago by deyan
- Owner set to deyan
- Status changed from new to s1a_analysis_started
- Description modified (diff)
comment:2 Changed 15 years ago by deyan
- Status changed from s1a_analysis_started to s1b_analysis_finished
- Description modified (diff)
comment:3 Changed 15 years ago by todor
- Status changed from s1b_analysis_finished to s1c_analysis_ok
- Analysis_score changed from 0 to 3.5
the requirements are sufficient
comment:5 Changed 15 years ago by boyanl
- Owner changed from deyan to boyanl
- Status changed from s1c_analysis_ok to s2a_design_started
comment:7 Changed 15 years ago by boyanl
- Status changed from s2a_design_started to s2b_design_finished
- Description modified (diff)
- Add a new class TriStateCheckBox extending JCheckBox with the following members:
- A public static enum State representing the state of the checkbox
- public void setSelected(boolean selected) - overriding JCheckBox's method, setting the state according to the state model
- public void paintComponent(Graphics g) , which defines how to draw the checkbox (with an added code for drawing the new state)
- an inner public static class TriStateModel extending JToggleButton.ToggleButtonModel , which holds a State variable and defines when the checkbox will be "selected" and the state transition
- Add a new class CheckBoxTree extending JTree with the following members:
- A public static class CheckNode extends DefaultMutableTreeNode to represent the tree node, containing:
- a TriStateModel state , representing the state of the node
- public State getState() - returns the state of the node
- public void nextState() - sets the node state to the "next" one, as defined in the state transition of the model
- public void setState (State newState) - sets a new state of the node and propagates the changes to children/parent if necessary.
- A class CheckRenderer extends JPanel implements TreeCellRenderer to visualize the tree nodes, it contains:
- A JLabel label to hold the text of the node
- A TriStateCheckBox check to hold the checkbox component
- public void doLayout() - layouts both components. Sets the location and bounds of the checkbox and the label
- A class NodeSelectionListener extends MouseAdapter with the following methods:
- public void mouseClicked (MouseEvent e) - handles the mouse input over the tree. If some row of the tree is clicked, it alters the state of the CheckNode for that row (sets it to the "next" state)
- public CheckNode addNode (String nodeText) - adds a new node attached to the tree root and returns the added node
- public CheckNode addNode (String nodeText, CheckNode parent) - adds a new node with a specified parent
- public CheckNode getRootNode() - returns the root of the tree
- public CheckBoxTree (String rootName) - creates a tree with a specified root name
- A public static class CheckNode extends DefaultMutableTreeNode to represent the tree node, containing:
- Changes to the TemplateDialog class
- Change the dialog to use a CheckBoxTree instead of a BoundGroupCheckBox as a tree
- Remove the JPanel checkBoxPanel member and getter and replace it with a JScrollPane treeScrollPane scroll pane for the tree
- Modify the setup() method to create a new tree with a root name the title from the input info, and sets the tree to the treeScrollPane , and clean up the creation of the tree (it uses addKey now)
- Remove the addTemplateKey method and replace it with a recursive addKey
comment:8 Changed 15 years ago by boyanl
- Description modified (diff)
- Add a new class TriStateCheckBox extending JCheckBox with the following members:
- A public static enum State representing the state of the checkbox
- public void setSelected(boolean selected) - overriding JCheckBox's method, setting the state according to the state model
- public void paintComponent(Graphics g) , which defines how to draw the checkbox (with an added code for drawing the new state)
- an inner public static class TriStateModel extending JToggleButton.ToggleButtonModel , which holds a State variable and defines when the checkbox will be "selected" and the state transition
- Add a new class CheckBoxTree extending JTree with the following members:
- A public static class CheckNode extends DefaultMutableTreeNode to represent the tree node, containing:
- a TriStateModel state , representing the state of the node
- public State getState() - returns the state of the node
- public void nextState() - sets the node state to the "next" one, as defined in the state transition of the model
- public void setState (State newState) - sets a new state of the node and propagates the changes to children/parent if necessary.
- A class CheckRenderer extends JPanel implements TreeCellRenderer to visualize the tree nodes, it contains:
- A JLabel label to hold the text of the node
- A TriStateCheckBox check to hold the checkbox component
- public void doLayout() - layouts both components. Sets the location and bounds of the checkbox and the label
- A class NodeSelectionListener extends MouseAdapter with the following methods:
- public void mouseClicked (MouseEvent e) - handles the mouse input over the tree. If some row of the tree is clicked, it alters the state of the CheckNode for that row (sets it to the "next" state)
- public CheckNode addNode (String nodeText) - adds a new node attached to the tree root and returns the added node
- public CheckNode addNode (String nodeText, CheckNode parent) - adds a new node with a specified parent
- public CheckNode getRootNode() - returns the root of the tree
- public CheckBoxTree (String rootName) - creates a tree with a specified root name
- A public static class CheckNode extends DefaultMutableTreeNode to represent the tree node, containing:
- Changes to the TemplateDialog class
- Change the dialog to use a CheckBoxTree instead of a BoundGroupCheckBox as a tree
- Remove the JPanel checkBoxPanel member and getter and replace it with a JScrollPane treeScrollPane scroll pane for the tree
- Modify the setup() method to create a new tree with a root name the title from the input info, and sets the tree to the treeScrollPane , and clean up the creation of the tree (it uses addKey now)
- Remove the addTemplateKey method and replace it with a recursive addKey
comment:9 Changed 15 years ago by meddle
- Status changed from s2b_design_finished to s2c_design_ok
- Design_score changed from 0 to 4
- Design_reviewers set to meddle
- So for a first task here you did pretty well writing this design.
- I have some comments for the code:
- First don't use Bulgarian words in Latin alphabet when you name your classes, for example TriStateCheckBox, and the rest beginning with 'Tri', rename that.
- See this page GoodCodeExamples, there are some simple rules for:
- Writing JavaDoc (fix your malformed ones), but as a whole I like your style.
- Identation
- Spacing
- Use tab wide four spaces (fix your eclipse for that)
- I suggest you look at our BoundControl API, Pap will make you update this classes to extend our controls soon.
- Why you paint the PARTIAL state in blue, in the analysis it is grey.
- You should write code based on tests (Test-driven programming), that is advise, I couldn't make anyone in the office write good tests, but think yours will be good. For view related implementations I use Demos, starting Sophie 2 author/reader for testing takes too much time.
- Good design :)
4p
comment:10 Changed 15 years ago by boyanl
Most of the points are taken (or are things I have to do :) ), but I thought I would address some:
- About the naming, I know it sounds like mixing Bulgarian + English, but that's what I actually encountered while searching for this control: http://en.wikipedia.org/wiki/Tri-state_check_box, so I left it that way.
- About the painting, the blue square was a "placeholder" for what should be drawn in the checkbox. I could draw some icon in there, but I need it as an image (I should have put a comment in the code probably).
- Thanks :)
comment:11 Changed 15 years ago by boyanl
- Status changed from s2c_design_ok to s3a_implementation_started
comment:12 Changed 15 years ago by boyanl
- Status changed from s3a_implementation_started to s3b_implementation_finished
Finished the code cleanup and added the icon, source is in [9004]
comment:13 Changed 15 years ago by meddle
- Status changed from s3b_implementation_finished to s2c_design_ok
- Test_score changed from 0 to 2
- Imp._reviewers set to meddle
- Your task breaks many things.
- All of the import resource dialogs don't show.
- Your dialog don't show with when Sophie is run with True.
- You can not exit Sophie normally.
- Don't put in one file more than one class on top level...
- Ident your code (Ctrl+A and then Ctrl+I)
- Call me to try to fix the dialog problem if you want.
comment:14 Changed 15 years ago by boyanl
- Status changed from s2c_design_ok to s3a_implementation_started
comment:15 Changed 15 years ago by boyanl
- Status changed from s3a_implementation_started to s3b_implementation_finished
Fixed, the changes are in [9023]
comment:16 Changed 15 years ago by meddle
- Status changed from s3b_implementation_finished to s3c_implementation_ok
- Test_score changed from 2 to 3.5
- Imp._reviewers changed from meddle to meddle, meddle, todor
Merged into the trunk at [9027]
- You should name constants with upper case letters (I'm talking about the icon in the Tristate check-box).
- You should use the ImmImage.draw method and not export it to buffered image.
- Write JavaDoc, commenting not only the setter/getter parameters, but and the overview part.
- You better write setIcon methods instead putting the icons in constants, that way the icons of the extenders will be able to be set through the skin.
- Add yourself like an author of the classes that you change.
3.5p
comment:17 Changed 13 years ago by meddle
- Status changed from s3c_implementation_ok to closed
- Resolution set to obsolete
Closing all the tickets before M Y1
Note: See
TracTickets for help on using
tickets.