@Override
  public void update() {

    boolean reloadSelection = false;

    listMultipleSelection = getMultipleSelection();

    // If the list of elements has changed, remove old elements and add new ones
    if (!Arrays.equals(listModel.toArray(), listMultipleSelection.getPossibleValues().toArray())) {
      listModel.removeAllElements();
      reloadSelection = true;
      for (T value : listMultipleSelection.getPossibleValues()) listModel.addElement(value);
    } else {
      // if the list is the same but the selection has changed, remove all selections and select new
      // ones
      if (!Arrays.equals(
          itemsContainerList.getSelectedValues(),
          listMultipleSelection.getSelectedValues().toArray())) reloadSelection = true;
    }
    if (reloadSelection) {
      // selected items
      final List<T> selectedVals = listMultipleSelection.getSelectedValues();
      final List<T> allValues = listMultipleSelection.getPossibleValues();

      final int[] selectedIdx = new int[selectedVals.size()];
      int index = 0;
      for (T selected : selectedVals) {
        for (int i = 0; i < allValues.size(); i++) {
          if (itemsContainerList.getModel().getElementAt(i).equals(selected)) {
            selectedIdx[index] = i;
            index++;
          }
        }
      }
      itemsContainerList.removeSelectionInterval(0, allValues.size() - 1);
      itemsContainerList.setSelectedIndices(selectedIdx);
    }
  }
Пример #2
0
 public void removeSelectionInterval(int index0, int index1) {
   super.removeSelectionInterval(index0, index1);
   int anchor = getAnchorSelectionIndex();
   int lead = getLeadSelectionIndex();
   table.setSelectedRows(Math.min(anchor, lead), Math.max(anchor, lead));
 }
Пример #3
0
 public void unhiliteInactiveParticipant(String cname) {
   int i = plistModel.indexOf(cname);
   plist.removeSelectionInterval(i, i);
 }
Пример #4
0
 private void removeSelection() {
   int curSelectedIndex = irLines.getSelectedIndex();
   irLines.removeSelectionInterval(curSelectedIndex, curSelectedIndex);
 }