Esempio n. 1
0
    protected void toggleSelection(int index) {
      if (!_list.isEnabled() || !_list.isCheckBoxEnabled(index)) {
        return;
      }

      CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel();
      boolean selected = selectionModel.isSelectedIndex(index);
      selectionModel.removeListSelectionListener(this);
      try {
        if (selected) selectionModel.removeSelectionInterval(index, index);
        else selectionModel.addSelectionInterval(index, index);
      } finally {
        selectionModel.addListSelectionListener(this);
        _list.repaint();
      }
    }