Ignore:
Timestamp:
2003-05-27T15:40:47+12:00 (21 years ago)
Author:
mdewsnip
Message:

Fixed tabbing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/XORToggleButtonGroup.java

    r4293 r4364  
    44/** Just like any other button group, this object encapsulates several checkbox listeners, but instead of recording which are selected, or indeed what buttons it has assigned to it, this group has but one purpose: to ensure that at least one check button is always selected. */
    55public class XORToggleButtonGroup
    6     implements ActionListener {
    7     /** true if we are to ignore any further change events we recieve. */
    8     private boolean ignore = false;
    9     /** The current number of checkboxes that are selected. Never < 1. */
    10     private int selected_count = 0;
     6    implements ActionListener {
     7    /** true if we are to ignore any further change events we recieve. */
     8    private boolean ignore = false;
     9    /** The current number of checkboxes that are selected. Never < 1. */
     10    private int selected_count = 0;
    1111
    12     private JToggleButton last_button;
     12    private JToggleButton last_button;
    1313
    14     /** Any implementation of ActionListener includes this method so that we can be informed when an action has occured on any registered checkboxes, allowing us to roll back the action if this is the only selected checkbox remaining.
     14    /** Any implementation of ActionListener includes this method so that we can be informed when an action has occured on any registered checkboxes, allowing us to roll back the action if this is the only selected checkbox remaining.
    1515      * @param event An <strong>ActionEvent</strong> containing information about the event.
    1616      */
    17     public void actionPerformed(ActionEvent event) {
    18           if(!ignore) {
    19                 ignore = true;
    20                 JToggleButton toggle_button = (JToggleButton) event.getSource();
    21                 if(toggle_button.isSelected()) {
    22                      selected_count++;
    23                 }
    24                 else {
    25                      if(selected_count > 1) {
    26                           selected_count--;
    27                      }
    28                      else {
    29                           toggle_button.setSelected(true);
    30                      }
    31                 }
    32                 ignore = false;
    33           }
    34     }
    35     public void add(JToggleButton toggle_button) {
    36           last_button = toggle_button;
    37           // If the checkbox is selected, increase our count.
    38           if(toggle_button.isSelected()) {
    39                 selected_count++;
    40           }
    41           toggle_button.addActionListener(this);
    42     }
     17    public void actionPerformed(ActionEvent event) {
     18    if(!ignore) {
     19        ignore = true;
     20        JToggleButton toggle_button = (JToggleButton) event.getSource();
     21        if(toggle_button.isSelected()) {
     22        selected_count++;
     23        }
     24        else {
     25        if(selected_count > 1) {
     26            selected_count--;
     27        }
     28        else {
     29            toggle_button.setSelected(true);
     30        }
     31        }
     32        ignore = false;
     33    }
     34    }
     35    public void add(JToggleButton toggle_button) {
     36    last_button = toggle_button;
     37    // If the checkbox is selected, increase our count.
     38    if(toggle_button.isSelected()) {
     39        selected_count++;
     40    }
     41    toggle_button.addActionListener(this);
     42    }
    4343
    44     /** Ensures that at least one option is selected. */
    45     public void establish() {
    46           if(selected_count == 0 && last_button != null) {
    47                 last_button.setSelected(true);
    48           }
    49     }
     44    /** Ensures that at least one option is selected. */
     45    public void establish() {
     46    if(selected_count == 0 && last_button != null) {
     47        last_button.setSelected(true);
     48    }
     49    }
    5050}
Note: See TracChangeset for help on using the changeset viewer.