Skip to content

Commit ad813ad

Browse files
committed
2 parents eea1b37 + 92cc09d commit ad813ad

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
2222
- We added `--provider=crossref` to `get-cited-works` at `JabKit`. [#14357](https://github.com/JabRef/jabref/pull/14357)
2323
- We added [unpaywall](https://unpaywall.org/) as fulltext fetcher. [#14340](https://github.com/JabRef/jabref/pull/14340)
2424
- We added the possibility to configure the email provided to unpaywall. [#14340](https://github.com/JabRef/jabref/pull/14340)
25+
- We added "Close library" to the File menu. [#14381](https://github.com/JabRef/jabref/issues/14381)
2526
- We added a "Regenerate" button for the AI chat allowing the user to make the language model reformulate its response to the previous prompt. [#12191](https://github.com/JabRef/jabref/issues/12191)
2627
- We added support for transliteration of fields to English and automatic transliteration of generated citation key. [#11377](https://github.com/JabRef/jabref/issues/11377)
2728

jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ private void addToImportEntriesGroup(List<BibEntry> entriesToInsert) {
522522
.flatMap(grp -> grp.getChildren()
523523
.stream()
524524
.filter(node -> node.getGroup() instanceof ExplicitGroup
525-
&& node.getGroup().getName().equals(groupName))
525+
&& node.getGroup().getName().equals(groupName))
526526
.findFirst())
527527
.ifPresent(importGroup -> importGroup.addEntriesToGroup(entriesToInsert));
528528
}

jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,13 @@ private void updateEditorPane() {
301301

302302
public void updateHorizontalDividerPosition() {
303303
if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) {
304-
horizontalSplit.setDividerPositions(preferences.getGuiPreferences().getHorizontalDividerPosition() / horizontalSplit.getWidth());
304+
horizontalSplit.setDividerPositions(preferences.getGuiPreferences()
305+
.getHorizontalDividerPosition() / horizontalSplit.getWidth());
305306
horizontalDividerSubscription = EasyBind.valueAt(horizontalSplit.getDividers(), 0)
306307
.mapObservable(SplitPane.Divider::positionProperty)
307-
.listenToValues((_, newValue) -> preferences.getGuiPreferences().setHorizontalDividerPosition(newValue.doubleValue()));
308+
.listenToValues((_, newValue) ->
309+
preferences.getGuiPreferences()
310+
.setHorizontalDividerPosition(newValue.doubleValue()));
308311
}
309312
}
310313

@@ -313,7 +316,9 @@ public void updateVerticalDividerPosition() {
313316
verticalSplit.setDividerPositions(preferences.getGuiPreferences().getVerticalDividerPosition());
314317
verticalDividerSubscription = EasyBind.valueAt(verticalSplit.getDividers(), 0)
315318
.mapObservable(SplitPane.Divider::positionProperty)
316-
.listenToValues((_, newValue) -> preferences.getGuiPreferences().setVerticalDividerPosition(newValue.doubleValue()));
319+
.listenToValues((_, newValue) ->
320+
preferences.getGuiPreferences()
321+
.setVerticalDividerPosition(newValue.doubleValue()));
317322
}
318323
}
319324

@@ -436,7 +441,9 @@ private void initBindings() {
436441
String activeUID = stateManager.getActiveDatabase().get().getUid();
437442
boolean wasClosed = tabbedPane.getTabs().stream()
438443
.filter(tab -> tab instanceof LibraryTab)
439-
.noneMatch(ltab -> ((LibraryTab) ltab).getBibDatabaseContext().getUid().equals(activeUID));
444+
.noneMatch(ltab -> ((LibraryTab) ltab).getBibDatabaseContext()
445+
.getUid()
446+
.equals(activeUID));
440447
if (wasClosed) {
441448
tabbedPane.getSelectionModel().selectNext();
442449
}
@@ -454,6 +461,7 @@ private void initBindings() {
454461
BindingsHelper.bindBidirectional((ObservableValue<Boolean>) stateManager.getEditorShowing(), panelMode,
455462
mode -> stateManager.getEditorShowing().setValue(mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR),
456463
showing -> panelMode.setValue(showing ? PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR : PanelMode.MAIN_TABLE));
464+
457465
EasyBind.subscribe(panelMode, mode -> {
458466
updateEditorPane();
459467
if (mode == PanelMode.MAIN_TABLE_AND_ENTRY_EDITOR) {
@@ -545,8 +553,7 @@ public void showWelcomeTab() {
545553
taskExecutor,
546554
fileHistory,
547555
Injector.instantiateModelOrService(BuildInfo.class),
548-
preferences.getWorkspacePreferences()
549-
);
556+
preferences.getWorkspacePreferences());
550557
tabbedPane.getTabs().add(welcomeTab);
551558
tabbedPane.getSelectionModel().select(welcomeTab);
552559
}
@@ -588,16 +595,21 @@ private ContextMenu createTabContextMenuFor(LibraryTab tab) {
588595
ActionFactory factory = new ActionFactory();
589596

590597
contextMenu.getItems().addAll(
591-
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(tab::getBibDatabaseContext, stateManager)),
592-
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(dialogService, stateManager, preferences, tab::getBibDatabaseContext)),
593-
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(() -> {
594-
LibraryTab currentTab = getCurrentLibraryTab();
595-
return (currentTab == null) ? null : currentTab.getBibDatabaseContext();
596-
}, stateManager, preferences, dialogService)),
598+
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES,
599+
new LibraryPropertiesAction(tab::getBibDatabaseContext, stateManager)),
600+
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER,
601+
new OpenDatabaseFolder(dialogService, stateManager, preferences, tab::getBibDatabaseContext)),
602+
factory.createMenuItem(StandardActions.OPEN_CONSOLE,
603+
new OpenConsoleAction(() -> {
604+
LibraryTab currentTab = getCurrentLibraryTab();
605+
return (currentTab == null) ? null : currentTab.getBibDatabaseContext();
606+
}, stateManager, preferences, dialogService)),
597607
new SeparatorMenuItem(),
598-
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(this, tab, stateManager)),
599-
factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES, new CloseOthersDatabaseAction(tab)),
600-
factory.createMenuItem(StandardActions.CLOSE_ALL_LIBRARIES, new CloseAllDatabaseAction()));
608+
factory.createMenuItem(StandardActions.CLOSE_LIBRARY,
609+
new CloseDatabaseAction(this, tab, stateManager)),
610+
factory.createMenuItem(StandardActions.CLOSE_OTHER_LIBRARIES,
611+
new CloseOthersDatabaseAction(tab))
612+
);
601613

