diff --git a/CHANGELOG.md b/CHANGELOG.md index 89df55d3d63..842a8255648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed the paste entry command in the menu and toolbar, that did not do anything. [#6293](https://github.com/JabRef/jabref/issues/6293) - We fixed an issue where the windows installer did not create an entry in the start menu [bug report in the forum](https://discourse.jabref.org/t/error-while-fetching-from-doi/2018/3) - We fixed an issue where JabRef switched to discrete graphics under macOS [#5935](https://github.com/JabRef/jabref/issues/5935) +- We fixed an issue where the Preferences entry preview will be unexpected modified leads to Value too long exception [#6198](https://github.com/JabRef/jabref/issues/6198) ### Removed diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java index 8d387006ce7..67fcada9c73 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewTabView.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewTabView.java @@ -211,7 +211,7 @@ private void dragDetectedInAvailable(MouseEvent event) { List selectedLayouts = new ArrayList<>(viewModel.availableSelectionModelProperty().getValue().getSelectedItems()); if (!selectedLayouts.isEmpty()) { Dragboard dragboard = startDragAndDrop(TransferMode.MOVE); - viewModel.dragDetected(viewModel.availableListProperty(), selectedLayouts, dragboard); + viewModel.dragDetected(viewModel.availableListProperty(), viewModel.availableSelectionModelProperty(), selectedLayouts, dragboard); } event.consume(); } @@ -220,7 +220,7 @@ private void dragDetectedInChosen(MouseEvent event) { List selectedLayouts = new ArrayList<>(viewModel.chosenSelectionModelProperty().getValue().getSelectedItems()); if (!selectedLayouts.isEmpty()) { Dragboard dragboard = startDragAndDrop(TransferMode.MOVE); - viewModel.dragDetected(viewModel.chosenListProperty(), selectedLayouts, dragboard); + viewModel.dragDetected(viewModel.chosenListProperty(), viewModel.chosenSelectionModelProperty(), selectedLayouts, dragboard); } event.consume(); } diff --git a/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java b/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java index 5d5a841047a..d749fb09dfd 100644 --- a/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java @@ -68,6 +68,7 @@ public class PreviewTabViewModel implements PreferenceTabViewModel { private final CustomLocalDragboard localDragboard; private Validator chosenListValidator; private ListProperty dragSourceList = null; + private ObjectProperty> dragSourceSelectionModel = null; public PreviewTabViewModel(DialogService dialogService, JabRefPreferences preferences, TaskExecutor taskExecutor, StateManager stateManager) { this.dialogService = dialogService; @@ -231,12 +232,14 @@ public boolean validateSettings() { public void addToChosen() { List selected = new ArrayList<>(availableSelectionModelProperty.getValue().getSelectedItems()); + availableSelectionModelProperty.getValue().clearSelection(); availableListProperty.removeAll(selected); chosenListProperty.addAll(selected); } public void removeFromChosen() { List selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedItems()); + chosenSelectionModelProperty.getValue().clearSelection(); chosenListProperty.removeAll(selected); availableListProperty.addAll(selected); availableListProperty.sort((a, b) -> a.getName().compareToIgnoreCase(b.getName())); @@ -249,6 +252,7 @@ public void selectedInChosenUp() { List selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedIndices()); List newIndices = new ArrayList<>(); + chosenSelectionModelProperty.getValue().clearSelection(); for (int oldIndex : selected) { boolean alreadyTaken = newIndices.contains(oldIndex - 1); @@ -257,7 +261,6 @@ public void selectedInChosenUp() { newIndices.add(newIndex); } - chosenSelectionModelProperty.getValue().clearSelection(); newIndices.forEach(index -> chosenSelectionModelProperty.getValue().select(index)); chosenSelectionModelProperty.getValue().select(newIndices.get(0)); refreshPreview(); @@ -270,6 +273,7 @@ public void selectedInChosenDown() { List selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedIndices()); List newIndices = new ArrayList<>(); + chosenSelectionModelProperty.getValue().clearSelection(); for (int i = selected.size() - 1; i >= 0; i--) { int oldIndex = selected.get(i); @@ -279,7 +283,6 @@ public void selectedInChosenDown() { newIndices.add(newIndex); } - chosenSelectionModelProperty.getValue().clearSelection(); newIndices.forEach(index -> chosenSelectionModelProperty.getValue().select(index)); chosenSelectionModelProperty.getValue().select(newIndices.get(0)); refreshPreview(); @@ -365,12 +368,13 @@ public void dragOver(DragEvent event) { } } - public void dragDetected(ListProperty sourceList, List selectedLayouts, Dragboard dragboard) { + public void dragDetected(ListProperty sourceList, ObjectProperty> sourceSelectionModel, List selectedLayouts, Dragboard dragboard) { ClipboardContent content = new ClipboardContent(); content.put(DragAndDropDataFormats.PREVIEWLAYOUTS, ""); dragboard.setContent(content); localDragboard.putPreviewLayouts(selectedLayouts); dragSourceList = sourceList; + dragSourceSelectionModel = sourceSelectionModel; } /** @@ -386,6 +390,7 @@ public boolean dragDropped(ListProperty targetList, Dragboard dra if (dragboard.hasContent(DragAndDropDataFormats.PREVIEWLAYOUTS)) { List draggedLayouts = localDragboard.getPreviewLayouts(); if (!draggedLayouts.isEmpty()) { + dragSourceSelectionModel.getValue().clearSelection(); dragSourceList.getValue().removeAll(draggedLayouts); targetList.getValue().addAll(draggedLayouts); success = true; @@ -412,7 +417,7 @@ public boolean dragDroppedInChosenCell(PreviewLayout targetLayout, Dragboard dra if (dragboard.hasContent(DragAndDropDataFormats.PREVIEWLAYOUTS)) { List draggedSelectedLayouts = new ArrayList<>(localDragboard.getPreviewLayouts()); if (!draggedSelectedLayouts.isEmpty()) { - + chosenSelectionModelProperty.getValue().clearSelection(); int targetId = chosenListProperty.getValue().indexOf(targetLayout); // see https://stackoverflow.com/questions/28603224/sort-tableview-with-drag-and-drop-rows @@ -427,7 +432,7 @@ public boolean dragDroppedInChosenCell(PreviewLayout targetLayout, Dragboard dra } targetLayout = chosenListProperty.getValue().get(targetId); } - + dragSourceSelectionModel.getValue().clearSelection(); dragSourceList.getValue().removeAll(draggedSelectedLayouts); if (targetLayout != null) { @@ -438,7 +443,6 @@ public boolean dragDroppedInChosenCell(PreviewLayout targetLayout, Dragboard dra chosenListProperty.getValue().addAll(targetId, draggedSelectedLayouts); - chosenSelectionModelProperty.getValue().clearSelection(); draggedSelectedLayouts.forEach(layout -> chosenSelectionModelProperty.getValue().select(layout)); success = true;