void () { ArrayList<MapInfo> mappings = new ArrayList<>(myModel.getItems()); int index = myDirectoryMappingTable.getSelectionModel().getMinSelectionIndex(); Collection<MapInfo> selection = myDirectoryMappingTable.getSelection(); mappings.removeAll(selection); Collection<MapInfo> removedValidRoots = ContainerUtil.mapNotNull(selection, info -> { return info.type == MapInfo.Type.NORMAL && myCheckers.get(info.mapping.getVcs()) != null ? MapInfo.unregistered(info.mapping) : null; }); mappings.addAll(removedValidRoots); sortAndAddSeparatorIfNeeded(mappings); myModel.setItems(mappings); if (mappings.size() > 0) { if (index >= mappings.size()) { index = mappings.size() - 1; } myDirectoryMappingTable.getSelectionModel().setSelectionInterval(index, index); } }