Skip to content

Commit 7fede76

Browse files
authored
EntryEditor now also shows on empty entries (#12955)
* EntryEditor now also shows on empty entries * Fix entry editor showing "random" entry * More _ for unused variables * Fix Markdown
1 parent 3dc2cfe commit 7fede76

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

docs/requirements/entry-editor.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
parent: Requirements
3+
---
4+
# Entry Editor
5+
6+
## Entry Editor should show the last entry
7+
`req~entry-editor.keep-showing~1`
8+
9+
The Entry Editor should "always" show a valid entry.
10+
11+
When users search or select a group not containing the entry shown in the Entry Editor, the Entry Editor should keep showing until user select a new entry explicitly.
12+
13+
Needs: impl
14+
15+
<!-- markdownlint-disable-file MD022 -->

src/main/java/org/jabref/gui/entryeditor/EntryEditor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,19 @@ public EntryEditor(Supplier<LibraryTab> tabSupplier, UndoAction undoAction, Redo
169169
}
170170
});
171171

172-
stateManager.getSelectedEntries().addListener((InvalidationListener) c -> {
172+
stateManager.getSelectedEntries().addListener((InvalidationListener) _ -> {
173173
if (stateManager.getSelectedEntries().isEmpty()) {
174-
setCurrentlyEditedEntry(new BibEntry());
174+
// [impl->req~entry-editor.keep-showing~1]
175+
// No change in the entry editor
176+
// We allow users to edit the "old" entry
175177
} else {
176178
setCurrentlyEditedEntry(stateManager.getSelectedEntries().getFirst());
177179
}
178180
}
179181
);
180182

181183
EasyBind.listen(preferences.getPreviewPreferences().showPreviewAsExtraTabProperty(),
182-
(obs, oldValue, newValue) -> {
184+
(_, _, newValue) -> {
183185
if (currentlyEditedEntry != null) {
184186
adaptVisibleTabs();
185187
Tab tab = tabbed.getSelectionModel().selectedItemProperty().get();
@@ -425,14 +427,12 @@ public void setCurrentlyEditedEntry(@NonNull BibEntry currentlyEditedEntry) {
425427
typeSubscription.unsubscribe();
426428
}
427429

428-
if (!currentlyEditedEntry.isEmpty()) {
429-
typeSubscription = EasyBind.subscribe(this.currentlyEditedEntry.typeProperty(), _ -> {
430-
typeLabel.setText(new TypedBibEntry(currentlyEditedEntry, tabSupplier.get().getBibDatabaseContext().getMode()).getTypeForDisplay());
431-
adaptVisibleTabs();
432-
setupToolBar();
433-
getSelectedTab().notifyAboutFocus(currentlyEditedEntry);
434-
});
435-
}
430+
typeSubscription = EasyBind.subscribe(this.currentlyEditedEntry.typeProperty(), _ -> {
431+
typeLabel.setText(new TypedBibEntry(currentlyEditedEntry, tabSupplier.get().getBibDatabaseContext().getMode()).getTypeForDisplay());
432+
adaptVisibleTabs();
433+
setupToolBar();
434+
getSelectedTab().notifyAboutFocus(currentlyEditedEntry);
435+
});
436436

437437
if (preferences.getEntryEditorPreferences().showSourceTabByDefault()) {
438438
tabbed.getSelectionModel().select(sourceTab);

0 commit comments

Comments
 (0)