|
3 | 3 | import java.io.File; |
4 | 4 | import java.nio.file.Path; |
5 | 5 | import java.util.ArrayList; |
6 | | -import java.util.Collection; |
7 | 6 | import java.util.HashMap; |
8 | 7 | import java.util.LinkedList; |
9 | 8 | import java.util.List; |
|
19 | 18 | import javafx.beans.InvalidationListener; |
20 | 19 | import javafx.fxml.FXML; |
21 | 20 | import javafx.geometry.Side; |
22 | | -import javafx.scene.Node; |
23 | | -import javafx.scene.Parent; |
24 | 21 | import javafx.scene.control.Button; |
25 | 22 | import javafx.scene.control.ContextMenu; |
26 | 23 | import javafx.scene.control.Label; |
27 | 24 | import javafx.scene.control.MenuItem; |
28 | 25 | import javafx.scene.control.Tab; |
29 | 26 | import javafx.scene.control.TabPane; |
30 | | -import javafx.scene.control.TextField; |
31 | | -import javafx.scene.control.TextInputControl; |
32 | 27 | import javafx.scene.input.DataFormat; |
33 | 28 | import javafx.scene.input.KeyEvent; |
34 | 29 | import javafx.scene.input.TransferMode; |
|
43 | 38 | import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab; |
44 | 39 | import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab; |
45 | 40 | import org.jabref.gui.externalfiles.ExternalFilesEntryLinker; |
46 | | -import org.jabref.gui.fieldeditors.EditorTextField; |
47 | 41 | import org.jabref.gui.help.HelpAction; |
48 | 42 | import org.jabref.gui.importer.GrobidUseDialogHelper; |
49 | 43 | import org.jabref.gui.keyboard.KeyBinding; |
@@ -169,11 +163,6 @@ public EntryEditor(Supplier<LibraryTab> tabSupplier, UndoAction undoAction, Redo |
169 | 163 |
|
170 | 164 | setupDragAndDrop(); |
171 | 165 |
|
172 | | - EditorTextField.setupTabNavigation( |
173 | | - this::isLastFieldInCurrentTab, |
174 | | - this::moveToNextTabAndFocus |
175 | | - ); |
176 | | - |
177 | 166 | EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> { |
178 | 167 | EntryEditorTab activeTab = (EntryEditorTab) tab; |
179 | 168 | if (activeTab != null) { |
@@ -539,98 +528,4 @@ public void nextPreviewStyle() { |
539 | 528 | public void previousPreviewStyle() { |
540 | 529 | this.previewPanel.previousPreviewStyle(); |
541 | 530 | } |
542 | | - |
543 | | - /** |
544 | | - * Checks if the given TextField is the last field in the currently selected tab. |
545 | | - * |
546 | | - * @param textField the TextField to check |
547 | | - * @return true if this is the last field in the current tab, false otherwise |
548 | | - */ |
549 | | - private boolean isLastFieldInCurrentTab(TextField textField) { |
550 | | - if (textField == null || tabbed.getSelectionModel().getSelectedItem() == null) { |
551 | | - return false; |
552 | | - } |
553 | | - |
554 | | - Tab selectedTab = tabbed.getSelectionModel().getSelectedItem(); |
555 | | - if (!(selectedTab instanceof FieldsEditorTab currentTab)) { |
556 | | - return false; |
557 | | - } |
558 | | - |
559 | | - Collection<Field> shownFields = currentTab.getShownFields(); |
560 | | - if (shownFields.isEmpty() || textField.getId() == null) { |
561 | | - return false; |
562 | | - } |
563 | | - |
564 | | - Optional<Field> lastField = shownFields.stream() |
565 | | - .reduce((first, second) -> second); |
566 | | - |
567 | | - return lastField.map(Field::getDisplayName) |
568 | | - .map(displayName -> displayName.equalsIgnoreCase(textField.getId())) |
569 | | - .orElse(false); |
570 | | - } |
571 | | - |
572 | | - /** |
573 | | - * Moves to the next tab and focuses on its first field. |
574 | | - */ |
575 | | - private void moveToNextTabAndFocus() { |
576 | | - tabbed.getSelectionModel().selectNext(); |
577 | | - |
578 | | - UiTaskExecutor.runInJavaFXThread(() -> { |
579 | | - Tab selectedTab = tabbed.getSelectionModel().getSelectedItem(); |
580 | | - if (selectedTab instanceof FieldsEditorTab currentTab) { |
581 | | - focusFirstFieldInTab(currentTab); |
582 | | - } |
583 | | - }); |
584 | | - } |
585 | | - |
586 | | - private void focusFirstFieldInTab(FieldsEditorTab tab) { |
587 | | - Node tabContent = tab.getContent(); |
588 | | - if (tabContent instanceof Parent parent) { |
589 | | - // First try to find field by ID (preferred method) |
590 | | - Collection<Field> shownFields = tab.getShownFields(); |
591 | | - if (!shownFields.isEmpty()) { |
592 | | - Field firstField = shownFields.iterator().next(); |
593 | | - String firstFieldId = firstField.getDisplayName(); |
594 | | - Optional<TextInputControl> firstTextInput = findTextInputById(parent, firstFieldId); |
595 | | - if (firstTextInput.isPresent()) { |
596 | | - firstTextInput.get().requestFocus(); |
597 | | - return; |
598 | | - } |
599 | | - } |
600 | | - |
601 | | - Optional<TextInputControl> anyTextInput = findAnyTextInput(parent); |
602 | | - if (anyTextInput.isPresent()) { |
603 | | - anyTextInput.get().requestFocus(); |
604 | | - } |
605 | | - } |
606 | | - } |
607 | | - |
608 | | - /// Recursively searches for a TextInputControl (TextField or TextArea) with the given ID. |
609 | | - private Optional<TextInputControl> findTextInputById(Parent parent, String id) { |
610 | | - for (Node child : parent.getChildrenUnmodifiable()) { |
611 | | - if (child instanceof TextInputControl textInput && id.equalsIgnoreCase(textInput.getId())) { |
612 | | - return Optional.of(textInput); |
613 | | - } else if (child instanceof Parent childParent) { |
614 | | - Optional<TextInputControl> found = findTextInputById(childParent, id); |
615 | | - if (found.isPresent()) { |
616 | | - return found; |
617 | | - } |
618 | | - } |
619 | | - } |
620 | | - return Optional.empty(); |
621 | | - } |
622 | | - |
623 | | - private Optional<TextInputControl> findAnyTextInput(Parent parent) { |
624 | | - for (Node child : parent.getChildrenUnmodifiable()) { |
625 | | - if (child instanceof TextInputControl textInput) { |
626 | | - return Optional.of(textInput); |
627 | | - } else if (child instanceof Parent childParent) { |
628 | | - Optional<TextInputControl> found = findAnyTextInput(childParent); |
629 | | - if (found.isPresent()) { |
630 | | - return found; |
631 | | - } |
632 | | - } |
633 | | - } |
634 | | - return Optional.empty(); |
635 | | - } |
636 | 531 | } |
0 commit comments