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/ExclusiveListSelectionListener.java

    r4293 r4364  
    5858 */
    5959public class ExclusiveListSelectionListener
    60     implements ListSelectionListener {
    61     /** A flag set to show that we are already dealing with a list selection change, and to ignore further ones until the flag becomes unset again. */
    62     private boolean ignore = false;
    63     /** An array of JList components, containing each JList thats registered with this listener. */
    64     private JList lists[] = null;
    65     /** Method to register a new JList with this listener.
    66       * @param list The new <strong>JList</strong> to register.
     60    implements ListSelectionListener {
     61    /** A flag set to show that we are already dealing with a list selection change, and to ignore further ones until the flag becomes unset again. */
     62    private boolean ignore = false;
     63    /** An array of JList components, containing each JList thats registered with this listener. */
     64    private JList lists[] = null;
     65    /** Method to register a new JList with this listener.
     66     * @param list The new <strong>JList</strong> to register.
    6767      */
    68     public void add(JList list) {
    69           list.addListSelectionListener(this);
    70           if(lists == null) {
    71                 lists = new JList[1];
    72                 lists[0] = list;
    73           }
    74           else {
    75                 JList temp[] = new JList[lists.length + 1];
    76                 System.arraycopy(lists, 0, temp, 0, lists.length);
    77                 temp[lists.length] = list;
    78                 lists = temp;
    79           }
    80     }
    81     /** Any implementation of ListSelectionListener must include this method so we can be informed when the selection changes. In this case we want to clear the selections of all other registered JLists other than the caller.
     68    public void add(JList list) {
     69    list.addListSelectionListener(this);
     70    if(lists == null) {
     71        lists = new JList[1];
     72        lists[0] = list;
     73    }
     74    else {
     75        JList temp[] = new JList[lists.length + 1];
     76        System.arraycopy(lists, 0, temp, 0, lists.length);
     77        temp[lists.length] = list;
     78        lists = temp;
     79    }
     80    }
     81    /** Any implementation of ListSelectionListener must include this method so we can be informed when the selection changes. In this case we want to clear the selections of all other registered JLists other than the caller.
    8282      * @param event A <strong>ListSelectionEvent</strong> containing informaiton about the event.
    8383      */
    84     public void valueChanged(ListSelectionEvent event) {
    85           if(!ignore) {
    86                 ignore = true;
    87                 JList source = (JList)event.getSource();
    88                 for(int i = 0; i < lists.length; i++) {
    89                      if(lists[i] != source) {
    90                           lists[i].clearSelection();
    91                      }
    92                 }
    93                 ignore = false;
    94           }
    95     }
     84    public void valueChanged(ListSelectionEvent event) {
     85    if(!ignore) {
     86        ignore = true;
     87        JList source = (JList)event.getSource();
     88        for(int i = 0; i < lists.length; i++) {
     89        if(lists[i] != source) {
     90            lists[i].clearSelection();
     91        }
     92        }
     93        ignore = false;
     94    }
     95    }
    9696}
Note: See TracChangeset for help on using the changeset viewer.