diff --git a/CHANGELOG.md b/CHANGELOG.md index df11540ff6e..53505257d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,11 +20,11 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Inherit fields from cross-referenced entries as specified by biblatex. [#5045](https://github.com/JabRef/jabref/issues/5045) - We fixed an issue where it was no longer possible to connect to LibreOffice. [#5261](https://github.com/JabRef/jabref/issues/5261) - The "All entries group" is no longer shown when no library is open. +- After assigning an entry to a group, the item count is now properly colored to reflect the new membership of the entry. [#3112](https://github.com/JabRef/jabref/issues/3112) - The group panel is now properly updated when switching between libraries (or when closing/opening one). [#3142](https://github.com/JabRef/jabref/issues/3142) - We fixed an error where the number of matched entries shown in the group pane was not updated correctly. [#4441](https://github.com/JabRef/jabref/issues/4441) - We fixed an error mentioning "javafx.controls/com.sun.javafx.scene.control" that was thrown when interacting with the toolbar. - ### Removed diff --git a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java index e4f2678db82..2eece37b6aa 100644 --- a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java @@ -113,8 +113,13 @@ public List addEntriesToGroup(List entries) { // return; // user aborted operation //} - return groupNode.addEntriesToGroup(entries); + var changes = groupNode.addEntriesToGroup(entries); + // Update appearance of group + anySelectedEntriesMatched.invalidate(); + allSelectedEntriesMatched.invalidate(); + + return changes; // TODO: Store undo // if (!undo.isEmpty()) { // groupSelector.concludeAssignment(UndoableChangeEntriesOfGroup.getUndoableEdit(target, undo), target.getNode(), assignedEntries); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index c9686d9ab4f..ddfbf0434e1 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -111,8 +111,7 @@ public void initialize() { })); // Icon and group name - mainColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty()); - new ViewModelTreeTableCellFactory() + new ViewModelTreeTableCellFactory() .withText(GroupNodeViewModel::getDisplayName) .withIcon(GroupNodeViewModel::getIcon) .withTooltip(GroupNodeViewModel::getDescription) @@ -121,7 +120,7 @@ public void initialize() { // Number of hits PseudoClass anySelected = PseudoClass.getPseudoClass("any-selected"); PseudoClass allSelected = PseudoClass.getPseudoClass("all-selected"); - new ViewModelTreeTableCellFactory() + new ViewModelTreeTableCellFactory() .withGraphic(group -> { final StackPane node = new StackPane(); node.getStyleClass().setAll("hits"); @@ -141,8 +140,7 @@ public void initialize() { .install(numberColumn); // Arrow indicating expanded status - disclosureNodeColumn.setCellValueFactory(cellData -> cellData.getValue().valueProperty()); - new ViewModelTreeTableCellFactory() + new ViewModelTreeTableCellFactory() .withGraphic(viewModel -> { final StackPane disclosureNode = new StackPane(); disclosureNode.visibleProperty().bind(viewModel.hasChildrenProperty()); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index feb3a90e23a..47ae8b58c62 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -52,6 +52,7 @@ public GroupTreeViewModel(StateManager stateManager, DialogService dialogService this.dialogService = Objects.requireNonNull(dialogService); this.taskExecutor = Objects.requireNonNull(taskExecutor); this.localDragboard = Objects.requireNonNull(localDragboard); + // Register listener EasyBind.subscribe(stateManager.activeDatabaseProperty(), this::onActiveDatabaseChanged); EasyBind.subscribe(selectedGroups, this::onSelectedGroupChanged); diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java index c58665b93e2..69528fc8927 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java @@ -29,7 +29,7 @@ public class KeyBindingsDialogView extends BaseDialog { @FXML private TreeTableView keyBindingsTable; @FXML private TreeTableColumn actionColumn; @FXML private TreeTableColumn shortcutColumn; - @FXML private TreeTableColumn resetColumn; + @FXML private TreeTableColumn resetColumn; @Inject private KeyBindingRepository keyBindingRepository; @Inject private DialogService dialogService; @@ -65,10 +65,10 @@ private void initialize() { ); actionColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().nameProperty()); shortcutColumn.setCellValueFactory(cellData -> cellData.getValue().getValue().shownBindingProperty()); - resetColumn.setCellFactory(new ViewModelTreeTableCellFactory() + new ViewModelTreeTableCellFactory() .withGraphic(keyBinding -> keyBinding.getIcon().map(JabRefIcon::getGraphicNode).orElse(null)) .withOnMouseClickedEvent(keyBinding -> evt -> keyBinding.resetToDefault()) - ); + .install(resetColumn); } @FXML diff --git a/src/main/java/org/jabref/gui/util/ViewModelTreeTableCellFactory.java b/src/main/java/org/jabref/gui/util/ViewModelTreeTableCellFactory.java index 233178e17fd..8b89661ac3c 100644 --- a/src/main/java/org/jabref/gui/util/ViewModelTreeTableCellFactory.java +++ b/src/main/java/org/jabref/gui/util/ViewModelTreeTableCellFactory.java @@ -15,56 +15,54 @@ * Constructs a {@link TreeTableCell} based on the view model of the row and a bunch of specified converter methods. * * @param view model - * @param cell value */ -public class ViewModelTreeTableCellFactory implements Callback, TreeTableCell> { +public class ViewModelTreeTableCellFactory implements Callback, TreeTableCell> { private Callback toText; private Callback toGraphic; private Callback> toOnMouseClickedEvent; private Callback toTooltip; - public ViewModelTreeTableCellFactory withText(Callback toText) { + public ViewModelTreeTableCellFactory withText(Callback toText) { this.toText = toText; return this; } - public ViewModelTreeTableCellFactory withGraphic(Callback toGraphic) { + public ViewModelTreeTableCellFactory withGraphic(Callback toGraphic) { this.toGraphic = toGraphic; return this; } - public ViewModelTreeTableCellFactory withIcon(Callback toIcon) { + public ViewModelTreeTableCellFactory withIcon(Callback toIcon) { this.toGraphic = viewModel -> toIcon.call(viewModel).getGraphicNode(); return this; } - public ViewModelTreeTableCellFactory withTooltip(Callback toTooltip) { + public ViewModelTreeTableCellFactory withTooltip(Callback toTooltip) { this.toTooltip = toTooltip; return this; } - public ViewModelTreeTableCellFactory withOnMouseClickedEvent( + public ViewModelTreeTableCellFactory withOnMouseClickedEvent( Callback> toOnMouseClickedEvent) { this.toOnMouseClickedEvent = toOnMouseClickedEvent; return this; } @Override - public TreeTableCell call(TreeTableColumn param) { + public TreeTableCell call(TreeTableColumn param) { - return new TreeTableCell() { + return new TreeTableCell() { @Override - protected void updateItem(T item, boolean empty) { - super.updateItem(item, empty); + protected void updateItem(S viewModel, boolean empty) { + super.updateItem(viewModel, empty); - if (empty || getTreeTableRow() == null || getTreeTableRow().getItem() == null) { + if (empty || viewModel == null) { setText(null); setGraphic(null); setOnMouseClicked(null); } else { - S viewModel = getTreeTableRow().getItem(); if (toText != null) { setText(toText.call(viewModel)); } @@ -85,7 +83,8 @@ protected void updateItem(T item, boolean empty) { }; } - public void install(TreeTableColumn column) { + public void install(TreeTableColumn column) { + column.setCellValueFactory(cellData -> cellData.getValue().valueProperty()); column.setCellFactory(this); } }