From ab5a4e6e7c80e096ec4b40e8463af89a1ab57715 Mon Sep 17 00:00:00 2001 From: Kevin Klein Date: Sun, 9 Oct 2022 14:32:57 +0200 Subject: [PATCH 1/4] Place subgroups w.r.t. alphabetical ordering --- CHANGELOG.md | 1 + .../java/org/jabref/gui/groups/GroupTreeView.java | 2 +- .../org/jabref/gui/groups/GroupTreeViewModel.java | 14 +++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 895a48815ec..674f8dba8d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We reworked the Define study parameters dialog. [#9123](https://github.com/JabRef/jabref/pull/9123) - We simplified the actions to fast-resolve duplicates to 'Keep Left', 'Keep Right', 'Keep Both' and 'Keep Merged'. [#9056](https://github.com/JabRef/jabref/issues/9056) - We fixed an issue where a message about changed metadata would occur on saving although nothing changed. [#9159](https://github.com/JabRef/jabref/issues/9159) +- When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [#577](https://github.com/koppor/jabref/issues/9159) ### Fixed diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 995afdee45d..fd3ab5c7614 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -430,7 +430,7 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) { }); MenuItem sortSubgroups = new MenuItem(Localization.lang("Sort subgroups")); - sortSubgroups.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group)); + sortSubgroups.setOnAction(event -> viewModel.sortAlphabeticallyRecursive(group.getGroupNode())); MenuItem addEntries = new MenuItem(Localization.lang("Add selected entries to this group")); addEntries.setOnAction(event -> viewModel.addSelectedEntries(group)); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 670130757ad..1d25ec2113b 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -150,7 +150,8 @@ private void onActiveDatabaseChanged(Optional newDatabase) { } /** - * Opens "New Group Dialog" and add the resulting group to the specified group + * Opens "New Group Dialog" and adds the resulting group as subgroup to the specified group while maintaining the + * alphabetical order */ public void addNewSubgroup(GroupNodeViewModel parent, GroupDialogHeader groupDialogHeader) { @@ -172,6 +173,8 @@ public void addNewSubgroup(GroupNodeViewModel parent, GroupDialogHeader groupDia // TODO: Expand parent to make new group visible // parent.expand(); + sortAlphabeticallyRecursive(parent.getGroupNode()); + dialogService.notify(Localization.lang("Added group \"%0\".", group.getName())); writeGroupChangesToMetaData(); }); @@ -260,6 +263,11 @@ public void editGroup(GroupNodeViewModel oldGroup) { // undoAddPreviousEntries = UndoableChangeEntriesOfGroup.getUndoableEdit(null, addChange); // } + oldGroup.getParent().ifPresent(parent -> { + sortAlphabeticallyRecursive(parent); + }); + + dialogService.notify(Localization.lang("Modified group \"%0\".", group.getName())); writeGroupChangesToMetaData(); @@ -420,7 +428,7 @@ public void removeSelectedEntries(GroupNodeViewModel group) { // mPanel.getUndoManager().addEdit(UndoableChangeEntriesOfGroup.getUndoableEdit(mNode, undo)); } - public void sortAlphabeticallyRecursive(GroupNodeViewModel group) { - group.getGroupNode().sortChildren(compAlphabetIgnoreCase, true); + public void sortAlphabeticallyRecursive(GroupTreeNode group) { + group.sortChildren(compAlphabetIgnoreCase, true); } } From feca84108c8d80fb152646e2d98d0272b04cd3d5 Mon Sep 17 00:00:00 2001 From: Kevin Klein <38384885+0x002A@users.noreply.github.com> Date: Sun, 9 Oct 2022 14:35:48 +0200 Subject: [PATCH 2/4] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 674f8dba8d1..0fecc8aace0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We reworked the Define study parameters dialog. [#9123](https://github.com/JabRef/jabref/pull/9123) - We simplified the actions to fast-resolve duplicates to 'Keep Left', 'Keep Right', 'Keep Both' and 'Keep Merged'. [#9056](https://github.com/JabRef/jabref/issues/9056) - We fixed an issue where a message about changed metadata would occur on saving although nothing changed. [#9159](https://github.com/JabRef/jabref/issues/9159) -- When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [#577](https://github.com/koppor/jabref/issues/9159) +- When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [#577](https://github.com/koppor/jabref/issues/577) ### Fixed From be9eb4c55bfc23c9e48c4788f63c3537a1065e06 Mon Sep 17 00:00:00 2001 From: Kevin Klein Date: Sun, 9 Oct 2022 16:08:06 +0200 Subject: [PATCH 3/4] Fix checkstyle --- src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 1d25ec2113b..5b0b3db25c5 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -267,7 +267,6 @@ public void editGroup(GroupNodeViewModel oldGroup) { sortAlphabeticallyRecursive(parent); }); - dialogService.notify(Localization.lang("Modified group \"%0\".", group.getName())); writeGroupChangesToMetaData(); From 2a5b8203e8c239df0be4a058a295ee80d8bae306 Mon Sep 17 00:00:00 2001 From: Kevin Klein <38384885+0x002A@users.noreply.github.com> Date: Mon, 10 Oct 2022 23:34:11 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b62ac13d111..c10964cb1a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We reworked the Define study parameters dialog. [#9123](https://github.com/JabRef/jabref/pull/9123) - We simplified the actions to fast-resolve duplicates to 'Keep Left', 'Keep Right', 'Keep Both' and 'Keep Merged'. [#9056](https://github.com/JabRef/jabref/issues/9056) - We fixed an issue where a message about changed metadata would occur on saving although nothing changed. [#9159](https://github.com/JabRef/jabref/issues/9159) -- When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [#577](https://github.com/koppor/jabref/issues/577) +- When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [koppor#577](https://github.com/koppor/jabref/issues/577) ### Fixed