Esempio n. 1
0
 protected void toggleSelections() {
   int[] indices = _list.getSelectedIndices();
   CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel();
   selectionModel.removeListSelectionListener(this);
   selectionModel.setValueIsAdjusting(true);
   try {
     if (indices.length > 0) {
       boolean selected = selectionModel.isSelectedIndex(indices[0]);
       for (int index : indices) {
         if (!_list.isCheckBoxEnabled(index)) {
           continue;
         }
         if (selected && selectionModel.isSelectedIndex(index)) {
           selectionModel.removeSelectionInterval(index, index);
         } else if (!selected && !selectionModel.isSelectedIndex(index)) {
           selectionModel.addSelectionInterval(index, index);
         }
       }
     }
   } finally {
     selectionModel.setValueIsAdjusting(false);
     selectionModel.addListSelectionListener(this);
     _list.repaint();
   }
 }