From 5a8845786a85753ad0da9dfe6f79bf042e324cd5 Mon Sep 17 00:00:00 2001 From: Priyanshu Gupta Date: Fri, 17 Jan 2025 16:31:55 +0530 Subject: [PATCH 01/13] Hide Tab bar for single library view --- src/main/java/org/jabref/gui/LibraryTab.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index f93ef8c6101..363005e530a 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -345,6 +345,24 @@ private void onDatabaseLoadingFailed(Exception ex) { private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) { TabPane tabPane = this.getTabPane(); + + stateManager.getOpenDatabases().addListener((ListChangeListener) change -> { + int numberOfOpenDatabases = stateManager.getOpenDatabases().size(); + if (numberOfOpenDatabases == 1) { + tabPane.setStyle("-fx-tab-max-height: 0;"); + tabPane.lookup(".tab-header-area").setStyle("-fx-pref-height: 0; visibility: hidden"); + tabPane.lookupAll(".tab-pane > .tab-header-area > .headers-region > .tab").forEach(node -> { + node.setStyle("-fx-padding: 0; -fx-border-width: 0; -fx-pref-height: 0;"); + }); + } else { + tabPane.setStyle(""); + tabPane.lookup(".tab-header-area").setStyle(""); + tabPane.lookupAll(".tab-pane > .tab-header-area > .headers-region > .tab").forEach(node -> { + node.setStyle(""); + }); + } + }); + if (tabPane == null) { LOGGER.debug("User interrupted loading. Not showing any library."); return; From 1321806173ad5d698f9d206e7fc436f5c0260f23 Mon Sep 17 00:00:00 2001 From: Priyanshu Gupta Date: Sat, 18 Jan 2025 07:31:45 +0530 Subject: [PATCH 02/13] Add CSS classes and preference option --- src/main/java/org/jabref/gui/Base.css | 11 +++++ src/main/java/org/jabref/gui/LibraryTab.java | 49 ++++++++++++------- .../org/jabref/gui/WorkspacePreferences.java | 15 ++++++ .../gui/preferences/JabRefGuiPreferences.java | 4 ++ .../gui/preferences/general/GeneralTab.fxml | 1 + .../gui/preferences/general/GeneralTab.java | 2 + .../general/GeneralTabViewModel.java | 7 +++ src/main/resources/l10n/JabRef_en.properties | 2 + 8 files changed, 73 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index 23337a9c7cc..6c6fcd0a798 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -664,6 +664,17 @@ TextFlow > .tooltip-text-monospaced { -fx-padding: 0 0 0 0; } +.tab-pane.hide-tab-bar .tab-header-area { + -fx-pref-height: 0; + visibility: hidden; +} + +.tab-pane.hide-tab-bar .tab-header-area > .headers-region > .tab { + -fx-padding: 0; + -fx-border-width: 0; + -fx-pref-height: 0; +} + .numberColumn > .hits:any-selected { -fx-background-color: derive(-jr-green, 70%); } diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index 363005e530a..f583ff18b6e 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -346,23 +346,35 @@ private void onDatabaseLoadingFailed(Exception ex) { private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) { TabPane tabPane = this.getTabPane(); - stateManager.getOpenDatabases().addListener((ListChangeListener) change -> { - int numberOfOpenDatabases = stateManager.getOpenDatabases().size(); - if (numberOfOpenDatabases == 1) { - tabPane.setStyle("-fx-tab-max-height: 0;"); - tabPane.lookup(".tab-header-area").setStyle("-fx-pref-height: 0; visibility: hidden"); - tabPane.lookupAll(".tab-pane > .tab-header-area > .headers-region > .tab").forEach(node -> { - node.setStyle("-fx-padding: 0; -fx-border-width: 0; -fx-pref-height: 0;"); - }); - } else { - tabPane.setStyle(""); - tabPane.lookup(".tab-header-area").setStyle(""); - tabPane.lookupAll(".tab-pane > .tab-header-area > .headers-region > .tab").forEach(node -> { - node.setStyle(""); - }); - } - }); - + if (preferences.getWorkspacePreferences().shouldHideTabBar()) { + stateManager.getOpenDatabases().addListener((ListChangeListener) change -> { + int numberOfOpenDatabases = stateManager.getOpenDatabases().size(); + if (numberOfOpenDatabases == 1) { + if (!tabPane.getStyleClass().contains("hide-tab-bar")) { + tabPane.getStyleClass().add("hide-tab-bar"); + } + } else { + tabPane.getStyleClass().remove("hide-tab-bar"); + } + }); + } + + /* BindingsHelper.subscribeFuture( + preferences.getWorkspacePreferences().confirmHideTabBarProperty(), + hideTabBar -> { + stateManager.getOpenDatabases().addListener((ListChangeListener) change -> { + int numberOfOpenDatabases = stateManager.getOpenDatabases().size(); + if (hideTabBar && numberOfOpenDatabases == 1) { + if (!tabPane.getStyleClass().contains("hide-tab-bar")) { + tabPane.getStyleClass().add("hide-tab-bar"); + } + } else { + tabPane.getStyleClass().remove("hide-tab-bar"); + } + }); + } + );*/ + if (tabPane == null) { LOGGER.debug("User interrupted loading. Not showing any library."); return; @@ -495,7 +507,8 @@ public void registerUndoableChanges(List changes) { } } - public void editEntryAndFocusField(BibEntry entry, Field field) { + public void editEntryAndFocusField(BibEntry entry, Field + field) { showAndEdit(entry); Platform.runLater(() -> { // Focus field and entry in main table (async to give entry editor time to load) diff --git a/src/main/java/org/jabref/gui/WorkspacePreferences.java b/src/main/java/org/jabref/gui/WorkspacePreferences.java index 2948be7582e..184aba03691 100644 --- a/src/main/java/org/jabref/gui/WorkspacePreferences.java +++ b/src/main/java/org/jabref/gui/WorkspacePreferences.java @@ -25,6 +25,7 @@ public class WorkspacePreferences { private final BooleanProperty showAdvancedHints; private final BooleanProperty warnAboutDuplicatesInInspection; private final BooleanProperty confirmDelete; + private final BooleanProperty confirmHideTabBar; private final ObservableList selectedSlrCatalogs; public WorkspacePreferences(Language language, @@ -37,6 +38,7 @@ public WorkspacePreferences(Language language, boolean showAdvancedHints, boolean warnAboutDuplicatesInInspection, boolean confirmDelete, + boolean confirmHideTabBar, List selectedSlrCatalogs) { this.language = new SimpleObjectProperty<>(language); this.shouldOverrideDefaultFontSize = new SimpleBooleanProperty(shouldOverrideDefaultFontSize); @@ -48,6 +50,7 @@ public WorkspacePreferences(Language language, this.showAdvancedHints = new SimpleBooleanProperty(showAdvancedHints); this.warnAboutDuplicatesInInspection = new SimpleBooleanProperty(warnAboutDuplicatesInInspection); this.confirmDelete = new SimpleBooleanProperty(confirmDelete); + this.confirmHideTabBar = new SimpleBooleanProperty(confirmHideTabBar); this.selectedSlrCatalogs = FXCollections.observableArrayList(selectedSlrCatalogs); } @@ -163,6 +166,18 @@ public void setConfirmDelete(boolean confirmDelete) { this.confirmDelete.set(confirmDelete); } + public boolean shouldHideTabBar() { + return confirmHideTabBar.get(); + } + + public BooleanProperty confirmHideTabBarProperty() { + return confirmHideTabBar; + } + + public void setHideTabBar(boolean hideTabBar) { + this.confirmHideTabBar.set(hideTabBar); + } + public ObservableList getSelectedSlrCatalogs() { return selectedSlrCatalogs; } diff --git a/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java b/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java index 2ab75d18cb7..c7ff53127f7 100644 --- a/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java +++ b/src/main/java/org/jabref/gui/preferences/JabRefGuiPreferences.java @@ -169,6 +169,7 @@ public class JabRefGuiPreferences extends JabRefCliPreferences implements GuiPre private static final String OVERRIDE_DEFAULT_FONT_SIZE = "overrideDefaultFontSize"; private static final String SHOW_ADVANCED_HINTS = "showAdvancedHints"; private static final String CONFIRM_DELETE = "confirmDelete"; + private static final String CONFIRM_HIDE_TAB_BAR = "confirmHideTabBar"; // endregion private static final String ENTRY_EDITOR_HEIGHT = "entryEditorHeightFX"; @@ -266,6 +267,7 @@ private JabRefGuiPreferences() { defaults.put(THEME, Theme.BASE_CSS); defaults.put(THEME_SYNC_OS, Boolean.FALSE); defaults.put(CONFIRM_DELETE, Boolean.TRUE); + defaults.put(CONFIRM_HIDE_TAB_BAR, Boolean.TRUE); defaults.put(SHOW_ADVANCED_HINTS, Boolean.TRUE); // endregion @@ -633,6 +635,7 @@ public WorkspacePreferences getWorkspacePreferences() { getBoolean(SHOW_ADVANCED_HINTS), getBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION), getBoolean(CONFIRM_DELETE), + getBoolean(CONFIRM_HIDE_TAB_BAR), getStringList(SELECTED_SLR_CATALOGS)); EasyBind.listen(workspacePreferences.languageProperty(), (obs, oldValue, newValue) -> { @@ -651,6 +654,7 @@ public WorkspacePreferences getWorkspacePreferences() { EasyBind.listen(workspacePreferences.showAdvancedHintsProperty(), (obs, oldValue, newValue) -> putBoolean(SHOW_ADVANCED_HINTS, newValue)); EasyBind.listen(workspacePreferences.warnAboutDuplicatesInInspectionProperty(), (obs, oldValue, newValue) -> putBoolean(WARN_ABOUT_DUPLICATES_IN_INSPECTION, newValue)); EasyBind.listen(workspacePreferences.confirmDeleteProperty(), (obs, oldValue, newValue) -> putBoolean(CONFIRM_DELETE, newValue)); + EasyBind.listen(workspacePreferences.confirmHideTabBarProperty(), (obs, oldValue, newValue) -> putBoolean(CONFIRM_HIDE_TAB_BAR, newValue)); workspacePreferences.getSelectedSlrCatalogs().addListener((ListChangeListener) change -> putStringList(SELECTED_SLR_CATALOGS, workspacePreferences.getSelectedSlrCatalogs())); return workspacePreferences; diff --git a/src/main/java/org/jabref/gui/preferences/general/GeneralTab.fxml b/src/main/java/org/jabref/gui/preferences/general/GeneralTab.fxml index b7f6c599498..a7a138a2922 100644 --- a/src/main/java/org/jabref/gui/preferences/general/GeneralTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/general/GeneralTab.fxml @@ -72,6 +72,7 @@ text="%Warn about unresolved duplicates when closing inspection window"/> +