Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a browse button next to the path text field for aux-based groups #4743

Merged
merged 6 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 24 additions & 3 deletions src/main/java/org/jabref/gui/groups/GroupDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -33,13 +35,16 @@

import org.jabref.Globals;
import org.jabref.JabRefGUI;
import org.jabref.gui.DialogService;
import org.jabref.gui.JabRefFrame;
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;
Expand Down Expand Up @@ -105,6 +110,8 @@ class GroupDialog extends BaseDialog<AbstractGroup> {

// 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();
Expand Down Expand Up @@ -145,7 +152,7 @@ public GroupDialog(JabRefFrame jabrefFrame, AbstractGroup editedGroup) {
VBox keywordPanel = createOptionsKeywordGroup();
VBox searchPanel = createOptionsSearchGroup();
VBox autoPanel = createOptionsAutoGroup();
VBox texPanel = createOptionsTexGroup();
VBox texPanel = createOptionsTexGroup(jabrefFrame);
optionsPanel.getChildren().addAll(explicitPanel, keywordPanel, searchPanel, autoPanel, texPanel);
optionsPanel.setPadding(new Insets(0, 0, 0, 10));

Expand Down Expand Up @@ -438,11 +445,16 @@ private static String formatRegExException(String regExp, Exception e) {
return s;
}

private VBox createOptionsTexGroup() {
private VBox createOptionsTexGroup(JabRefFrame jabRefFrame) {
samiyac marked this conversation as resolved.
Show resolved Hide resolved
VBox texPanel = new VBox();
texPanel.setVisible(false);
texPanel.getChildren().add(new Label(Localization.lang("Aux file")));
texPanel.getChildren().add(texGroupFilePath);
EventHandler<ActionEvent> actionHandler = (ActionEvent e) -> openBrowseDialog(jabRefFrame);
texGroupBrowseButton.setOnAction(actionHandler);
samiyac marked this conversation as resolved.
Show resolved Hide resolved
texGroupHBox.getChildren().add(texGroupFilePath);
texGroupHBox.getChildren().add(texGroupBrowseButton);
texGroupHBox.setHgrow(texGroupFilePath, Priority.ALWAYS);
texPanel.getChildren().add(texGroupHBox);
return texPanel;
}

Expand Down Expand Up @@ -586,6 +598,15 @@ private void updateComponents() {
getDialogPane().lookupButton(ButtonType.OK).setDisable(!okEnabled);
}

private void openBrowseDialog(JabRefFrame jabRefFrame) {
samiyac marked this conversation as resolved.
Show resolved Hide resolved
DialogService dialogService = jabRefFrame.getDialogService();
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()) {
Expand Down