Skip to content

Commit

Permalink
Fix Preferences style value too long (#6372)
Browse files Browse the repository at this point in the history
* Showing correct icon on main table linked files column

* Showing correct icon on both main table and linked files column

* Showing correct icon on both main table and linked file editor list

* delete the TODO comments

* add record in CHANGELOG.md

* Squashed 'src/main/resources/csl-styles/' changes from fa6bb22..06785fa

* Fixed unexpected modification of Preview in Preferences->Entry preview

* Add entry in CHANGELOG.md

* Add entry in CHANGELOG.md
  • Loading branch information
leitianjian authored Apr 29, 2020
1 parent cbf7796 commit d10e56f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/preferences/PreviewTabView.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void dragDetectedInAvailable(MouseEvent event) {
List<PreviewLayout> 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();
}
Expand All @@ -220,7 +220,7 @@ private void dragDetectedInChosen(MouseEvent event) {
List<PreviewLayout> 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();
}
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/org/jabref/gui/preferences/PreviewTabViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class PreviewTabViewModel implements PreferenceTabViewModel {
private final CustomLocalDragboard localDragboard;
private Validator chosenListValidator;
private ListProperty<PreviewLayout> dragSourceList = null;
private ObjectProperty<MultipleSelectionModel<PreviewLayout>> dragSourceSelectionModel = null;

public PreviewTabViewModel(DialogService dialogService, JabRefPreferences preferences, TaskExecutor taskExecutor, StateManager stateManager) {
this.dialogService = dialogService;
Expand Down Expand Up @@ -231,12 +232,14 @@ public boolean validateSettings() {

public void addToChosen() {
List<PreviewLayout> selected = new ArrayList<>(availableSelectionModelProperty.getValue().getSelectedItems());
availableSelectionModelProperty.getValue().clearSelection();
availableListProperty.removeAll(selected);
chosenListProperty.addAll(selected);
}

public void removeFromChosen() {
List<PreviewLayout> selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedItems());
chosenSelectionModelProperty.getValue().clearSelection();
chosenListProperty.removeAll(selected);
availableListProperty.addAll(selected);
availableListProperty.sort((a, b) -> a.getName().compareToIgnoreCase(b.getName()));
Expand All @@ -249,6 +252,7 @@ public void selectedInChosenUp() {

List<Integer> selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedIndices());
List<Integer> newIndices = new ArrayList<>();
chosenSelectionModelProperty.getValue().clearSelection();

for (int oldIndex : selected) {
boolean alreadyTaken = newIndices.contains(oldIndex - 1);
Expand All @@ -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();
Expand All @@ -270,6 +273,7 @@ public void selectedInChosenDown() {

List<Integer> selected = new ArrayList<>(chosenSelectionModelProperty.getValue().getSelectedIndices());
List<Integer> newIndices = new ArrayList<>();
chosenSelectionModelProperty.getValue().clearSelection();

for (int i = selected.size() - 1; i >= 0; i--) {
int oldIndex = selected.get(i);
Expand All @@ -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();
Expand Down Expand Up @@ -365,12 +368,13 @@ public void dragOver(DragEvent event) {
}
}

public void dragDetected(ListProperty<PreviewLayout> sourceList, List<PreviewLayout> selectedLayouts, Dragboard dragboard) {
public void dragDetected(ListProperty<PreviewLayout> sourceList, ObjectProperty<MultipleSelectionModel<PreviewLayout>> sourceSelectionModel, List<PreviewLayout> selectedLayouts, Dragboard dragboard) {
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.PREVIEWLAYOUTS, "");
dragboard.setContent(content);
localDragboard.putPreviewLayouts(selectedLayouts);
dragSourceList = sourceList;
dragSourceSelectionModel = sourceSelectionModel;
}

/**
Expand All @@ -386,6 +390,7 @@ public boolean dragDropped(ListProperty<PreviewLayout> targetList, Dragboard dra
if (dragboard.hasContent(DragAndDropDataFormats.PREVIEWLAYOUTS)) {
List<PreviewLayout> draggedLayouts = localDragboard.getPreviewLayouts();
if (!draggedLayouts.isEmpty()) {
dragSourceSelectionModel.getValue().clearSelection();
dragSourceList.getValue().removeAll(draggedLayouts);
targetList.getValue().addAll(draggedLayouts);
success = true;
Expand All @@ -412,7 +417,7 @@ public boolean dragDroppedInChosenCell(PreviewLayout targetLayout, Dragboard dra
if (dragboard.hasContent(DragAndDropDataFormats.PREVIEWLAYOUTS)) {
List<PreviewLayout> 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
Expand All @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit d10e56f

Please sign in to comment.