From 42616e24b8d86198eb9cb8c563d52eb1dddbdb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Tue, 5 Nov 2024 12:31:58 +0100 Subject: [PATCH 01/10] Added keybinding for renaming group with F2 --- .../jabref/gui/actions/StandardActions.java | 1 + .../jabref/gui/groups/GroupDialogView.java | 3 + .../org/jabref/gui/groups/GroupTreeView.java | 12 +++ .../jabref/gui/groups/GroupTreeViewModel.java | 59 +++++++++++++ .../jabref/gui/groups/RenameGroupView.java | 83 +++++++++++++++++++ .../org/jabref/gui/keyboard/KeyBinding.java | 3 +- 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/jabref/gui/groups/RenameGroupView.java diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index df789a51733..303cca6ecc2 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -192,6 +192,7 @@ public enum StandardActions implements Action { GROUP_REMOVE_KEEP_SUBGROUPS(Localization.lang("Keep subgroups")), GROUP_REMOVE_WITH_SUBGROUPS(Localization.lang("Also remove subgroups")), GROUP_CHAT(Localization.lang("Chat with group")), + GROUP_RENAME(Localization.lang("Rename group"),KeyBinding.RENAME_GROUP), GROUP_EDIT(Localization.lang("Edit group")), GROUP_GENERATE_SUMMARIES(Localization.lang("Generate summaries for entries in the group")), GROUP_GENERATE_EMBEDDINGS(Localization.lang("Generate embeddings for linked files in the group")), diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogView.java b/src/main/java/org/jabref/gui/groups/GroupDialogView.java index c1f537248ea..f3553411845 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialogView.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialogView.java @@ -118,6 +118,7 @@ public GroupDialogView(BibDatabaseContext currentDatabase, @Nullable GroupTreeNode parentNode, @Nullable AbstractGroup editedGroup, GroupDialogHeader groupDialogHeader) { + this.currentDatabase = currentDatabase; this.parentNode = parentNode; this.editedGroup = editedGroup; @@ -158,6 +159,8 @@ public GroupDialogView(BibDatabaseContext currentDatabase, confirmDialogButton.disableProperty().bind(viewModel.validationStatus().validProperty().not()); // handle validation before closing dialog and calling resultConverter confirmDialogButton.addEventFilter(ActionEvent.ACTION, viewModel::validationHandler); + + } private @Nullable AbstractGroup parentGroup() { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 7b6efa2ecdd..f53d001b9ca 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -10,6 +10,11 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Button; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; import javafx.application.Platform; import javafx.beans.binding.Bindings; @@ -538,6 +543,7 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) { ActionFactory factory = new ActionFactory(); MenuItem removeGroup; + if (group.hasSubgroups() && group.canAddGroupsIn() && !group.isRoot()) { removeGroup = new Menu(Localization.lang("Remove group"), null, factory.createMenuItem(StandardActions.GROUP_REMOVE_KEEP_SUBGROUPS, @@ -557,6 +563,7 @@ private ContextMenu createContextMenuForGroup(GroupNodeViewModel group) { factory.createMenuItem(StandardActions.GROUP_EDIT, new ContextAction(StandardActions.GROUP_EDIT, group)), factory.createMenuItem(StandardActions.GROUP_GENERATE_EMBEDDINGS, new ContextAction(StandardActions.GROUP_GENERATE_EMBEDDINGS, group)), factory.createMenuItem(StandardActions.GROUP_GENERATE_SUMMARIES, new ContextAction(StandardActions.GROUP_GENERATE_SUMMARIES, group)), + factory.createMenuItem(StandardActions.GROUP_RENAME, new ContextAction(StandardActions.GROUP_RENAME, group)), removeGroup, new SeparatorMenuItem(), factory.createMenuItem(StandardActions.GROUP_SUBGROUP_ADD, new ContextAction(StandardActions.GROUP_SUBGROUP_ADD, group)), @@ -639,6 +646,8 @@ public ContextAction(StandardActions command, GroupNodeViewModel group) { switch (command) { case GROUP_EDIT -> group.isEditable(); + case GROUP_RENAME -> + group.isEditable(); case GROUP_REMOVE, GROUP_REMOVE_WITH_SUBGROUPS, GROUP_REMOVE_KEEP_SUBGROUPS -> group.isEditable() && group.canRemove(); case GROUP_SUBGROUP_ADD -> @@ -662,6 +671,9 @@ public void execute() { switch (command) { case GROUP_REMOVE -> viewModel.removeGroupNoSubgroups(group); + case GROUP_RENAME -> { + viewModel.renameGroup(group); + } case GROUP_REMOVE_KEEP_SUBGROUPS -> viewModel.removeGroupKeepSubgroups(group); case GROUP_REMOVE_WITH_SUBGROUPS -> diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 48def6325c8..82c02da015f 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -260,9 +260,68 @@ boolean onlyMinorChanges(AbstractGroup oldGroup, AbstractGroup newGroup) { return true; } + /** + * Opens "Rename Group Dialog" and change name of group + */ + + public void renameGroup(GroupNodeViewModel oldGroup) { + currentDatabase.ifPresent(database -> { + AbstractGroup oldGroupDef = oldGroup.getGroupNode().getGroup(); + String oldGroupName = oldGroupDef.getName(); // Zachytenie starého názvu pred otvorením dialógu + + + Optional newGroup = dialogService.showCustomDialogAndWait( + new RenameGroupView(database, + oldGroup.getGroupNode().getGroup()) + ); + + newGroup.ifPresent(group -> { + + String newGroupName = group.getName(); + + + //check if it´s empty new string + if (newGroupName.trim().isEmpty()) { + dialogService.notify(Localization.lang("The new group name cannot be empty or consist only of spaces.")); + return; + } + + // check if is not include "," + if (newGroupName.contains(",")) { + dialogService.notify(Localization.lang("The new group name cannot contain commas.")); + return; + } + + // chceck if old group name dont equels with new group name + if (oldGroupName.equals(newGroupName)) { + dialogService.notify(Localization.lang("The new group name is the same as the old one. No changes made.")); + return; + } + + + // check if other groups name are not same + int groupsWithSameName = 0; + Optional databaseRootGroup = currentDatabase.get().getMetaData().getGroups(); + if (databaseRootGroup.isPresent()) { + groupsWithSameName = databaseRootGroup.get().findChildrenSatisfying(g -> g.getName().equals(newGroupName)).size(); + } + + // then change name + if (groupsWithSameName < 2) { + oldGroup.getGroupNode().setGroup(group, true, true, database.getEntries()); + dialogService.notify(Localization.lang("Renamed group from \"%0\" to \"%1\".", oldGroupName, newGroupName)); + writeGroupChangesToMetaData(); + refresh(); + } + }); + }); + } + + /** * Opens "Edit Group Dialog" and changes the given group to the edited one. */ + public void editGroup(GroupNodeViewModel oldGroup) { currentDatabase.ifPresent(database -> { Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialogView( diff --git a/src/main/java/org/jabref/gui/groups/RenameGroupView.java b/src/main/java/org/jabref/gui/groups/RenameGroupView.java new file mode 100644 index 00000000000..c21e2647067 --- /dev/null +++ b/src/main/java/org/jabref/gui/groups/RenameGroupView.java @@ -0,0 +1,83 @@ +package org.jabref.gui.groups; + +import jakarta.inject.Inject; +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.scene.layout.VBox; +import org.jabref.gui.DialogService; +import org.jabref.gui.util.BaseDialog; +import org.jabref.logic.l10n.Localization; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.groups.*; +import org.jspecify.annotations.Nullable; + +import java.util.Optional; + +public class RenameGroupView extends BaseDialog { + + @FXML + private TextField nameField; + + @Inject + private DialogService dialogService; + + + private final BibDatabaseContext currentDatabase; + private final @Nullable AbstractGroup editedGroup; + + public RenameGroupView(BibDatabaseContext currentDatabase, + @Nullable AbstractGroup editedGroup) { + this.currentDatabase = currentDatabase; + this.editedGroup = editedGroup; + + // set Width and Height + setWidth(400); + setHeight(150); + + // set Title name + setTitle(Localization.lang("Rename group")); + + // add OK and Cancel buttons + getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); + + nameField = new TextField(); + nameField.setPromptText("Enter new group name"); + + // add Input + VBox vbox = new VBox(new Label("New group name:"), nameField); + getDialogPane().setContent(vbox); + + // If press OK change name else return null + setResultConverter(buttonType -> { + if (buttonType == ButtonType.OK) { + return resultConverter(ButtonType.OK).orElse(null); + } else { + // Ak sa zvolí Cancel alebo sa dialóg zavrie cez X + return null; + } + }); + } + + protected Optional resultConverter(ButtonType button) { + if (button != ButtonType.OK) { + return Optional.empty(); + } + + try { + // Get new name from Input + String newGroupName = nameField.getText().trim(); + + if (editedGroup != null) { + //set new input + editedGroup.nameProperty().set(newGroupName); + return Optional.of(editedGroup); + } + + return Optional.empty(); + } catch (Exception exception) { + dialogService.showErrorDialogAndWait(exception.getLocalizedMessage(), exception); + return Optional.empty(); + } + } +} + diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java index d0cb6100338..cd6666a80ca 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java @@ -6,7 +6,8 @@ * @implNote Cannot be sorted alphabetically, as {@link KeyBindingRepository#getKeyCombination(KeyBinding)} iterates over the enum in order and returns the first match. */ public enum KeyBinding { - EDITOR_DELETE("Delete", Localization.lang("Delete text"), "", KeyBindingCategory.EDITOR), + EDITOR_DELETE("Delete", Localization.lang("Delete text"), "",KeyBindingCategory.EDITOR ), + RENAME_GROUP("Rename Group",Localization.lang("Rename group"),"R", KeyBindingCategory.EDIT), // DELETE BACKWARDS = Rubout EDITOR_BACKWARD("Move caret left", Localization.lang("Move caret left"), "", KeyBindingCategory.EDITOR), EDITOR_FORWARD("Move caret right", Localization.lang("Move caret right"), "", KeyBindingCategory.EDITOR), From ea811f193c6d48aa975773c8e0e523f824669135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Mon, 11 Nov 2024 23:26:21 +0100 Subject: [PATCH 02/10] fix group size changes --- src/main/java/org/jabref/gui/DialogService.java | 2 ++ .../org/jabref/gui/groups/GroupTreeView.java | 6 +----- .../jabref/gui/groups/GroupTreeViewModel.java | 10 +--------- .../org/jabref/gui/groups/RenameGroupView.java | 17 ++++++++++------- .../org/jabref/gui/keyboard/KeyBinding.java | 4 ++-- 5 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/jabref/gui/DialogService.java b/src/main/java/org/jabref/gui/DialogService.java index 7248be47511..d2460f0fd71 100644 --- a/src/main/java/org/jabref/gui/DialogService.java +++ b/src/main/java/org/jabref/gui/DialogService.java @@ -27,9 +27,11 @@ import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.dialog.ProgressDialog; + /** * This interface provides methods to create dialogs and show them to the user. */ +@SuppressWarnings("checkstyle:EmptyLineSeparator") public interface DialogService extends NotificationService { /** diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index f53d001b9ca..c8c621756de 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -10,11 +10,6 @@ import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.MenuItem; -import javafx.scene.control.Button; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.HBox; import javafx.application.Platform; import javafx.beans.binding.Bindings; @@ -673,6 +668,7 @@ public void execute() { viewModel.removeGroupNoSubgroups(group); case GROUP_RENAME -> { viewModel.renameGroup(group); + groupTree.refresh(); } case GROUP_REMOVE_KEEP_SUBGROUPS -> viewModel.removeGroupKeepSubgroups(group); diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 82c02da015f..fe55099b7a4 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -269,7 +269,6 @@ public void renameGroup(GroupNodeViewModel oldGroup) { AbstractGroup oldGroupDef = oldGroup.getGroupNode().getGroup(); String oldGroupName = oldGroupDef.getName(); // Zachytenie starého názvu pred otvorením dialógu - Optional newGroup = dialogService.showCustomDialogAndWait( new RenameGroupView(database, oldGroup.getGroupNode().getGroup()) @@ -279,27 +278,20 @@ public void renameGroup(GroupNodeViewModel oldGroup) { String newGroupName = group.getName(); - - //check if it´s empty new string if (newGroupName.trim().isEmpty()) { - dialogService.notify(Localization.lang("The new group name cannot be empty or consist only of spaces.")); return; } // check if is not include "," if (newGroupName.contains(",")) { - dialogService.notify(Localization.lang("The new group name cannot contain commas.")); return; } // chceck if old group name dont equels with new group name if (oldGroupName.equals(newGroupName)) { - dialogService.notify(Localization.lang("The new group name is the same as the old one. No changes made.")); return; } - - // check if other groups name are not same int groupsWithSameName = 0; Optional databaseRootGroup = currentDatabase.get().getMetaData().getGroups(); if (databaseRootGroup.isPresent()) { @@ -309,7 +301,6 @@ public void renameGroup(GroupNodeViewModel oldGroup) { // then change name if (groupsWithSameName < 2) { oldGroup.getGroupNode().setGroup(group, true, true, database.getEntries()); - dialogService.notify(Localization.lang("Renamed group from \"%0\" to \"%1\".", oldGroupName, newGroupName)); writeGroupChangesToMetaData(); refresh(); } @@ -322,6 +313,7 @@ public void renameGroup(GroupNodeViewModel oldGroup) { * Opens "Edit Group Dialog" and changes the given group to the edited one. */ + @SuppressWarnings("checkstyle:EmptyLineSeparator") public void editGroup(GroupNodeViewModel oldGroup) { currentDatabase.ifPresent(database -> { Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialogView( diff --git a/src/main/java/org/jabref/gui/groups/RenameGroupView.java b/src/main/java/org/jabref/gui/groups/RenameGroupView.java index c21e2647067..08b0a785a76 100644 --- a/src/main/java/org/jabref/gui/groups/RenameGroupView.java +++ b/src/main/java/org/jabref/gui/groups/RenameGroupView.java @@ -1,17 +1,21 @@ package org.jabref.gui.groups; -import jakarta.inject.Inject; +import java.util.Optional; + import javafx.fxml.FXML; -import javafx.scene.control.*; +import javafx.scene.control.ButtonType; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; import javafx.scene.layout.VBox; + import org.jabref.gui.DialogService; import org.jabref.gui.util.BaseDialog; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; -import org.jabref.model.groups.*; -import org.jspecify.annotations.Nullable; +import org.jabref.model.groups.AbstractGroup; -import java.util.Optional; +import jakarta.inject.Inject; +import org.jspecify.annotations.Nullable; public class RenameGroupView extends BaseDialog { @@ -68,8 +72,7 @@ protected Optional resultConverter(ButtonType button) { String newGroupName = nameField.getText().trim(); if (editedGroup != null) { - //set new input - editedGroup.nameProperty().set(newGroupName); + editedGroup.nameProperty().setValue(newGroupName); return Optional.of(editedGroup); } diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java index cd6666a80ca..f36be28585f 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBinding.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBinding.java @@ -6,11 +6,11 @@ * @implNote Cannot be sorted alphabetically, as {@link KeyBindingRepository#getKeyCombination(KeyBinding)} iterates over the enum in order and returns the first match. */ public enum KeyBinding { - EDITOR_DELETE("Delete", Localization.lang("Delete text"), "",KeyBindingCategory.EDITOR ), - RENAME_GROUP("Rename Group",Localization.lang("Rename group"),"R", KeyBindingCategory.EDIT), // DELETE BACKWARDS = Rubout EDITOR_BACKWARD("Move caret left", Localization.lang("Move caret left"), "", KeyBindingCategory.EDITOR), EDITOR_FORWARD("Move caret right", Localization.lang("Move caret right"), "", KeyBindingCategory.EDITOR), + EDITOR_DELETE("Delete", Localization.lang("Delete text"), "", KeyBindingCategory.EDITOR), + RENAME_GROUP("Rename Group", Localization.lang("Rename group"), "F2", KeyBindingCategory.EDIT), EDITOR_WORD_BACKWARD("Move caret to previous word", Localization.lang("Move caret to previous word"), "", KeyBindingCategory.EDITOR), EDITOR_WORD_FORWARD("Move caret to next word", Localization.lang("Move caret to next word"), "", KeyBindingCategory.EDITOR), EDITOR_BEGINNING("Move caret to beginning of line", Localization.lang("Move caret to beginning of line"), "", KeyBindingCategory.EDITOR), From 8144433b001eafe1948e8a75885a3f678ea286ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Mon, 11 Nov 2024 23:43:59 +0100 Subject: [PATCH 03/10] fix checkstyleTest --- src/main/java/org/jabref/gui/actions/StandardActions.java | 2 +- src/main/java/org/jabref/gui/groups/GroupDialogView.java | 3 --- src/main/java/org/jabref/gui/groups/RenameGroupView.java | 3 +-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/StandardActions.java b/src/main/java/org/jabref/gui/actions/StandardActions.java index 303cca6ecc2..9ebdf89bf6b 100644 --- a/src/main/java/org/jabref/gui/actions/StandardActions.java +++ b/src/main/java/org/jabref/gui/actions/StandardActions.java @@ -192,7 +192,7 @@ public enum StandardActions implements Action { GROUP_REMOVE_KEEP_SUBGROUPS(Localization.lang("Keep subgroups")), GROUP_REMOVE_WITH_SUBGROUPS(Localization.lang("Also remove subgroups")), GROUP_CHAT(Localization.lang("Chat with group")), - GROUP_RENAME(Localization.lang("Rename group"),KeyBinding.RENAME_GROUP), + GROUP_RENAME(Localization.lang("Rename group"), KeyBinding.RENAME_GROUP), GROUP_EDIT(Localization.lang("Edit group")), GROUP_GENERATE_SUMMARIES(Localization.lang("Generate summaries for entries in the group")), GROUP_GENERATE_EMBEDDINGS(Localization.lang("Generate embeddings for linked files in the group")), diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogView.java b/src/main/java/org/jabref/gui/groups/GroupDialogView.java index f3553411845..455f719d686 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialogView.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialogView.java @@ -102,7 +102,6 @@ public class GroupDialogView extends BaseDialog { private final EnumMap hierarchyToolTip = new EnumMap<>(GroupHierarchyType.class); private final ControlsFxVisualizer validationVisualizer = new ControlsFxVisualizer(); - private final BibDatabaseContext currentDatabase; private final @Nullable GroupTreeNode parentNode; private final @Nullable AbstractGroup editedGroup; @@ -159,8 +158,6 @@ public GroupDialogView(BibDatabaseContext currentDatabase, confirmDialogButton.disableProperty().bind(viewModel.validationStatus().validProperty().not()); // handle validation before closing dialog and calling resultConverter confirmDialogButton.addEventFilter(ActionEvent.ACTION, viewModel::validationHandler); - - } private @Nullable AbstractGroup parentGroup() { diff --git a/src/main/java/org/jabref/gui/groups/RenameGroupView.java b/src/main/java/org/jabref/gui/groups/RenameGroupView.java index 08b0a785a76..83dfa3c7cc9 100644 --- a/src/main/java/org/jabref/gui/groups/RenameGroupView.java +++ b/src/main/java/org/jabref/gui/groups/RenameGroupView.java @@ -10,7 +10,6 @@ import org.jabref.gui.DialogService; import org.jabref.gui.util.BaseDialog; -import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.groups.AbstractGroup; @@ -39,7 +38,7 @@ public RenameGroupView(BibDatabaseContext currentDatabase, setHeight(150); // set Title name - setTitle(Localization.lang("Rename group")); + setTitle("Rename group"); // add OK and Cancel buttons getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); From 20c387a7c790a67356c90b289feca7d7c601285c Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 12 Nov 2024 00:12:55 +0100 Subject: [PATCH 04/10] Discard changes to src/main/java/org/jabref/gui/DialogService.java --- src/main/java/org/jabref/gui/DialogService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/DialogService.java b/src/main/java/org/jabref/gui/DialogService.java index d2460f0fd71..7248be47511 100644 --- a/src/main/java/org/jabref/gui/DialogService.java +++ b/src/main/java/org/jabref/gui/DialogService.java @@ -27,11 +27,9 @@ import org.controlsfx.control.textfield.CustomPasswordField; import org.controlsfx.dialog.ProgressDialog; - /** * This interface provides methods to create dialogs and show them to the user. */ -@SuppressWarnings("checkstyle:EmptyLineSeparator") public interface DialogService extends NotificationService { /** From 67a5d5f1615c3a496c91f294bd573faec38ae3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Mon, 18 Nov 2024 21:35:54 +0100 Subject: [PATCH 05/10] remove comments etc. --- .../jabref/gui/groups/GroupTreeViewModel.java | 9 +-------- .../jabref/gui/groups/RenameGroupView.java | 19 ++++++------------- src/main/resources/l10n/JabRef_en.properties | 4 ++++ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index fe55099b7a4..68ad674234e 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -263,11 +263,10 @@ boolean onlyMinorChanges(AbstractGroup oldGroup, AbstractGroup newGroup) { /** * Opens "Rename Group Dialog" and change name of group */ - public void renameGroup(GroupNodeViewModel oldGroup) { currentDatabase.ifPresent(database -> { AbstractGroup oldGroupDef = oldGroup.getGroupNode().getGroup(); - String oldGroupName = oldGroupDef.getName(); // Zachytenie starého názvu pred otvorením dialógu + String oldGroupName = oldGroupDef.getName(); Optional newGroup = dialogService.showCustomDialogAndWait( new RenameGroupView(database, @@ -282,12 +281,10 @@ public void renameGroup(GroupNodeViewModel oldGroup) { return; } - // check if is not include "," if (newGroupName.contains(",")) { return; } - // chceck if old group name dont equels with new group name if (oldGroupName.equals(newGroupName)) { return; } @@ -298,7 +295,6 @@ public void renameGroup(GroupNodeViewModel oldGroup) { groupsWithSameName = databaseRootGroup.get().findChildrenSatisfying(g -> g.getName().equals(newGroupName)).size(); } - // then change name if (groupsWithSameName < 2) { oldGroup.getGroupNode().setGroup(group, true, true, database.getEntries()); writeGroupChangesToMetaData(); @@ -308,12 +304,9 @@ public void renameGroup(GroupNodeViewModel oldGroup) { }); } - /** * Opens "Edit Group Dialog" and changes the given group to the edited one. */ - - @SuppressWarnings("checkstyle:EmptyLineSeparator") public void editGroup(GroupNodeViewModel oldGroup) { currentDatabase.ifPresent(database -> { Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialogView( diff --git a/src/main/java/org/jabref/gui/groups/RenameGroupView.java b/src/main/java/org/jabref/gui/groups/RenameGroupView.java index 83dfa3c7cc9..165b7a73de9 100644 --- a/src/main/java/org/jabref/gui/groups/RenameGroupView.java +++ b/src/main/java/org/jabref/gui/groups/RenameGroupView.java @@ -10,11 +10,11 @@ import org.jabref.gui.DialogService; import org.jabref.gui.util.BaseDialog; +import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.groups.AbstractGroup; import jakarta.inject.Inject; -import org.jspecify.annotations.Nullable; public class RenameGroupView extends BaseDialog { @@ -26,36 +26,30 @@ public class RenameGroupView extends BaseDialog { private final BibDatabaseContext currentDatabase; - private final @Nullable AbstractGroup editedGroup; + private final AbstractGroup editedGroup; public RenameGroupView(BibDatabaseContext currentDatabase, - @Nullable AbstractGroup editedGroup) { + AbstractGroup editedGroup) { this.currentDatabase = currentDatabase; this.editedGroup = editedGroup; - // set Width and Height setWidth(400); setHeight(150); - // set Title name - setTitle("Rename group"); + setTitle(Localization.lang("Rename group")); - // add OK and Cancel buttons getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); nameField = new TextField(); - nameField.setPromptText("Enter new group name"); + nameField.setPromptText(Localization.lang("Enter new group name")); - // add Input - VBox vbox = new VBox(new Label("New group name:"), nameField); + VBox vbox = new VBox(new Label(Localization.lang("New group name")), nameField); getDialogPane().setContent(vbox); - // If press OK change name else return null setResultConverter(buttonType -> { if (buttonType == ButtonType.OK) { return resultConverter(ButtonType.OK).orElse(null); } else { - // Ak sa zvolí Cancel alebo sa dialóg zavrie cez X return null; } }); @@ -67,7 +61,6 @@ protected Optional resultConverter(ButtonType button) { } try { - // Get new name from Input String newGroupName = nameField.getText().trim(); if (editedGroup != null) { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 0d980636e73..e143163c079 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2797,3 +2797,7 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0' Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0' Store\ url\ for\ downloaded\ file=Store url for downloaded file + +Enter\ new\ group\ name=Enter new group name +New\ group\ name=New group name +Rename\ group=Rename group From 487754a6989916d0238410aa4011c04cef70bb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Mon, 18 Nov 2024 22:57:48 +0100 Subject: [PATCH 06/10] remove comments etc. --- src/main/resources/l10n/JabRef_en.properties | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index e143163c079..0d980636e73 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2797,7 +2797,3 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0' Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0' Store\ url\ for\ downloaded\ file=Store url for downloaded file - -Enter\ new\ group\ name=Enter new group name -New\ group\ name=New group name -Rename\ group=Rename group From a3e85991a36d24686e183b21ee46440bbbee7469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Dul=C3=A1k?= Date: Fri, 22 Nov 2024 21:51:21 +0100 Subject: [PATCH 07/10] try CI --- .../jabref/gui/groups/RenameGroupView.java | 4 +- src/main/resources/l10n/JabRef_en.properties | 65 ++++++++++++------- .../importer/fetcher/JstorFetcherTest.java | 1 + 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/jabref/gui/groups/RenameGroupView.java b/src/main/java/org/jabref/gui/groups/RenameGroupView.java index 165b7a73de9..e8e29db11a0 100644 --- a/src/main/java/org/jabref/gui/groups/RenameGroupView.java +++ b/src/main/java/org/jabref/gui/groups/RenameGroupView.java @@ -41,9 +41,9 @@ public RenameGroupView(BibDatabaseContext currentDatabase, getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); nameField = new TextField(); - nameField.setPromptText(Localization.lang("Enter new group name")); + nameField.setPromptText(Localization.lang("Name")); - VBox vbox = new VBox(new Label(Localization.lang("New group name")), nameField); + VBox vbox = new VBox(new Label(Localization.lang("New group")), nameField); getDialogPane().setContent(vbox); setResultConverter(buttonType -> { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 0d980636e73..05dbcb02578 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -103,11 +103,11 @@ Available\ import\ formats=Available import formats Show\ BibTeX\ source=Show BibTeX source Show/edit\ %0\ source=Show/edit %0 source -Background\ Tasks=Background Tasks +Background\ tasks=Background tasks -Background\ Tasks\ are\ running=Background Tasks are running +Background\ tasks\ are\ running=Background tasks are running -Background\ Tasks\ are\ done=Background Tasks are done +Background\ tasks\ are\ finished=Background tasks are finished Browse=Browse @@ -318,9 +318,9 @@ Extract\ References\ (online)=Extract References (online) Processing...=Processing... Processing\ "%0"...=Processing "%0"... -Processing\ Citation\ Style\ "%0"...=Processing Citation Style "%0"... Processing\ PDF(s)=Processing PDF(s) -Processing\ file\ %0=Processing file %0 +Processing\ %0=Processing %0 +Importing\ files\ into\ %1\ |\ %2\ of\ %0\ file(s)\ processed.=Importing files into %1 | %2 of %0 file(s) processed. Processing\ a\ large\ number\ of\ files=Processing a large number of files You\ are\ about\ to\ process\ %0\ files.\ Continue?=You are about to process %0 files. Continue? @@ -481,8 +481,6 @@ Import\ preferences=Import preferences Import\ preferences\ from\ file=Import preferences from file -Imported\ entries=Imported entries - Importer\ class=Importer class Include\ subgroups\:\ When\ selected,\ view\ entries\ contained\ in\ this\ group\ or\ its\ subgroups=Include subgroups: When selected, view entries contained in this group or its subgroups @@ -490,12 +488,11 @@ Include\ subgroups\:\ When\ selected,\ view\ entries\ contained\ in\ this\ group Independent\ group\:\ When\ selected,\ view\ only\ this\ group's\ entries=Independent group: When selected, view only this group's entries I\ Agree=I Agree -Score=Score Indexing\ bib\ fields\ for\ %0=Indexing bib fields for %0 -Indexing\ PDF\ files\ for\ %0=Indexing PDF files for %0 +Indexing\ %0=Indexing %0 +Indexing\ files\ for\ %1\ |\ %2\ of\ %0\ file(s)\ indexed.=Indexing files for %1 | %2 of %0 file(s) indexed. %0\ of\ %1\ entries\ added\ to\ the\ index.=%0 of %1 entries added to the index. %0\ of\ %1\ entries\ removed\ from\ the\ index.=%0 of %1 entries removed from the index. -Indexing\ %0.\ %1\ of\ %2\ files\ added\ to\ the\ index.=Indexing %0. %1 of %2 files added to the index. Removing\ entries\ from\ index\ for\ %0=Removing entries from index for %0 Invalid\ URL=Invalid URL @@ -810,7 +807,6 @@ Character\ encoding\ '%0'\ is\ not\ supported.=Character encoding '%0' is not su Filter\ search\ results=Filter search results Filter\ by\ groups=Filter by groups Invert\ groups=Invert groups -Match\ score=Match score Scroll\ to\ previous\ match\ category=Scroll to previous match category Scroll\ to\ next\ match\ category=Scroll to next match category Search=Search @@ -818,6 +814,8 @@ Search...=Search... Searching...=Searching... Finished\ Searching=Finished Searching Search\ expression=Search expression +This\ only\ affects\ unfielded\ terms.\ For\ using\ RegEx\ in\ a\ fielded\ term,\ use\ \=~\ operator.=This only affects unfielded terms. For using RegEx in a fielded term, use =~ operator. +This\ only\ affects\ unfielded\ terms.\ For\ using\ case-sensitive\ in\ a\ fielded\ term,\ use\ \=!\ operator.=This only affects unfielded terms. For using case-sensitive in a fielded term, use =! operator. Fulltext\ search=Fulltext search Enable\ indexing=Enable indexing @@ -829,7 +827,7 @@ Searching\ for\ files=Searching for files Use\ regular\ expression\ search=Use regular expression search search\ expression=search expression Free\ search\ expression=Free search expression -Search\ failed\:\ illegal\ search\ expression=Search failed: illegal search expression +Illegal\ search\ expression=Illegal search expression No\ search\ matches.=No search matches. Web\ search=Web search Search\ results=Search results @@ -844,7 +842,7 @@ Clear\ search=Clear search Search\ document\ identifier\ online=Search document identifier online Search\ for\ unlinked\ local\ files=Search for unlinked local files Search\ full\ text\ documents\ online=Search full text documents online -Hint\:\n\nTo\ search\ all\ fields\ for\ Smith,\ enter\:\nsmith\n\nTo\ search\ the\ field\ author\ for\ Smith\ and\ the\ field\ title\ for\ electrical,\ enter\:\nauthor\:Smith\ AND\ title\:electrical=Hint:\n\nTo search all fields for Smith, enter:\nsmith\n\nTo search the field author for Smith and the field title for electrical, enter:\nauthor:Smith AND title:electrical +Hint\:\n\nTo\ search\ all\ fields\ for\ Smith,\ enter\:\nsmith\n\nTo\ search\ the\ field\ author\ for\ Smith\ and\ the\ field\ title\ for\ electrical,\ enter\:\nauthor\=Smith\ AND\ title\=electrical=Hint:\n\nTo search all fields for Smith, enter:\nsmith\n\nTo search the field author for Smith and the field title for electrical, enter:\nauthor=Smith AND title=electrical Search\ term\ is\ empty.=Search term is empty. Invalid\ regular\ expression.=Invalid regular expression. Searching\ for\ a\ keyword=Searching for a keyword @@ -986,7 +984,6 @@ web\ link=web link What\ do\ you\ want\ to\ do?=What do you want to do? Whatever\ option\ you\ choose,\ Mr.\ DLib\ may\ share\ its\ data\ with\ research\ partners\ to\ further\ improve\ recommendation\ quality\ as\ part\ of\ a\ 'living\ lab'.\ Mr.\ DLib\ may\ also\ release\ public\ datasets\ that\ may\ contain\ anonymized\ information\ about\ you\ and\ the\ recommendations\ (sensitive\ information\ such\ as\ metadata\ of\ your\ articles\ will\ be\ anonymised\ through\ e.g.\ hashing).\ Research\ partners\ are\ obliged\ to\ adhere\ to\ the\ same\ strict\ data\ protection\ policy\ as\ Mr.\ DLib.=Whatever option you choose, Mr. DLib may share its data with research partners to further improve recommendation quality as part of a 'living lab'. Mr. DLib may also release public datasets that may contain anonymized information about you and the recommendations (sensitive information such as metadata of your articles will be anonymised through e.g. hashing). Research partners are obliged to adhere to the same strict data protection policy as Mr. DLib. -File\ '%0'\ is\ write\ protected.=File '%0' is write protected. You\ must\ restart\ JabRef\ for\ this\ to\ come\ into\ effect.=You must restart JabRef for this to come into effect. @@ -1001,9 +998,15 @@ Rename\ file=Rename file Move\ file\ to\ file\ directory\ and\ rename\ file=Move file to file directory and rename file +File\ '%0'\ is\ write\ protected.=File '%0' is write protected. Could\ not\ move\ file\ '%0'.=Could not move file '%0'. Could\ not\ find\ file\ '%0'.=Could not find file '%0'. -Number\ of\ entries\ successfully\ imported=Number of entries successfully imported +Error\ opening\ file=Error opening file +Error\ opening\ file\ '%0'=Error opening file '%0' +File\ '%0'\ already\ linked=File '%0' already linked + +%0\ entry(s)\ imported=%0 entry(s) imported + Error\ while\ fetching\ from\ %0=Error while fetching from %0 Unable\ to\ open\ link.=Unable to open link. @@ -1030,8 +1033,6 @@ Rename\ field=Rename field Looking\ for\ full\ text\ document...=Looking for full text document... A\ local\ copy\ will\ be\ opened.=A local copy will be opened. -Error\ opening\ file=Error opening file -Error\ opening\ file\ '%0'=Error opening file '%0' Formatter\ not\ found\:\ %0=Formatter not found: %0 @@ -1055,7 +1056,7 @@ Waiting\ for\ background\ tasks\ to\ finish.\ Quit\ anyway?=Waiting for backgrou Find\ and\ remove\ duplicate\ citation\ keys=Find and remove duplicate citation keys Expected\ syntax\ for\ --fetch\='\:'=Expected syntax for --fetch=':' -General\ file\ directory=General file directory +Library-specific\ file\ directory=Library-specific file directory User-specific\ file\ directory=User-specific file directory LaTeX\ file\ directory=LaTeX file directory @@ -1247,7 +1248,6 @@ Update\ keywords=Update keywords Problem\ connecting=Problem connecting Connection\ to\ OpenOffice/LibreOffice\ has\ been\ lost.\ Please\ make\ sure\ OpenOffice/LibreOffice\ is\ running,\ and\ try\ to\ reconnect.=Connection to OpenOffice/LibreOffice has been lost. Please make sure OpenOffice/LibreOffice is running, and try to reconnect. -JabRef\ will\ send\ at\ least\ one\ request\ per\ entry\ to\ a\ publisher.=JabRef will send at least one request per entry to a publisher. Correct\ the\ entry,\ and\ reopen\ editor\ to\ display/edit\ source.=Correct the entry, and reopen editor to display/edit source. Could\ not\ connect\ to\ running\ OpenOffice/LibreOffice.=Could not connect to running OpenOffice/LibreOffice. Make\ sure\ you\ have\ installed\ OpenOffice/LibreOffice\ with\ Java\ support.=Make sure you have installed OpenOffice/LibreOffice with Java support. @@ -1458,7 +1458,6 @@ Ill-formed\ entrytype\ comment\ in\ BIB\ file=Ill-formed entrytype comment in BI Move\ linked\ files\ to\ default\ file\ directory\ %0=Move linked files to default file directory %0 -Do\ you\ still\ want\ to\ continue?=Do you still want to continue? Internal\ style=Internal style Add\ style\ file=Add style file Remove\ style=Remove style @@ -1761,6 +1760,8 @@ Remote\ services=Remote services Cannot\ use\ port\ %0\ for\ remote\ operation;\ another\ application\ may\ be\ using\ it.\ Try\ specifying\ another\ port.=Cannot use port %0 for remote operation; another application may be using it. Try specifying another port. Grobid\ URL=Grobid URL Allow\ sending\ PDF\ files\ and\ raw\ citation\ strings\ to\ a\ JabRef\ online\ service\ (Grobid)\ to\ determine\ Metadata.\ This\ produces\ better\ results.=Allow sending PDF files and raw citation strings to a JabRef online service (Grobid) to determine Metadata. This produces better results. +Send\ to\ Grobid=Send to Grobid +Do\ not\ send=Do not send Proxy\ requires\ password=Proxy requires password Proxy\ configuration=Proxy configuration @@ -1802,7 +1803,7 @@ See\ what\ has\ been\ changed\ in\ the\ JabRef\ versions=See what has been chang Referenced\ citation\ key\ '%0'\ does\ not\ exist=Referenced citation key '%0' does not exist Full\ text\ document\ for\ entry\ %0\ already\ linked.=Full text document for entry %0 already linked. Download\ full\ text\ documents=Download full text documents -You\ are\ about\ to\ download\ full\ text\ documents\ for\ %0\ entries.=You are about to download full text documents for %0 entries. +You\ are\ attempting\ to\ download\ full\ text\ documents\ for\ %0\ entries.\nJabRef\ will\ send\ at\ least\ one\ request\ per\ entry\ to\ a\ publisher.=You are attempting to download full text documents for %0 entries.\nJabRef will send at least one request per entry to a publisher. last\ four\ nonpunctuation\ characters\ should\ be\ numerals=last four nonpunctuation characters should be numerals Author=Author @@ -2563,7 +2564,6 @@ Are\ you\ sure\ you\ want\ to\ clear\ the\ chat\ history\ of\ this\ entry?=Are y Context\ window\ size=Context window size Context\ window\ size\ must\ be\ greater\ than\ 0=Context window size must be greater than 0 Instruction\ for\ AI\ (also\ known\ as\ prompt\ or\ system\ message)=Instruction for AI (also known as prompt or system message) -The\ instruction\ has\ to\ be\ provided=The instruction has to be provided An\ I/O\ error\ occurred\ while\ opening\ the\ embedding\ model\ by\ URL\ %0=An I/O error occurred while opening the embedding model by URL %0 Got\ error\ while\ processing\ the\ file\:=Got error while processing the file: The\ model\ by\ URL\ %0\ is\ malformed=The model by URL %0 is malformed @@ -2648,6 +2648,12 @@ Generate\ summaries\ for\ entries\ in\ the\ group=Generate summaries for entries Generating\ summaries\ for\ %0=Generating summaries for %0 Ingestion\ started\ for\ group\ "%0".=Ingestion started for group "%0". Summarization\ started\ for\ group\ "%0".=Summarization started for group "%0". +Reset\ templates\ to\ default=Reset templates to default +Templates=Templates +System\ message\ for\ chatting=System message for chatting +User\ message\ for\ chatting=User message for chatting +Completion\ text\ for\ summarization\ of\ a\ chunk=Completion text for summarization of a chunk +Completion\ text\ for\ summarization\ of\ several\ chunks=Completion text for summarization of several chunks Link=Link Source\ URL=Source URL @@ -2763,9 +2769,9 @@ Pushing\ citations\ to\ TeXShop\ is\ only\ possible\ on\ macOS\!=Pushing citatio Single\ instance=Single instance -Copied\ %0\ entry(ies)=Copied %0 entry(ies) -Cut\ %0\ entry(ies)=Cut %0 entry(ies) -Deleted\ %0\ entry(ies)=Deleted %0 entry(ies) +Copied\ %0\ entry(s)=Copied %0 entry(s) +Cut\ %0\ entry(s)=Cut %0 entry(s) +Deleted\ %0\ entry(s)=Deleted %0 entry(s) Enable\ Journal\ Information\ Fetching?=Enable Journal Information Fetching? Would\ you\ like\ to\ enable\ fetching\ of\ journal\ information?\ This\ can\ be\ changed\ later\ in\ %0\ >\ %1.=Would you like to enable fetching of journal information? This can be changed later in %0 > %1. @@ -2797,3 +2803,12 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0' Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0' Store\ url\ for\ downloaded\ file=Store url for downloaded file + +Compare\ with\ existing\ entry=Compare with existing entry +Library\ Entry=Library Entry +Citation\ Entry=Citation Entry + +File\ Move\ Errors=File Move Errors +Could\ not\ move\ file\ %0.\ Please\ close\ this\ file\ and\ retry.=Could not move file %0. Please close this file and retry. + +Rename\ group = "Rename group" diff --git a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java index 283dc2cdf41..a9dfd56f2bb 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java @@ -60,6 +60,7 @@ public class JstorFetcherTest implements SearchBasedFetcherCapabilityTest { @Test void searchByTitle() throws Exception { List entries = fetcher.performSearch("title: \"Test Anxiety Analysis of Chinese College Students in Computer-based Spoken English Test\""); + System.out.println("toto tu som spustil" + entries); assertEquals(Collections.singletonList(bibEntry), entries); } From 645693b2926b4153c783e554ec8520190fc06ffd Mon Sep 17 00:00:00 2001 From: RichardD <99145695+Rydzard@users.noreply.github.com> Date: Fri, 22 Nov 2024 22:10:49 +0100 Subject: [PATCH 08/10] DeleteTest --- .../importer/fetcher/JstorFetcherTest.java | 117 ------------------ 1 file changed, 117 deletions(-) delete mode 100644 src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java diff --git a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java deleted file mode 100644 index a9dfd56f2bb..00000000000 --- a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.jabref.logic.importer.fetcher; - -import java.net.URI; -import java.net.URL; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.SearchBasedFetcher; -import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.field.StandardField; -import org.jabref.model.entry.types.StandardEntryType; -import org.jabref.support.DisabledOnCIServer; -import org.jabref.testutils.category.FetcherTest; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.mockito.Answers; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; - -@FetcherTest -@DisabledOnCIServer("CI server is blocked by JSTOR") -public class JstorFetcherTest implements SearchBasedFetcherCapabilityTest { - - private final JstorFetcher fetcher = new JstorFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); - - private final BibEntry bibEntry = new BibEntry(StandardEntryType.Article) - .withCitationKey("10.2307/90002164") - .withField(StandardField.AUTHOR, "Yang Yanxia") - .withField(StandardField.TITLE, "Test Anxiety Analysis of Chinese College Students in Computer-based Spoken English Test") - .withField(StandardField.ISSN, "11763647, 14364522") - .withField(StandardField.JOURNAL, "Journal of Educational Technology & Society") - .withField(StandardField.ABSTRACT, "ABSTRACT Test anxiety was a commonly known or assumed factor that could greatly influence performance of test takers. With the employment of designed questionnaires and computer-based spoken English test, this paper explored test anxiety manifestation of Chinese college students from both macro and micro aspects, and found out that the major anxiety in computer-based spoken English test was spoken English test anxiety, which consisted of test anxiety and communication apprehension. Regard to proximal test anxiety, the causes listed in proper order as low spoken English abilities, lack of speaking techniques, anxiety from the evaluative process and inadaptability with computer-based spoken English test format. As to distal anxiety causes, attitude toward learning spoken English and self-evaluation of speaking abilities were significantly negatively correlated with test anxiety. Besides, as test anxiety significantly associated often with test performance, a look at pedagogical implications has been discussed in this paper.") - .withField(StandardField.PUBLISHER, "International Forum of Educational Technology & Society") - .withField(StandardField.NUMBER, "2") - .withField(StandardField.PAGES, "63--73") - .withField(StandardField.VOLUME, "20") - .withField(StandardField.URL, "http://www.jstor.org/stable/90002164") - .withField(StandardField.YEAR, "2017"); - - private final BibEntry doiEntry = new BibEntry(StandardEntryType.Article) - .withCitationKey("10.1086/501484") - .withField(StandardField.AUTHOR, "Johnmarshall Reeve") - .withField(StandardField.TITLE, "Teachers as Facilitators: What Autonomy‐Supportive Teachers Do and Why Their Students Benefit") - .withField(StandardField.ISSN, "00135984, 15548279") - .withField(StandardField.JOURNAL, "The Elementary School Journal") - .withField(StandardField.ABSTRACT, "Abstract Students are sometimes proactive and engaged in classroom learning activities, but they are also sometimes only reactive and passive. Recognizing this, in this article I argue that students’ classroom engagement depends, in part, on the supportive quality of the classroom climate in which they learn. According to the dialectical framework within self‐determination theory, students possess inner motivational resources that classroom conditions can support or frustrate. When teachers find ways to nurture these inner resources, they adopt an autonomy‐supportive motivating style. After articulating what autonomy‐supportive teachers say and do during instruction, I discuss 3 points: teachers can learn how to be more autonomy supportive toward students; teachers most engage students when they offer high levels of both autonomy support and structure; and an autonomy‐supportive motivating style is an important element to a high‐quality teacher‐student relationship.") - .withField(StandardField.PUBLISHER, "The University of Chicago Press") - .withField(StandardField.NUMBER, "3") - .withField(StandardField.PAGES, "225--236") - .withField(StandardField.VOLUME, "106") - .withField(StandardField.URL, "http://www.jstor.org/stable/10.1086/501484") - .withField(StandardField.YEAR, "2006"); - - @Test - void searchByTitle() throws Exception { - List entries = fetcher.performSearch("title: \"Test Anxiety Analysis of Chinese College Students in Computer-based Spoken English Test\""); - System.out.println("toto tu som spustil" + entries); - assertEquals(Collections.singletonList(bibEntry), entries); - } - - @Test - void searchById() throws Exception { - Optional actual = fetcher.performSearchById("90002164"); - // The URL date is always the current date in the US. No need to properly check it. - actual.ifPresent(entry -> entry.clearField(StandardField.URLDATE)); - assertEquals(Optional.of(bibEntry), actual); - } - - @Test - void searchByUrlUsingId() throws Exception { - doiEntry.setField(StandardField.URLDATE, LocalDate.now().format(DateTimeFormatter.ISO_DATE)); - assertEquals(Optional.of(doiEntry), fetcher.performSearchById("https://www.jstor.org/stable/10.1086/501484?seq=1")); - } - - @Test - void fetchPDF() throws Exception { - Optional url = fetcher.findFullText(bibEntry); - assertEquals(Optional.of(URI.create("https://www.jstor.org/stable/pdf/90002164.pdf").toURL()), url); - } - - @Override - public SearchBasedFetcher getFetcher() { - return fetcher; - } - - @Override - public List getTestAuthors() { - return List.of("Haman", "Medlin"); - } - - @Override - public String getTestJournal() { - // Does not provide articles and journals - return "Test"; - } - - @Disabled("jstor does not support search only based on year") - @Override - public void supportsYearRangeSearch() throws Exception { - } - - @Disabled("jstor does not provide articles with journals") - @Override - public void supportsJournalSearch() throws Exception { - } - - @Disabled("jstor does not support search only based on year") - @Override - public void supportsYearSearch() throws Exception { - } -} From 75f84bc4376e92f8b47f61a879b405155dee0294 Mon Sep 17 00:00:00 2001 From: RichardD <99145695+Rydzard@users.noreply.github.com> Date: Fri, 22 Nov 2024 22:49:16 +0100 Subject: [PATCH 09/10] return FetcherTest --- .../importer/fetcher/JstorFetcherTest.java | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java diff --git a/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java new file mode 100644 index 00000000000..283dc2cdf41 --- /dev/null +++ b/src/test/java/org/jabref/logic/importer/fetcher/JstorFetcherTest.java @@ -0,0 +1,116 @@ +package org.jabref.logic.importer.fetcher; + +import java.net.URI; +import java.net.URL; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import org.jabref.logic.importer.ImportFormatPreferences; +import org.jabref.logic.importer.SearchBasedFetcher; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.types.StandardEntryType; +import org.jabref.support.DisabledOnCIServer; +import org.jabref.testutils.category.FetcherTest; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.mockito.Answers; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; + +@FetcherTest +@DisabledOnCIServer("CI server is blocked by JSTOR") +public class JstorFetcherTest implements SearchBasedFetcherCapabilityTest { + + private final JstorFetcher fetcher = new JstorFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); + + private final BibEntry bibEntry = new BibEntry(StandardEntryType.Article) + .withCitationKey("10.2307/90002164") + .withField(StandardField.AUTHOR, "Yang Yanxia") + .withField(StandardField.TITLE, "Test Anxiety Analysis of Chinese College Students in Computer-based Spoken English Test") + .withField(StandardField.ISSN, "11763647, 14364522") + .withField(StandardField.JOURNAL, "Journal of Educational Technology & Society") + .withField(StandardField.ABSTRACT, "ABSTRACT Test anxiety was a commonly known or assumed factor that could greatly influence performance of test takers. With the employment of designed questionnaires and computer-based spoken English test, this paper explored test anxiety manifestation of Chinese college students from both macro and micro aspects, and found out that the major anxiety in computer-based spoken English test was spoken English test anxiety, which consisted of test anxiety and communication apprehension. Regard to proximal test anxiety, the causes listed in proper order as low spoken English abilities, lack of speaking techniques, anxiety from the evaluative process and inadaptability with computer-based spoken English test format. As to distal anxiety causes, attitude toward learning spoken English and self-evaluation of speaking abilities were significantly negatively correlated with test anxiety. Besides, as test anxiety significantly associated often with test performance, a look at pedagogical implications has been discussed in this paper.") + .withField(StandardField.PUBLISHER, "International Forum of Educational Technology & Society") + .withField(StandardField.NUMBER, "2") + .withField(StandardField.PAGES, "63--73") + .withField(StandardField.VOLUME, "20") + .withField(StandardField.URL, "http://www.jstor.org/stable/90002164") + .withField(StandardField.YEAR, "2017"); + + private final BibEntry doiEntry = new BibEntry(StandardEntryType.Article) + .withCitationKey("10.1086/501484") + .withField(StandardField.AUTHOR, "Johnmarshall Reeve") + .withField(StandardField.TITLE, "Teachers as Facilitators: What Autonomy‐Supportive Teachers Do and Why Their Students Benefit") + .withField(StandardField.ISSN, "00135984, 15548279") + .withField(StandardField.JOURNAL, "The Elementary School Journal") + .withField(StandardField.ABSTRACT, "Abstract Students are sometimes proactive and engaged in classroom learning activities, but they are also sometimes only reactive and passive. Recognizing this, in this article I argue that students’ classroom engagement depends, in part, on the supportive quality of the classroom climate in which they learn. According to the dialectical framework within self‐determination theory, students possess inner motivational resources that classroom conditions can support or frustrate. When teachers find ways to nurture these inner resources, they adopt an autonomy‐supportive motivating style. After articulating what autonomy‐supportive teachers say and do during instruction, I discuss 3 points: teachers can learn how to be more autonomy supportive toward students; teachers most engage students when they offer high levels of both autonomy support and structure; and an autonomy‐supportive motivating style is an important element to a high‐quality teacher‐student relationship.") + .withField(StandardField.PUBLISHER, "The University of Chicago Press") + .withField(StandardField.NUMBER, "3") + .withField(StandardField.PAGES, "225--236") + .withField(StandardField.VOLUME, "106") + .withField(StandardField.URL, "http://www.jstor.org/stable/10.1086/501484") + .withField(StandardField.YEAR, "2006"); + + @Test + void searchByTitle() throws Exception { + List entries = fetcher.performSearch("title: \"Test Anxiety Analysis of Chinese College Students in Computer-based Spoken English Test\""); + assertEquals(Collections.singletonList(bibEntry), entries); + } + + @Test + void searchById() throws Exception { + Optional actual = fetcher.performSearchById("90002164"); + // The URL date is always the current date in the US. No need to properly check it. + actual.ifPresent(entry -> entry.clearField(StandardField.URLDATE)); + assertEquals(Optional.of(bibEntry), actual); + } + + @Test + void searchByUrlUsingId() throws Exception { + doiEntry.setField(StandardField.URLDATE, LocalDate.now().format(DateTimeFormatter.ISO_DATE)); + assertEquals(Optional.of(doiEntry), fetcher.performSearchById("https://www.jstor.org/stable/10.1086/501484?seq=1")); + } + + @Test + void fetchPDF() throws Exception { + Optional url = fetcher.findFullText(bibEntry); + assertEquals(Optional.of(URI.create("https://www.jstor.org/stable/pdf/90002164.pdf").toURL()), url); + } + + @Override + public SearchBasedFetcher getFetcher() { + return fetcher; + } + + @Override + public List getTestAuthors() { + return List.of("Haman", "Medlin"); + } + + @Override + public String getTestJournal() { + // Does not provide articles and journals + return "Test"; + } + + @Disabled("jstor does not support search only based on year") + @Override + public void supportsYearRangeSearch() throws Exception { + } + + @Disabled("jstor does not provide articles with journals") + @Override + public void supportsJournalSearch() throws Exception { + } + + @Disabled("jstor does not support search only based on year") + @Override + public void supportsYearSearch() throws Exception { + } +} From 068253ca45077b8f6c6701b16fbd536aa7204e1b Mon Sep 17 00:00:00 2001 From: RichardD <99145695+Rydzard@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:03:56 +0100 Subject: [PATCH 10/10] Update JabRef_en.properties --- src/main/resources/l10n/JabRef_en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 05dbcb02578..7db0469a8f3 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2811,4 +2811,4 @@ Citation\ Entry=Citation Entry File\ Move\ Errors=File Move Errors Could\ not\ move\ file\ %0.\ Please\ close\ this\ file\ and\ retry.=Could not move file %0. Please close this file and retry. -Rename\ group = "Rename group" +Rename\ group=Rename group