mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-25 14:10:20 +00:00
bulk changes
[ci skip]
This commit is contained in:
@@ -4,6 +4,9 @@ import javafx.collections.ListChangeListener;
|
||||
import javafx.collections.ObservableList;
|
||||
import org.cryptomator.common.settings.VaultSettings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This listener makes sure to reflect any changes to the vault list back to the settings.
|
||||
*/
|
||||
@@ -19,14 +22,11 @@ public class VaultListChangeListener implements ListChangeListener<Vault> {
|
||||
public void onChanged(Change<? extends Vault> c) {
|
||||
while(c.next()) {
|
||||
if (c.wasAdded()) {
|
||||
for (int i = c.getFrom(); i < c.getTo(); i++) {
|
||||
Vault v = c.getList().get(i);
|
||||
vaultSettingsList.add(i, v.getVaultSettings());
|
||||
}
|
||||
List<VaultSettings> addedSettings = c.getAddedSubList().stream().map(Vault::getVaultSettings).collect(Collectors.toList());
|
||||
vaultSettingsList.addAll(c.getFrom(), addedSettings);
|
||||
} else if (c.wasRemoved()) {
|
||||
for (Vault v : c.getRemoved()) {
|
||||
vaultSettingsList.remove(v.getVaultSettings());
|
||||
}
|
||||
List<VaultSettings> removedSettings = c.getRemoved().stream().map(Vault::getVaultSettings).collect(Collectors.toList());
|
||||
vaultSettingsList.removeAll(removedSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user