diff --git a/CHANGELOG.md b/CHANGELOG.md index eecbaff3814..4efb45787a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We grouped and reordered the Main Menu (File, Edit, Library, Quality, Tools, and View tabs & icons). [#4666](https://github.com/JabRef/jabref/issues/4666) [#4667](https://github.com/JabRef/jabref/issues/4667) [#4668](https://github.com/JabRef/jabref/issues/4668) [#4669](https://github.com/JabRef/jabref/issues/4669) [#4670](https://github.com/JabRef/jabref/issues/4670) [#4671](https://github.com/JabRef/jabref/issues/4671) [#4672](https://github.com/JabRef/jabref/issues/4672) [#4673](https://github.com/JabRef/jabref/issues/4673) - We added additional modifiers (capitalize, titlecase and sentencecase) to the Bibtex key generator. [#1506](https://github.com/JabRef/jabref/issues/1506) - We grouped the toolbar icons and changed the Open Library and Copy icons. [#4584](https://github.com/JabRef/jabref/issues/4584) +- We added a browse button next to the path text field for aux-based groups. [#4586](https://github.com/JabRef/jabref/issues/4586) ### Fixed diff --git a/src/main/java/org/jabref/gui/groups/GroupDialog.java b/src/main/java/org/jabref/gui/groups/GroupDialog.java index 16b8601a8dd..9859213c926 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialog.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialog.java @@ -13,6 +13,7 @@ import javafx.geometry.Insets; import javafx.geometry.Orientation; import javafx.scene.Node; +import javafx.scene.control.Button; import javafx.scene.control.ButtonType; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -24,6 +25,7 @@ import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.text.Font; @@ -33,13 +35,16 @@ import org.jabref.Globals; import org.jabref.JabRefGUI; -import org.jabref.gui.JabRefFrame; +import org.jabref.gui.BasePanel; +import org.jabref.gui.DialogService; import org.jabref.gui.search.rules.describer.SearchDescribers; import org.jabref.gui.util.BaseDialog; +import org.jabref.gui.util.FileDialogConfiguration; import org.jabref.gui.util.TooltipTextUtil; import org.jabref.logic.auxparser.DefaultAuxParser; import org.jabref.logic.l10n.Localization; import org.jabref.logic.search.SearchQuery; +import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.FieldName; import org.jabref.model.entry.Keyword; @@ -83,6 +88,8 @@ class GroupDialog extends BaseDialog { private final RadioButton independentButton = new RadioButton(Localization.lang("Independent group: When selected, view only this group's entries")); private final RadioButton intersectionButton = new RadioButton(Localization.lang("Refine supergroup: When selected, view entries contained in both this group and its supergroup")); private final RadioButton unionButton = new RadioButton(Localization.lang("Include subgroups: When selected, view entries contained in this group or its subgroups")); + private final DialogService dialogService; + private final JabRefPreferences prefs; // for KeywordGroup private final TextField keywordGroupSearchTerm = new TextField(); @@ -105,6 +112,8 @@ class GroupDialog extends BaseDialog { // for TexGroup private final TextField texGroupFilePath = new TextField(); + private final Button texGroupBrowseButton = new Button("Browse"); + private final HBox texGroupHBox = new HBox(10); // for all types private final TextFlow descriptionTextFlow = new TextFlow(); @@ -118,7 +127,7 @@ class GroupDialog extends BaseDialog { * @param editedGroup The group being edited, or null if a new group is to be * created. */ - public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) { + public GroupDialog(DialogService dialogService, BasePanel basePanel, JabRefPreferences prefs, AbstractGroup editedGroup) { this.setTitle(Localization.lang("Edit group")); explicitRadioButton.setSelected(true); @@ -128,8 +137,11 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) { descriptionTextFlow.setMinHeight(180); descriptionTextFlow.setPrefHeight(180); + this.dialogService = dialogService; + this.prefs = prefs; + // set default values (overwritten if editedGroup != null) - keywordGroupSearchField.setText(jabrefFrame.prefs().get(JabRefPreferences.GROUPS_DEFAULT_FIELD)); + keywordGroupSearchField.setText(prefs.get(JabRefPreferences.GROUPS_DEFAULT_FIELD)); // configure elements ToggleGroup groupType = new ToggleGroup(); @@ -261,11 +273,10 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) { if (explicitRadioButton.isSelected()) { Character keywordDelimiter = Globals.prefs.getKeywordDelimiter(); if (groupName.contains(Character.toString(keywordDelimiter))) { - jabrefFrame.showMessage( - Localization.lang("The group name contains the keyword separator \"%0\" and thus probably does not work as expected.", Character.toString(keywordDelimiter))); + dialogService.showWarningDialogAndWait(null, Localization.lang("The group name contains the keyword separator \"%0\" and thus probably does not work as expected.", Character.toString(keywordDelimiter))); } - Optional rootGroup = jabrefFrame.getCurrentBasePanel().getBibDatabaseContext().getMetaData().getGroups(); + Optional rootGroup = basePanel.getBibDatabaseContext().getMetaData().getGroups(); if (rootGroup.isPresent()) { int groupsWithSameName = rootGroup.get().findChildrenSatisfying(group -> group.getName().equals(groupName)).size(); boolean warnAboutSameName = false; @@ -279,8 +290,7 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) { } if (warnAboutSameName) { - jabrefFrame.showMessage( - Localization.lang("There exists already a group with the same name.", Character.toString(keywordDelimiter))); + dialogService.showErrorDialogAndWait(Localization.lang("There exists already a group with the same name.", Character.toString(keywordDelimiter))); return null; } } @@ -323,7 +333,7 @@ groupName, getContext(), resultingGroup.setIconName(iconField.getText()); return resultingGroup; } catch (IllegalArgumentException | IOException exception) { - jabrefFrame.showMessage(exception.getLocalizedMessage()); + dialogService.showErrorDialogAndWait(exception.getLocalizedMessage(), exception); return null; } } @@ -404,12 +414,12 @@ groupName, getContext(), getDialogPane().getScene().getWindow().sizeToScene(); } - public GroupDialog() { - this(JabRefGUI.getMainFrame(), null); + public GroupDialog(DialogService dialogService) { + this(dialogService, JabRefGUI.getMainFrame().getCurrentBasePanel(), Globals.prefs, null); } - public GroupDialog(AbstractGroup editedGroup) { - this(JabRefGUI.getMainFrame(), editedGroup); + public GroupDialog(DialogService dialogService, AbstractGroup editedGroup) { + this(dialogService, JabRefGUI.getMainFrame().getCurrentBasePanel(), Globals.prefs, editedGroup); } private static String formatRegExException(String regExp, Exception e) { @@ -442,7 +452,11 @@ private VBox createOptionsTexGroup() { VBox texPanel = new VBox(); texPanel.setVisible(false); texPanel.getChildren().add(new Label(Localization.lang("Aux file"))); - texPanel.getChildren().add(texGroupFilePath); + texGroupBrowseButton.setOnAction((ActionEvent e) -> openBrowseDialog()); + texGroupHBox.getChildren().add(texGroupFilePath); + texGroupHBox.getChildren().add(texGroupBrowseButton); + texGroupHBox.setHgrow(texGroupFilePath, Priority.ALWAYS); + texPanel.getChildren().add(texGroupHBox); return texPanel; } @@ -586,6 +600,14 @@ private void updateComponents() { getDialogPane().lookupButton(ButtonType.OK).setDisable(!okEnabled); } + private void openBrowseDialog() { + FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() + .addExtensionFilter(StandardFileType.AUX) + .withDefaultExtension(StandardFileType.AUX) + .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build(); + dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> texGroupFilePath.setText(file.toAbsolutePath().toString())); + } + private String fromTextFlowToHTMLString(TextFlow textFlow) { StringBuilder htmlStringBuilder = new StringBuilder(); for (Node node : textFlow.getChildren()) { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index de4c279e59c..bccddf297e5 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -141,7 +141,7 @@ private void onActiveDatabaseChanged(Optional newDatabase) { * Opens "New Group Dialog" and add the resulting group to the specified group */ public void addNewSubgroup(GroupNodeViewModel parent) { - Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialog()); + Optional newGroup = dialogService.showCustomDialogAndWait(new GroupDialog(dialogService)); newGroup.ifPresent(group -> { parent.addSubgroup(group); @@ -166,7 +166,7 @@ private void writeGroupChangesToMetaData() { */ public void editGroup(GroupNodeViewModel oldGroup) { Optional newGroup = dialogService - .showCustomDialogAndWait(new GroupDialog(oldGroup.getGroupNode().getGroup())); + .showCustomDialogAndWait(new GroupDialog(dialogService, oldGroup.getGroupNode().getGroup())); newGroup.ifPresent(group -> { // TODO: Keep assignments boolean keepPreviousAssignments = dialogService.showConfirmationDialogAndWait(