Changes between Version 7 and Version 8 of Ticket #2394


Ignore:
Timestamp:
04/09/10 17:54:21 (15 years ago)
Author:
boyanl
Comment:
  • 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
  • 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

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #2394 – Description

    v7 v8  
    1  * Add a new class TriStateCheckBox extending JCheckBox with the following members: 
    2   * A {{{ public static enum State }}} representing the state of the checkbox 
    3   *  {{{ public void setState(State state) }}} - sets the new state of the checkbox 
    4   *  {{{ public State getState() }}} - gets the state of the checkbox 
    5   *  {{{ public void setSelected(boolean selected) }}} - overriding JCheckBox's method, setting the state according to the state model 
    6   *  {{{ public void paintComponent(Graphics g) }}}, which defines how to draw the checkbox (with an added code for drawing the new state) 
    7   * 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 
    8  
    9  * Add a new {{{ class CheckBoxTree extending JTree }}} with the following members: 
    10   * A {{{ public static class CheckNode extends DefaultMutableTreeNode }}} to represent the tree node, containing: 
    11    * a {{{ JTree backlink }}} to the containing tree, needed for the visual update of nodes when changing a state of a node 
    12    * a {{{ TriStateModel state }}}, representing the state of the node 
    13    * {{{ public State getState() }}} - returns the state of the node 
    14    * {{{ public void nextState() }}} - sets the node state to the "next" one, as defined in the state transition of the model 
    15    * {{{ public void setState (State newState) }}} - sets a new state of the node and propagates the changes to children/parent if necessary. Also updates the nodes visually using the backlink to the containing tree. 
    16   * A {{{ class CheckRenderer extends JPanel implements TreeCellRenderer }}} to visualize the tree nodes, it contains: 
    17    * A {{{ JLabel label }}} to hold the text of the node 
    18    * A {{{ TriStateCheckBox check }}} to hold the checkbox component 
    19    * {{{ public Dimension getPreferredSize() }}} - returns the preferred size, which is label_width + checkbox_width as width and max (check_height, label_height) as height 
    20    * {{{ public void doLayout() }}} - layouts both components. Sets the location and bounds of the checkbox and the label 
    21    * A {{{ class NodeSelectionListener extends MouseAdapter }}} with the following methods: 
    22     * {{{ 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) 
    23  
    24    * {{{ public CheckNode addNode (String nodeText) }}} - adds a new node attached to the tree root and returns the added node 
    25    * {{{ public CheckNode addNode (String nodeText, CheckNode parent) }}} - adds a new node with a specified parent 
    26    * {{{ public CheckNode getRootNode() }}} - returns the root of the tree 
    27    * {{{ public CheckBoxTree (String rootName) }}} - creates a tree with a specified root name 
    28  
    29  * Changes to the {{{ TemplateDialog }}} class 
    30   * Change the dialog to use a {{{CheckBoxTree instead of a {{{ BoundGroupCheckBox }}} as a tree 
    31   * Remove the {{{ JPanel checkBoxPanel }}} member and getter and replaced it with a {{{ JScrollPane treeScrollPane }}} scroll pane for the tree 
    32   * 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 cleaned up the creation of the tree (it uses {{{ addKey }}} now) 
    33   * Remove the addTemplateKey method and replaced it with a recursive {{{ addKey }}} 
     1Replace the existing template dialog with a collapsable tree. 
     2 * The tree should have three state checkboxes  
     3  * Selected state 
     4  * Not selected state 
     5  * Gray-out state (some of the children are selected) 
     6 * 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) 
     7 * Selecting/deselecting a parent selects/deselects all of its children 
     8 * The root and the first level should be seen on opening of the dialog 
     9 * Opened nodes and states of the nodes should be selectable by developers