try
{
adjustingToUserInput = true;
final KeyedComboBoxModel listModel = (KeyedComboBoxModel) list.getModel();
final ListSelectionModel selectionModel = list.getSelectionModel();
selectionModel.setValueIsAdjusting(true);
// Determine if this selection has added or removed items
final HashSet<Integer> newSelections = new HashSet<Integer>();
final int size = listModel.getSize();
for (int i = 0; i < size; i++)
{
if (selectionModel.isSelectedIndex(i))
{
newSelections.add(IntegerCache.getInteger(i));
}
}
// Turn on everything that was selected previously
Iterator it = selectionCache.iterator();
while (it.hasNext())
{
final Integer integer = (Integer) it.next();
final int index = integer.intValue();
selectionModel.addSelectionInterval(index, index);
}
// Add or remove the delta
if (newSelections.containsAll(selectionCache) == false)
{
it = newSelections.iterator();
while (it.hasNext())
{
final Integer nextInt = (Integer) it.next();
final int index = nextInt.intValue();
if (selectionCache.contains(nextInt))
{
selectionModel.removeSelectionInterval(index, index);
}
else
{
selectionModel.addSelectionInterval(index, index);
}
}
// Save selections for next time
selectionCache.clear();
for (int i = 0; i < size; i++)
{
if (selectionModel.isSelectedIndex(i))
{
selectionCache.add(IntegerCache.getInteger(i));
}
}
}
selectionModel.setValueIsAdjusting(false);
final int[] indices = list.getSelectedIndices();
final Object[] keys = new Object[indices.length];
for (int i = 0; i < keys.length; i++)
{