Skip to content

Commit

Permalink
Hide tab bar (#12395)
Browse files Browse the repository at this point in the history
* Hide Tab bar for single library view

* Add CSS classes and preference option

* Remove a nested if

* Improved synchronized functionality of preferences and list change listener

* Move TabBarManager into JabRefFrame from LibraryTab

* add options to menu

* Add 'Open in File Explorer' option to the menu

* Add a CHANGELOG.md entry

* Update CHANGELOG.md

Co-authored-by: Christoph <[email protected]>

* Fix space in CHANGELOG.md

* Fix space in CHANGELOG.md

* Remove TabBarManager from LibraryTab

* Move TabBarManager methods into JabRefFrame class

* Make methods private

---------

Co-authored-by: Christoph <[email protected]>
Co-authored-by: Subhramit Basu Bhowmick <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2025
1 parent 2b93f15 commit d1ce450
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

### Added

- We added a 'Copy to' context menu option with features for cross-reference inclusion/exclusion, as well as the ability to save user preferences. [#12374](https://github.com/JabRef/jabref/pull/12374)
- We added a feature for copying entries to libraries, available via the context menu, with an option to include cross-references. [#12374](https://github.com/JabRef/jabref/pull/12374)

### Changed

- We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278)
- The tab bar is now hidden when only one library is open. [#9971](https://github.com/JabRef/jabref/issues/9971)

### Fixed

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,20 @@ 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%);
}

.table-view,
.tree-table-view {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ private void onDatabaseLoadingFailed(Exception ex) {

private void setDatabaseContext(BibDatabaseContext bibDatabaseContext) {
TabPane tabPane = this.getTabPane();

if (tabPane == null) {
LOGGER.debug("User interrupted loading. Not showing any library.");
return;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/jabref/gui/WorkspacePreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> selectedSlrCatalogs;

public WorkspacePreferences(Language language,
Expand All @@ -37,6 +38,7 @@ public WorkspacePreferences(Language language,
boolean showAdvancedHints,
boolean warnAboutDuplicatesInInspection,
boolean confirmDelete,
boolean confirmHideTabBar,
List<String> selectedSlrCatalogs) {
this.language = new SimpleObjectProperty<>(language);
this.shouldOverrideDefaultFontSize = new SimpleBooleanProperty(shouldOverrideDefaultFontSize);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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<String> getSelectedSlrCatalogs() {
return selectedSlrCatalogs;
}
Expand Down
52 changes: 48 additions & 4 deletions src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import javafx.beans.InvalidationListener;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.collections.ListChangeListener;
import javafx.collections.transformation.FilteredList;
import javafx.event.Event;
import javafx.scene.control.ContextMenu;
Expand Down Expand Up @@ -45,6 +48,7 @@
import org.jabref.gui.sidepane.SidePane;
import org.jabref.gui.sidepane.SidePaneType;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.BindingsHelper;
import org.jabref.logic.UiCommand;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.journals.JournalAbbreviationRepository;
Expand Down Expand Up @@ -186,6 +190,7 @@ public JabRefFrame(Stage mainStage,
initKeyBindings();
frameDndHandler.initDragAndDrop();
initBindings();
initTabBarManager();
}

private void initLayout() {
Expand Down Expand Up @@ -393,6 +398,39 @@ private void initBindings() {
});
}

private void initTabBarManager() {
IntegerProperty numberOfOpenDatabases = new SimpleIntegerProperty();
stateManager.getOpenDatabases().addListener((ListChangeListener<BibDatabaseContext>) change -> {
numberOfOpenDatabases.set(stateManager.getOpenDatabases().size());
updateTabBarState(numberOfOpenDatabases);
});

BindingsHelper.subscribeFuture(preferences.getWorkspacePreferences().confirmHideTabBarProperty(), hideTabBar -> updateTabBarState(numberOfOpenDatabases));
maintainInitialTabBarState(preferences.getWorkspacePreferences().shouldHideTabBar());
}

private void updateTabBarState(IntegerProperty numberOfOpenDatabases) {
if (preferences.getWorkspacePreferences().shouldHideTabBar() && numberOfOpenDatabases.get() == 1) {
if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) {
tabbedPane.getStyleClass().add("hide-tab-bar");
}
} else {
tabbedPane.getStyleClass().remove("hide-tab-bar");
}
}

private void maintainInitialTabBarState(boolean show) {
if (show) {
if (stateManager.getOpenDatabases().size() == 1) {
if (!tabbedPane.getStyleClass().contains("hide-tab-bar")) {
tabbedPane.getStyleClass().add("hide-tab-bar");
}
} else {
tabbedPane.getStyleClass().remove("hide-tab-bar");
}
}
}

/* ************************************************************************
*
* Public API
Expand Down Expand Up @@ -461,7 +499,7 @@ private ContextMenu createTabContextMenuFor(LibraryTab tab) {

contextMenu.getItems().addAll(
factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(tab::getBibDatabaseContext, stateManager)),
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(tab::getBibDatabaseContext)),
factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new OpenDatabaseFolder(dialogService, stateManager, preferences, tab::getBibDatabaseContext)),
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(tab::getBibDatabaseContext, stateManager, preferences, dialogService)),
new SeparatorMenuItem(),
factory.createMenuItem(StandardActions.CLOSE_LIBRARY, new CloseDatabaseAction(this, tab, stateManager)),
Expand Down Expand Up @@ -632,11 +670,17 @@ public void execute() {
}
}

private class OpenDatabaseFolder extends SimpleCommand {
public static class OpenDatabaseFolder extends SimpleCommand {

private final Supplier<BibDatabaseContext> databaseContext;

public OpenDatabaseFolder(Supplier<BibDatabaseContext> databaseContext) {
private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;

public OpenDatabaseFolder(DialogService dialogService, StateManager stateManager, GuiPreferences preferences, Supplier<BibDatabaseContext> databaseContext) {
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.databaseContext = databaseContext;
this.executable.bind(needsSavedLocalDatabase(stateManager));
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ private void createMenu() {

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.OPEN_DATABASE_FOLDER, new JabRefFrame.OpenDatabaseFolder(dialogService, stateManager, preferences, () -> stateManager.getActiveDatabase().orElse(null))),
factory.createMenuItem(StandardActions.OPEN_CONSOLE, new OpenConsoleAction(stateManager, preferences, dialogService)),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(stateManager))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,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";
Expand Down Expand Up @@ -271,6 +272,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

Expand Down Expand Up @@ -652,6 +654,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) -> {
Expand All @@ -670,6 +673,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<String>) change ->
putStringList(SELECTED_SLR_CATALOGS, workspacePreferences.getSelectedSlrCatalogs()));
return workspacePreferences;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
text="%Warn about unresolved duplicates when closing inspection window"/>

<CheckBox fx:id="confirmDelete" text="%Show confirmation dialog when deleting entries"/>
<CheckBox fx:id="confirmHideTabBar" text="%Hide tab bar when single library is present"/>

<Label styleClass="sectionHeader" text="%Single instance" />
<HBox alignment="CENTER_LEFT" spacing="10.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class GeneralTab extends AbstractPreferenceTabView<GeneralTabViewModel> i
@FXML private CheckBox inspectionWarningDuplicate;

@FXML private CheckBox confirmDelete;
@FXML private CheckBox confirmHideTabBar;
@FXML private ComboBox<BibDatabaseMode> biblatexMode;
@FXML private CheckBox alwaysReformatBib;
@FXML private CheckBox autosaveLocalLibraries;
Expand Down Expand Up @@ -119,6 +120,7 @@ public void initialize() {
showAdvancedHints.selectedProperty().bindBidirectional(viewModel.showAdvancedHintsProperty());
inspectionWarningDuplicate.selectedProperty().bindBidirectional(viewModel.inspectionWarningDuplicateProperty());
confirmDelete.selectedProperty().bindBidirectional(viewModel.confirmDeleteProperty());
confirmHideTabBar.selectedProperty().bindBidirectional(viewModel.confirmHideTabBarProperty());

new ViewModelListCellFactory<BibDatabaseMode>()
.withText(BibDatabaseMode::getFormattedName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class GeneralTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty showAdvancedHintsProperty = new SimpleBooleanProperty();
private final BooleanProperty inspectionWarningDuplicateProperty = new SimpleBooleanProperty();
private final BooleanProperty confirmDeleteProperty = new SimpleBooleanProperty();
private final BooleanProperty hideTabBarProperty = new SimpleBooleanProperty();

private final ListProperty<BibDatabaseMode> bibliographyModeListProperty = new SimpleListProperty<>();
private final ObjectProperty<BibDatabaseMode> selectedBiblatexModeProperty = new SimpleObjectProperty<>();
Expand Down Expand Up @@ -184,6 +185,7 @@ public void setValues() {
inspectionWarningDuplicateProperty.setValue(workspacePreferences.shouldWarnAboutDuplicatesInInspection());

confirmDeleteProperty.setValue(workspacePreferences.shouldConfirmDelete());
hideTabBarProperty.setValue(workspacePreferences.shouldHideTabBar());

bibliographyModeListProperty.setValue(FXCollections.observableArrayList(BibDatabaseMode.values()));
selectedBiblatexModeProperty.setValue(libraryPreferences.getDefaultBibDatabaseMode());
Expand Down Expand Up @@ -225,6 +227,7 @@ public void storeSettings() {
workspacePreferences.setWarnAboutDuplicatesInInspection(inspectionWarningDuplicateProperty.getValue());

workspacePreferences.setConfirmDelete(confirmDeleteProperty.getValue());
workspacePreferences.setHideTabBar(confirmHideTabBarProperty().getValue());

libraryPreferences.setDefaultBibDatabaseMode(selectedBiblatexModeProperty.getValue());

Expand Down Expand Up @@ -371,6 +374,10 @@ public BooleanProperty confirmDeleteProperty() {
return this.confirmDeleteProperty;
}

public BooleanProperty confirmHideTabBarProperty() {
return this.hideTabBarProperty;
}

public ListProperty<BibDatabaseMode> biblatexModeListProperty() {
return this.bibliographyModeListProperty;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ Attached\ files=Attached files
Show\ confirmation\ dialog\ when\ deleting\ entries=Show confirmation dialog when deleting entries
Show\ confirmation\ dialog\ when\ deleting\ attached\ files=Show confirmation dialog when deleting attached files

Hide\ tab\ bar\ when\ single\ library\ is\ present=Hide tab bar when single library is present

Persist\ password\ between\ sessions=Persist password between sessions

Persist\ api\ keys\ between\ sessions=Persist api keys between sessions
Expand Down

0 comments on commit d1ce450

Please sign in to comment.