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

Switching entry tabs using tab #7

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 @@ -11,6 +11,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a way to navigate through Tabs in Entry Editor by pressing "tab" when the last TextField of a Tab is in focus. [#11937](https://github.com/JabRef/jabref/issues/11937)
- We added a "view as BibTeX" option before importing an entry from the citation relation tab. [#11826](https://github.com/JabRef/jabref/issues/11826)
- We added probable search hits instead of exact matches. Sorting by hit score can be done by the new score table column. [#11542](https://github.com/JabRef/jabref/pull/11542)
- We added support finding LaTeX-encoded special characters based on plain Unicode and vice versa. [#11542](https://github.com/JabRef/jabref/pull/11542)
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.input.DataFormat;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TransferMode;
Expand All @@ -36,6 +37,7 @@
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab;
import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab;
import org.jabref.gui.externalfiles.ExternalFilesEntryLinker;
import org.jabref.gui.fieldeditors.EditorTextField;
import org.jabref.gui.help.HelpAction;
import org.jabref.gui.importer.GrobidOptInDialogHelper;
import org.jabref.gui.keyboard.KeyBinding;
Expand Down Expand Up @@ -142,6 +144,7 @@ public EntryEditor(LibraryTab libraryTab, UndoAction undoAction, RedoAction redo
this.previewTabs = this.allPossibleTabs.stream().filter(OffersPreview.class::isInstance).map(OffersPreview.class::cast).toList();

setupDragAndDrop(libraryTab);
EditorTextField.entryContext(tabbed);

EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> {
EntryEditorTab activeTab = (EntryEditorTab) tab;
Expand Down Expand Up @@ -472,4 +475,20 @@ public void nextPreviewStyle() {
public void previousPreviewStyle() {
this.previewTabs.forEach(OffersPreview::previousPreviewStyle);
}

public static boolean checkLastTextField(TabPane tabs, TextField textField) {
FieldsEditorTab currentTab = (FieldsEditorTab) tabs.getSelectionModel().getSelectedItem();
Collection<Field> shownFields = currentTab.getShownFields();
Field lastField = null;
for (Field field : shownFields) {
lastField = field;
}
if (textField != null && lastField != null) {
if (textField.getId() == null) {
return false;
}
return lastField.getDisplayName().equalsIgnoreCase(textField.getId());
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public CitationKeyEditor(Field field,
undoManager,
dialogService);

textField.setId(field.getDisplayName());
establishBinding(textField, viewModel.textProperty(), keyBindingRepository, undoAction, redoAction);
textField.initContextMenu(Collections::emptyList, keyBindingRepository);
new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,34 @@
import javafx.fxml.Initializable;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.fieldeditors.contextmenu.EditorContextAction;
import org.jabref.gui.keyboard.KeyBindingRepository;

public class EditorTextField extends TextField implements Initializable, ContextMenuAddable {

public static TabPane tabs;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.DeclarationOrderCheck> reported by reviewdog 🐶
Static variable definition in wrong order.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plz check the styling

private final ContextMenu contextMenu = new ContextMenu();
private Runnable additionalPasteActionHandler = () -> {
// No additional paste behavior
};

public EditorTextField() {
this("");
this.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
String keyText = event.getText();
if ("\t".equals(keyText) && EntryEditor.checkLastTextField(tabs, this)) {
tabs.getSelectionModel().selectNext();
event.consume();
}
});
}

public EditorTextField(final String text) {
Expand All @@ -38,6 +49,10 @@ public EditorTextField(final String text) {
ClipBoardManager.addX11Support(this);
}

public static void entryContext(TabPane tab) {
tabs = tab;
}

@Override
public void initContextMenu(final Supplier<List<MenuItem>> items, KeyBindingRepository keyBindingRepository) {
setOnContextMenuRequested(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public MarkdownEditor(Field field, SuggestionProvider<?> suggestionProvider, Fie
}

@Override
protected TextInputControl createTextInputControl() {
protected TextInputControl createTextInputControl(Field field) {
return new EditorTextArea() {
@Override
public void paste() {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ public PersonsEditor(final Field field,
KeyBindingRepository keyBindingRepository = preferences.getKeyBindingRepository();

this.viewModel = new PersonsEditorViewModel(field, suggestionProvider, preferences.getAutoCompletePreferences(), fieldCheckers, undoManager);
textInput = isMultiLine ? new EditorTextArea() : new EditorTextField();
textInput = isMultiLine
? new EditorTextArea()
: new EditorTextField();

textInput.setId(field.getName());
decoratedStringProperty = new UiThreadStringProperty(viewModel.textProperty());
establishBinding(textInput, decoratedStringProperty, keyBindingRepository, undoAction, redoAction);
((ContextMenuAddable) textInput).initContextMenu(EditorMenus.getNameMenu(textInput), keyBindingRepository);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/jabref/gui/fieldeditors/SimpleEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SimpleEditor(final Field field,
this.viewModel = new SimpleEditorViewModel(field, suggestionProvider, fieldCheckers, undoManager);
this.isMultiLine = isMultiLine;

textInput = createTextInputControl();
textInput = createTextInputControl(field);
HBox.setHgrow(textInput, Priority.ALWAYS);

establishBinding(textInput, viewModel.textProperty(), preferences.getKeyBindingRepository(), undoAction, redoAction);
Expand All @@ -54,8 +54,10 @@ public SimpleEditor(final Field field,
new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textInput);
}

protected TextInputControl createTextInputControl() {
return isMultiLine ? new EditorTextArea() : new EditorTextField();
protected TextInputControl createTextInputControl(Field field) {
TextInputControl inputControl = isMultiLine ? new EditorTextArea() : new EditorTextField();
inputControl.setId(field.getName());
return inputControl;
}

@Override
Expand Down
Loading