602614
return contextMenu;
603615
}
@@ -741,7 +753,7 @@ public void execute() {
741753
}
742754
}
743755

744-
private class CloseOthersDatabaseAction extends SimpleCommand {
756+
protected class CloseOthersDatabaseAction extends SimpleCommand {
745757

746758
private final LibraryTab libraryTab;
747759

@@ -753,22 +765,13 @@ public CloseOthersDatabaseAction(LibraryTab libraryTab) {
753765
@Override
754766
public void execute() {
755767
LibraryTab toKeepLibraryTab = Optional.of(libraryTab).get();
756-
for (Tab tab : tabbedPane.getTabs()) {
757-
LibraryTab libraryTab = (LibraryTab) tab;
758-
if (libraryTab != toKeepLibraryTab) {
759-
Platform.runLater(() -> closeTab(libraryTab));
760-
}
761-
}
762-
}
763-
}
764-
765-
private class CloseAllDatabaseAction extends SimpleCommand {
766-
767-
@Override
768-
public void execute() {
769-
tabbedPane.getTabs().removeIf(t -> t instanceof WelcomeTab);
770-
for (Tab tab : tabbedPane.getTabs()) {
771-
Platform.runLater(() -> closeTab((LibraryTab) tab));
768+
List<LibraryTab> libraryTabs = tabbedPane.getTabs().stream()
769+
.filter(LibraryTab.class::isInstance)
770+
.map(LibraryTab.class::cast)
771+
.filter(tab -> tab != toKeepLibraryTab)
772+
.toList();
773+
for (LibraryTab tab : libraryTabs) {
774+
Platform.runLater(() -> closeTab(tab));
772775
}
773776
}
774777
}

jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private void createMenu() {
170170
factory.createMenuItem(StandardActions.SAVE_LIBRARY, new SaveAction(SaveAction.SaveMethod.SAVE, frame::getCurrentLibraryTab, dialogService, preferences, stateManager)),
171171
factory.createMenuItem(StandardActions.SAVE_LIBRARY_AS, new SaveAction(SaveAction.SaveMethod.SAVE_AS, frame::getCurrentLibraryTab, dialogService, preferences, stateManager)),
172172
factory.createMenuItem(StandardActions.SAVE_ALL, new SaveAllAction(frame::getLibraryTabs, preferences, dialogService, stateManager)),
173+
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new JabRefFrame.CloseDatabaseAction(frame, stateManager)),
173174

174175
new SeparatorMenuItem(),
175176

jablib/src/main/java/org/jabref/logic/exporter/GroupSerializer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ private static String serializeAllEntriesGroup() {
2525
return MetadataSerializationConfiguration.ALL_ENTRIES_GROUP_ID;
2626
}
2727

28-
2928
private String serializeExplicitGroup(ExplicitGroup group) {
3029
StringBuilder sb = new StringBuilder();
3130
sb.append(MetadataSerializationConfiguration.EXPLICIT_GROUP_ID);

0 commit comments

Comments
 (0)