-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Feat/field jumping 12276 #14120
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
Open
ZachCraw
wants to merge
18
commits into
JabRef:main
Choose a base branch
from
ZachCraw:feat/field_jumping_12276
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−11
Open
Feat/field jumping 12276 #14120
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3f5ce74
feat(JabRef #12276): Adding in Keybind enum for JUMP_TO_FIELD
ZachCraw 383e22f
feat(JabRef #12276): Initialising JumpToField command
ZachCraw cf9cdc7
docs(JabRef #12276): Adding in english localisation for JUMP to FIELD…
ZachCraw fbda3f4
feat(JabRef #12276): Creating base fxml for JUMP to field box
ZachCraw 0755740
feat(JabRef #12276): FXML action class to search through loaded fields
ZachCraw 84529b8
feat(JabRef #12276): Class to extract fieldNames for comparison and a…
ZachCraw 848ff0b
feat(JabRef #12276): Implementing field search handling within entryE…
ZachCraw fb5f482
Merge branch 'JabRef:main' into feat/field_jumping_12276
ZachCraw d188809
docs(JabRef #12276): Explained addition in CHANGELOG.md
ZachCraw ae000fc
Merge branch 'feat/field_jumping_12276' of https://github.com/ZachCra…
ZachCraw ff0e43f
docs(JabRef #12276): Fixing missing blank line in CHANGELOG
ZachCraw fc798a2
fix(JabRef #12276): Reverting docs deletion to include implementation…
ZachCraw 60c494b
fix(JabRef #12276): Fixing frame focusing and scene hierarchy.
ZachCraw d5c4405
fix(JabRef #12276): Removing necessary initialisation.
ZachCraw 0dffbf0
Merge branch 'main' into feat/field_jumping_12276
ZachCraw 57da947
docs(JabRef #12276): Changing function names to reflect "select" patt…
ZachCraw 27e03f6
Merge branch 'feat/field_jumping_12276' of https://github.com/ZachCra…
ZachCraw fbcb65a
Merge branch 'main' into feat/field_jumping_12276
ZachCraw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
jabgui/src/main/java/org/jabref/gui/entryeditor/JumpToFieldDialog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package org.jabref.gui.entryeditor; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.fxml.FXML; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.ButtonType; | ||
| import javafx.scene.control.TextField; | ||
|
|
||
| import org.jabref.gui.util.BaseDialog; | ||
| import org.jabref.logic.l10n.Localization; | ||
|
|
||
| import com.airhacks.afterburner.views.ViewLoader; | ||
| import org.controlsfx.control.textfield.TextFields; | ||
|
|
||
| public class JumpToFieldDialog extends BaseDialog<Void> { | ||
| @FXML private TextField searchField; | ||
| private final EntryEditor entryEditor; | ||
| private JumpToFieldViewModel viewModel; | ||
|
|
||
| public JumpToFieldDialog(EntryEditor entryEditor) { | ||
| this.entryEditor = entryEditor; | ||
| this.setTitle(Localization.lang("Jump to field")); | ||
|
|
||
| ViewLoader.view(this) | ||
| .load() | ||
| .setAsDialogPane(this); | ||
|
|
||
| this.getDialogPane().getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); | ||
|
|
||
| this.setResultConverter(button -> { | ||
| if (button == ButtonType.OK) { | ||
| jumpToSelectedField(); | ||
| } | ||
| return null; | ||
| }); | ||
|
|
||
| Platform.runLater(() -> searchField.requestFocus()); | ||
| } | ||
|
|
||
| @FXML | ||
| private void initialize() { | ||
| viewModel = new JumpToFieldViewModel(this.entryEditor); | ||
| searchField.textProperty().bindBidirectional(viewModel.searchTextProperty()); | ||
| TextFields.bindAutoCompletion(searchField, viewModel.getFieldNames()); | ||
|
|
||
| searchField.setOnAction(event -> { | ||
| Button okButton = (Button) getDialogPane().lookupButton(ButtonType.OK); | ||
| if (okButton != null) { | ||
| okButton.fire(); | ||
| } | ||
| event.consume(); | ||
| }); | ||
| } | ||
|
|
||
| private void jumpToSelectedField() { | ||
| String selectedField = searchField.getText(); | ||
|
|
||
| if (selectedField != null && !selectedField.isEmpty()) { | ||
| String fieldToJumpTo = selectedField.toLowerCase(); | ||
| entryEditor.selectField(fieldToJumpTo); | ||
| } | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
jabgui/src/main/java/org/jabref/gui/entryeditor/JumpToFieldViewModel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package org.jabref.gui.entryeditor; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import javafx.beans.property.SimpleStringProperty; | ||
| import javafx.beans.property.StringProperty; | ||
|
|
||
| import org.jabref.gui.AbstractViewModel; | ||
| import org.jabref.model.entry.field.Field; | ||
|
|
||
| public class JumpToFieldViewModel extends AbstractViewModel { | ||
|
|
||
| private final StringProperty searchText = new SimpleStringProperty(""); | ||
| private final EntryEditor entryEditor; | ||
|
|
||
| public JumpToFieldViewModel(EntryEditor entryEditor) { | ||
| this.entryEditor = entryEditor; | ||
| } | ||
|
|
||
| public StringProperty searchTextProperty() { | ||
| return searchText; | ||
| } | ||
|
|
||
| public List<String> getFieldNames() { | ||
| if (entryEditor.getCurrentlyEditedEntry() == null) { | ||
| return Collections.emptyList(); | ||
| } | ||
|
|
||
| List<String> fieldNames = entryEditor.getAllPossibleTabs().stream() | ||
| .filter(FieldsEditorTab.class::isInstance) | ||
| .map(FieldsEditorTab.class::cast) | ||
| .flatMap(tab -> tab.getShownFields().stream()) | ||
| .map(Field::getName) | ||
| .distinct() | ||
| .sorted() | ||
| .collect(Collectors.toList()); | ||
| return fieldNames; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
jabgui/src/main/resources/org/jabref/gui/entryeditor/JumpToFieldDialog.fxml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <?import javafx.scene.control.DialogPane?> | ||
| <?import javafx.scene.control.TextField?> | ||
| <?import javafx.scene.layout.VBox?> | ||
|
|
||
| <DialogPane prefWidth="300" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" | ||
| fx:controller="org.jabref.gui.entryeditor.JumpToFieldDialog"> | ||
| <content> | ||
| <VBox> | ||
| <TextField fx:id="searchField" promptText="%Type a field name"/> | ||
| </VBox> | ||
| </content> | ||
| </DialogPane> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep this as it referes to implementation spec