mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
preserve order of cell selection in border wallets grid
This commit is contained in:
parent
04145bde74
commit
1a46f8a643
1 changed files with 12 additions and 1 deletions
|
@ -40,6 +40,8 @@ public class MnemonicGridDialog extends Dialog<List<String>> {
|
||||||
private final BooleanProperty initializedProperty = new SimpleBooleanProperty(false);
|
private final BooleanProperty initializedProperty = new SimpleBooleanProperty(false);
|
||||||
private final BooleanProperty wordsSelectedProperty = new SimpleBooleanProperty(false);
|
private final BooleanProperty wordsSelectedProperty = new SimpleBooleanProperty(false);
|
||||||
|
|
||||||
|
private final List<TablePosition> selectedCells = new ArrayList<>();
|
||||||
|
|
||||||
public MnemonicGridDialog() {
|
public MnemonicGridDialog() {
|
||||||
DialogPane dialogPane = new MnemonicGridDialogPane();
|
DialogPane dialogPane = new MnemonicGridDialogPane();
|
||||||
setDialogPane(dialogPane);
|
setDialogPane(dialogPane);
|
||||||
|
@ -71,6 +73,15 @@ public class MnemonicGridDialog extends Dialog<List<String>> {
|
||||||
spreadsheetView.getSelectionModel().getSelectedCells().addListener(new ListChangeListener<>() {
|
spreadsheetView.getSelectionModel().getSelectedCells().addListener(new ListChangeListener<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(Change<? extends TablePosition> c) {
|
public void onChanged(Change<? extends TablePosition> c) {
|
||||||
|
while(c.next()) {
|
||||||
|
if(c.wasRemoved()) {
|
||||||
|
selectedCells.removeAll(c.getRemoved());
|
||||||
|
}
|
||||||
|
if(c.wasAdded()) {
|
||||||
|
selectedCells.addAll(c.getAddedSubList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int numWords = c.getList().size();
|
int numWords = c.getList().size();
|
||||||
wordsSelectedProperty.set(numWords == 11 || numWords == 23);
|
wordsSelectedProperty.set(numWords == 11 || numWords == 23);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +148,7 @@ public class MnemonicGridDialog extends Dialog<List<String>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getSelectedWords() {
|
private List<String> getSelectedWords() {
|
||||||
List<String> abbreviations = spreadsheetView.getSelectionModel().getSelectedCells().stream()
|
List<String> abbreviations = selectedCells.stream()
|
||||||
.map(position -> (String)spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn()).getItem()).collect(Collectors.toList());
|
.map(position -> (String)spreadsheetView.getGrid().getRows().get(position.getRow()).get(position.getColumn()).getItem()).collect(Collectors.toList());
|
||||||
|
|
||||||
List<String> words = new ArrayList<>();
|
List<String> words = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in a new issue