From 13b1b587cc1f5ed950f02275d8bd0f32ecdd853f Mon Sep 17 00:00:00 2001 From: u1041868 Date: Tue, 15 Oct 2024 14:37:40 +1100 Subject: [PATCH 01/26] made a basic welcome screen here in WelcomeScreen.java --- src/main/java/org/jabref/gui/JabRefGUI.java | 19 ++++--- .../org/jabref/gui/welcome/WelcomeScreen.java | 57 +++++++++++++++++++ 2 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/jabref/gui/welcome/WelcomeScreen.java diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 820e4468c34..9b50ed6aa07 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -25,6 +25,7 @@ import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.UiTaskExecutor; +import org.jabref.gui.welcome.WelcomeScreen; import org.jabref.logic.UiCommand; import org.jabref.logic.ai.AiService; import org.jabref.logic.l10n.Localization; @@ -85,12 +86,10 @@ public static void setup(List uiCommands, public void start(Stage stage) { this.mainStage = stage; - FallbackExceptionHandler.installExceptionHandler((exception, thread) -> { - UiTaskExecutor.runInJavaFXThread(() -> { - DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); - dialogService.showErrorDialogAndWait("Uncaught exception occurred in " + thread, exception); - }); - }); + FallbackExceptionHandler.installExceptionHandler((exception, thread) -> UiTaskExecutor.runInJavaFXThread(() -> { + DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); + dialogService.showErrorDialogAndWait("Uncaught exception occurred in " + thread, exception); + })); initialize(); @@ -232,7 +231,13 @@ private void openWindow() { mainStage.setMaximized(windowMaximised); debugLogWindowState(mainStage); - Scene scene = new Scene(JabRefGUI.mainFrame); + // Check if databases are open and display the appropriate screen + Scene scene; + if (stateManager.getOpenDatabases().isEmpty()) { + scene = WelcomeScreen.createWelcomeScene(); // Display the welcome screen + } else { + scene = new Scene(mainFrame); // Display the main frame + } LOGGER.debug("installing CSS"); themeManager.installCss(scene); diff --git a/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java b/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java new file mode 100644 index 00000000000..8b1d3bbb258 --- /dev/null +++ b/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java @@ -0,0 +1,57 @@ +package org.jabref.gui.welcome; + +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; + +public class WelcomeScreen { + + public static Scene createWelcomeScene() { + // Create the layout + VBox layout = new VBox(20); + layout.setAlignment(Pos.CENTER); + + // Welcome label with larger font and color + Label welcomeLabel = new Label("Welcome to JabRef!"); + welcomeLabel.setFont(new Font("Arial", 28)); + welcomeLabel.setTextFill(Color.DARKSLATEGRAY); + + // Create buttons with customized styling + Button openButton = createStyledButton("Open Library"); + Button createButton = createStyledButton("Create New Library"); + + // Add elements to the layout + layout.getChildren().addAll(welcomeLabel, openButton, createButton); + + // Create and return the scene + return new Scene(layout, 800, 600); + } + + // Helper method to create styled buttons + private static Button createStyledButton(String text) { + Button button = new Button(text); + button.setFont(new Font("Arial", 16)); + + // Primary button color: #50618F, with slight padding + button.setStyle("-fx-background-color: #50618F; -fx-text-fill: white; " + + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;"); + + // Darken slightly on hover + button.setOnMouseEntered(e -> button.setStyle( + "-fx-background-color: #405070; -fx-text-fill: white; " + + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;" + )); + + // Reset to original color on exit + button.setOnMouseExited(e -> button.setStyle( + "-fx-background-color: #50618F; -fx-text-fill: white; " + + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;" + )); + + return button; + } +} From 3c63145c4e3eb0a157be998240a7296327091258 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Tue, 15 Oct 2024 15:42:09 +1100 Subject: [PATCH 02/26] got rid of welcome screen and made a welcome tab instead. Welcome tab currently doesnt do anything useful --- src/main/java/org/jabref/gui/JabRefGUI.java | 8 +-- .../org/jabref/gui/frame/JabRefFrame.java | 30 ++++++++++ .../org/jabref/gui/welcome/WelcomeScreen.java | 57 ------------------- 3 files changed, 31 insertions(+), 64 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/welcome/WelcomeScreen.java diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index 9b50ed6aa07..ad030640850 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -25,7 +25,6 @@ import org.jabref.gui.theme.ThemeManager; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.util.UiTaskExecutor; -import org.jabref.gui.welcome.WelcomeScreen; import org.jabref.logic.UiCommand; import org.jabref.logic.ai.AiService; import org.jabref.logic.l10n.Localization; @@ -231,13 +230,8 @@ private void openWindow() { mainStage.setMaximized(windowMaximised); debugLogWindowState(mainStage); - // Check if databases are open and display the appropriate screen Scene scene; - if (stateManager.getOpenDatabases().isEmpty()) { - scene = WelcomeScreen.createWelcomeScene(); // Display the welcome screen - } else { - scene = new Scene(mainFrame); // Display the main frame - } + scene = new Scene(mainFrame); // Display the main frame LOGGER.debug("installing CSS"); themeManager.installCss(scene); diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index c40a946cffc..8ff19b1191a 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -14,7 +14,9 @@ import javafx.beans.binding.StringBinding; import javafx.collections.transformation.FilteredList; import javafx.event.Event; +import javafx.geometry.Pos; import javafx.scene.control.ContextMenu; +import javafx.scene.control.Label; import javafx.scene.control.SeparatorMenuItem; import javafx.scene.control.SplitPane; import javafx.scene.control.Tab; @@ -22,6 +24,8 @@ import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; import javafx.stage.Stage; import org.jabref.gui.ClipBoardManager; @@ -185,6 +189,8 @@ public JabRefFrame(Stage mainStage, initKeyBindings(); frameDndHandler.initDragAndDrop(); initBindings(); + bindDatabaseChanges(); + updateContent(); } private void initLayout() { @@ -231,6 +237,30 @@ private void initLayout() { setCenter(splitPane); } + private void updateContent() { + tabbedPane.getTabs().clear(); + if (stateManager.getOpenDatabases().isEmpty()) { + tabbedPane.getTabs().add(createEmptyTab()); + } + } + + private Tab createEmptyTab() { + Tab emptyTab = new Tab("Welcome"); + VBox content = new VBox(10); + content.setAlignment(Pos.CENTER); + Label welcomeLabel = new Label("Welcome to JabRef!"); + welcomeLabel.setFont(new Font("Arial", 28)); + welcomeLabel.setTextFill(Color.DARKSLATEGRAY); + content.getChildren().add(welcomeLabel); + emptyTab.setContent(content); + emptyTab.setClosable(false); + return emptyTab; + } + + private void bindDatabaseChanges() { + stateManager.getOpenDatabases().addListener((InvalidationListener) obs -> Platform.runLater(this::updateContent)); + } + private void updateSidePane() { if (sidePane.getChildren().isEmpty()) { if (dividerSubscription != null) { diff --git a/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java b/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java deleted file mode 100644 index 8b1d3bbb258..00000000000 --- a/src/main/java/org/jabref/gui/welcome/WelcomeScreen.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.jabref.gui.welcome; - -import javafx.geometry.Pos; -import javafx.scene.Scene; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.text.Font; - -public class WelcomeScreen { - - public static Scene createWelcomeScene() { - // Create the layout - VBox layout = new VBox(20); - layout.setAlignment(Pos.CENTER); - - // Welcome label with larger font and color - Label welcomeLabel = new Label("Welcome to JabRef!"); - welcomeLabel.setFont(new Font("Arial", 28)); - welcomeLabel.setTextFill(Color.DARKSLATEGRAY); - - // Create buttons with customized styling - Button openButton = createStyledButton("Open Library"); - Button createButton = createStyledButton("Create New Library"); - - // Add elements to the layout - layout.getChildren().addAll(welcomeLabel, openButton, createButton); - - // Create and return the scene - return new Scene(layout, 800, 600); - } - - // Helper method to create styled buttons - private static Button createStyledButton(String text) { - Button button = new Button(text); - button.setFont(new Font("Arial", 16)); - - // Primary button color: #50618F, with slight padding - button.setStyle("-fx-background-color: #50618F; -fx-text-fill: white; " - + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;"); - - // Darken slightly on hover - button.setOnMouseEntered(e -> button.setStyle( - "-fx-background-color: #405070; -fx-text-fill: white; " - + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;" - )); - - // Reset to original color on exit - button.setOnMouseExited(e -> button.setStyle( - "-fx-background-color: #50618F; -fx-text-fill: white; " - + "-fx-background-radius: 10; -fx-padding: 10 20 10 20;" - )); - - return button; - } -} From 0715fcd75a78ee997ed425cd2ad66ccd778f89dc Mon Sep 17 00:00:00 2001 From: u1041868 Date: Tue, 15 Oct 2024 16:08:33 +1100 Subject: [PATCH 03/26] made welcome page, works dynamically if no tabs are open --- .../org/jabref/gui/frame/JabRefFrame.java | 37 ++++++++----------- .../java/org/jabref/gui/util/WelcomePage.java | 28 ++++++++++++++ 2 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/jabref/gui/util/WelcomePage.java diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 8ff19b1191a..58450a0c1a4 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -14,18 +14,15 @@ import javafx.beans.binding.StringBinding; import javafx.collections.transformation.FilteredList; import javafx.event.Event; -import javafx.geometry.Pos; import javafx.scene.control.ContextMenu; -import javafx.scene.control.Label; import javafx.scene.control.SeparatorMenuItem; import javafx.scene.control.SplitPane; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import javafx.scene.input.KeyEvent; import javafx.scene.layout.BorderPane; +import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.stage.Stage; import org.jabref.gui.ClipBoardManager; @@ -49,6 +46,7 @@ import org.jabref.gui.sidepane.SidePane; import org.jabref.gui.sidepane.SidePaneType; import org.jabref.gui.undo.CountingUndoManager; +import org.jabref.gui.util.WelcomePage; import org.jabref.logic.UiCommand; import org.jabref.logic.ai.AiService; import org.jabref.logic.journals.JournalAbbreviationRepository; @@ -103,6 +101,9 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private Subscription dividerSubscription; + private final WelcomePage welcomePage = new WelcomePage(); + private final StackPane contentPane = new StackPane(); // Holds both WelcomePage and TabPane + public JabRefFrame(Stage mainStage, DialogService dialogService, FileUpdateMonitor fileUpdateMonitor, @@ -185,6 +186,7 @@ public JabRefFrame(Stage mainStage, } }); + // Initialize layout and bindings initLayout(); initKeyBindings(); frameDndHandler.initDragAndDrop(); @@ -229,32 +231,22 @@ private void initLayout() { head.setSpacing(0d); setTop(head); - splitPane.getItems().addAll(tabbedPane); + // Add welcome page and tabbed pane to content pane + contentPane.getChildren().addAll(welcomePage, tabbedPane); + setCenter(contentPane); // Use contentPane as the main content area + SplitPane.setResizableWithParent(sidePane, false); sidePane.widthProperty().addListener(c -> updateSidePane()); sidePane.getChildren().addListener((InvalidationListener) c -> updateSidePane()); updateSidePane(); - setCenter(splitPane); } private void updateContent() { - tabbedPane.getTabs().clear(); - if (stateManager.getOpenDatabases().isEmpty()) { - tabbedPane.getTabs().add(createEmptyTab()); - } - } + boolean hasOpenDatabases = !stateManager.getOpenDatabases().isEmpty(); - private Tab createEmptyTab() { - Tab emptyTab = new Tab("Welcome"); - VBox content = new VBox(10); - content.setAlignment(Pos.CENTER); - Label welcomeLabel = new Label("Welcome to JabRef!"); - welcomeLabel.setFont(new Font("Arial", 28)); - welcomeLabel.setTextFill(Color.DARKSLATEGRAY); - content.getChildren().add(welcomeLabel); - emptyTab.setContent(content); - emptyTab.setClosable(false); - return emptyTab; + // Show welcome page if no databases are open, otherwise show the tabs + welcomePage.setVisible(!hasOpenDatabases); + tabbedPane.setVisible(hasOpenDatabases); } private void bindDatabaseChanges() { @@ -482,6 +474,7 @@ public void addTab(@NonNull LibraryTab libraryTab, boolean raisePanel) { } libraryTab.setContextMenu(createTabContextMenuFor(libraryTab)); + updateContent(); } private ContextMenu createTabContextMenuFor(LibraryTab tab) { diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java new file mode 100644 index 00000000000..47339d3ba89 --- /dev/null +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -0,0 +1,28 @@ +package org.jabref.gui.util; + +import javafx.geometry.Pos; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; + +/** + * A simple Welcome Page for the JabRef application. + */ +public class WelcomePage extends VBox { + + public WelcomePage() { + setAlignment(Pos.CENTER); + setSpacing(10); + + Label welcomeLabel = new Label("Welcome to JabRef!"); + welcomeLabel.setFont(new Font("Arial", 28)); + welcomeLabel.setTextFill(Color.DARKSLATEGRAY); + + Label instructions = new Label("Click 'New Library' to get started or open an existing database."); + instructions.setFont(new Font("Arial", 16)); + instructions.setTextFill(Color.GRAY); + + getChildren().addAll(welcomeLabel, instructions); + } +} From b27ddb6994836cec7cc99bdb887e0fedf283de03 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Tue, 15 Oct 2024 18:16:57 +1100 Subject: [PATCH 04/26] opening new tab dismisses welcome screen --- .../org/jabref/gui/frame/JabRefFrame.java | 77 +++++++++++++++++-- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 58450a0c1a4..e1ef3d751b7 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -233,20 +233,45 @@ private void initLayout() { // Add welcome page and tabbed pane to content pane contentPane.getChildren().addAll(welcomePage, tabbedPane); - setCenter(contentPane); // Use contentPane as the main content area + + // Initially only add contentPane to the splitPane, not sidePane + splitPane.getItems().add(contentPane); SplitPane.setResizableWithParent(sidePane, false); sidePane.widthProperty().addListener(c -> updateSidePane()); sidePane.getChildren().addListener((InvalidationListener) c -> updateSidePane()); - updateSidePane(); + + setCenter(splitPane); + updateContent(); // Ensure layout is consistent on load } private void updateContent() { boolean hasOpenDatabases = !stateManager.getOpenDatabases().isEmpty(); - // Show welcome page if no databases are open, otherwise show the tabs + // Toggle visibility between welcome page and tabbed pane welcomePage.setVisible(!hasOpenDatabases); tabbedPane.setVisible(hasOpenDatabases); + + if (hasOpenDatabases) { + if (!splitPane.getItems().contains(sidePane)) { + // Ensure side pane is added only once, with preferred width + sidePane.setPrefWidth(260); + splitPane.getItems().addFirst(sidePane); + LOGGER.info("SidePane added with preferred width: {}", sidePane.getPrefWidth()); + } + + // Ensure the divider position is updated appropriately + Platform.runLater(() -> { + splitPane.setDividerPositions(0.2); // Set divider to 20% width + LOGGER.info("Divider set to 20% after opening database."); + }); + + updateSidePane(); // Additional updates if necessary + } else { + // Ensure side pane is removed when no databases are open + splitPane.getItems().remove(sidePane); + LOGGER.info("SidePane removed as no databases are open."); + } } private void bindDatabaseChanges() { @@ -258,19 +283,37 @@ private void updateSidePane() { if (dividerSubscription != null) { dividerSubscription.unsubscribe(); } - splitPane.getItems().remove(sidePane); + splitPane.getItems().remove(sidePane); // Remove side pane if empty } else { if (!splitPane.getItems().contains(sidePane)) { - splitPane.getItems().addFirst(sidePane); - updateDividerPosition(); + splitPane.getItems().addFirst(sidePane); // Add side pane back + updateDividerPosition(); // Adjust the divider position } } } public void updateDividerPosition() { if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { - splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); - dividerSubscription = EasyBind.listen(sidePane.widthProperty(), (obs, old, newVal) -> preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue())); + double sidePaneWidth = preferences.getGuiPreferences().getSidePaneWidth(); + double splitPaneWidth = splitPane.getWidth(); + double dividerPosition = sidePaneWidth / splitPaneWidth; + + LOGGER.info("Updating divider position..."); + LOGGER.info("SidePane width: {}", sidePaneWidth); + LOGGER.info("SplitPane width: {}", splitPaneWidth); + LOGGER.info("Calculated divider position: {}", dividerPosition); + + splitPane.setDividerPositions(dividerPosition); + + dividerSubscription = EasyBind.listen( + sidePane.widthProperty(), + (obs, old, newVal) -> { + LOGGER.info("SidePane width changed: old = {}, new = {}", old, newVal); + preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue()); + } + ); + } else { + LOGGER.info("Divider position not updated: Main stage not showing or sidePane is empty."); } } @@ -468,13 +511,31 @@ public void addTab(@NonNull BibDatabaseContext databaseContext, boolean raisePan public void addTab(@NonNull LibraryTab libraryTab, boolean raisePanel) { tabbedPane.getTabs().add(libraryTab); + if (raisePanel) { tabbedPane.getSelectionModel().select(libraryTab); tabbedPane.requestFocus(); } libraryTab.setContextMenu(createTabContextMenuFor(libraryTab)); + + // Ensure layout is updated updateContent(); + updateSidePane(); + + // Set the preferred width and divider position explicitly + sidePane.setPrefWidth(260); + Platform.runLater(() -> { + if (!sidePane.getChildren().isEmpty() && !splitPane.getItems().contains(sidePane)) { + splitPane.getItems().addFirst(sidePane); + + // Force divider to a known position (e.g., 0.2 of the total width) + LOGGER.info("Forcing divider position after adding tab."); + splitPane.setDividerPositions(0.2); + + updateDividerPosition(); // Ensure any further updates are applied + } + }); } private ContextMenu createTabContextMenuFor(LibraryTab tab) { From e88edc5088afc2b481888958c5c7627d10d6b8de Mon Sep 17 00:00:00 2001 From: u1041868 Date: Wed, 16 Oct 2024 14:49:26 +1100 Subject: [PATCH 05/26] corrected reference to JabRefGui.mainFrame --- src/main/java/org/jabref/gui/JabRefGUI.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index ad030640850..c2ad38f64b2 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -230,8 +230,7 @@ private void openWindow() { mainStage.setMaximized(windowMaximised); debugLogWindowState(mainStage); - Scene scene; - scene = new Scene(mainFrame); // Display the main frame + Scene scene = new Scene(JabRefGUI.mainFrame); LOGGER.debug("installing CSS"); themeManager.installCss(scene); From e14b01620822fad8203bef40ef98d738afa9252d Mon Sep 17 00:00:00 2001 From: u1041868 Date: Thu, 17 Oct 2024 19:12:57 +1100 Subject: [PATCH 06/26] remove some debug loggers --- .../org/jabref/gui/frame/JabRefFrame.java | 25 ++----------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index e1ef3d751b7..7b0d32c00cd 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -257,20 +257,17 @@ private void updateContent() { // Ensure side pane is added only once, with preferred width sidePane.setPrefWidth(260); splitPane.getItems().addFirst(sidePane); - LOGGER.info("SidePane added with preferred width: {}", sidePane.getPrefWidth()); } // Ensure the divider position is updated appropriately Platform.runLater(() -> { splitPane.setDividerPositions(0.2); // Set divider to 20% width - LOGGER.info("Divider set to 20% after opening database."); }); updateSidePane(); // Additional updates if necessary } else { // Ensure side pane is removed when no databases are open splitPane.getItems().remove(sidePane); - LOGGER.info("SidePane removed as no databases are open."); } } @@ -294,26 +291,8 @@ private void updateSidePane() { public void updateDividerPosition() { if (mainStage.isShowing() && !sidePane.getChildren().isEmpty()) { - double sidePaneWidth = preferences.getGuiPreferences().getSidePaneWidth(); - double splitPaneWidth = splitPane.getWidth(); - double dividerPosition = sidePaneWidth / splitPaneWidth; - - LOGGER.info("Updating divider position..."); - LOGGER.info("SidePane width: {}", sidePaneWidth); - LOGGER.info("SplitPane width: {}", splitPaneWidth); - LOGGER.info("Calculated divider position: {}", dividerPosition); - - splitPane.setDividerPositions(dividerPosition); - - dividerSubscription = EasyBind.listen( - sidePane.widthProperty(), - (obs, old, newVal) -> { - LOGGER.info("SidePane width changed: old = {}, new = {}", old, newVal); - preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue()); - } - ); - } else { - LOGGER.info("Divider position not updated: Main stage not showing or sidePane is empty."); + splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); + dividerSubscription = EasyBind.listen(sidePane.widthProperty(), (obs, old, newVal) -> preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue())); } } From 69005e9ca8bd412ef07680c956896d1f2fd6f42d Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 09:12:04 +1100 Subject: [PATCH 07/26] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c84f5424c4..587837745d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658) - We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732) - We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825) +- We added a welcome screen that displays when no database is open [#koppor96](https://github.com/koppor/jabref/issues/96) ### Changed From 14984a93f665c32bb9519a076d888b87a114742e Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 09:12:58 +1100 Subject: [PATCH 08/26] update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 587837745d3..5c84f5424c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658) - We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732) - We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825) -- We added a welcome screen that displays when no database is open [#koppor96](https://github.com/koppor/jabref/issues/96) ### Changed From eade258fb336beb8205a9556d1adec13204f9533 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 10:17:36 +1100 Subject: [PATCH 09/26] update welcome screen with hyperlinks instead of plain text --- .../org/jabref/gui/frame/JabRefFrame.java | 4 ++- .../java/org/jabref/gui/util/WelcomePage.java | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 7b0d32c00cd..720667d38eb 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -101,7 +101,7 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private Subscription dividerSubscription; - private final WelcomePage welcomePage = new WelcomePage(); + private final WelcomePage welcomePage; private final StackPane contentPane = new StackPane(); // Holds both WelcomePage and TabPane public JabRefFrame(Stage mainStage, @@ -125,6 +125,8 @@ public JabRefFrame(Stage mainStage, this.clipBoardManager = clipBoardManager; this.taskExecutor = taskExecutor; + this.welcomePage = new WelcomePage(this, preferences); + setId("frame"); // Create components diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 47339d3ba89..33fb6464aae 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -1,17 +1,24 @@ package org.jabref.gui.util; import javafx.geometry.Pos; +import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.scene.text.TextFlow; + +import org.jabref.gui.frame.JabRefFrame; +import org.jabref.gui.importer.NewDatabaseAction; +import org.jabref.gui.preferences.GuiPreferences; /** * A simple Welcome Page for the JabRef application. */ public class WelcomePage extends VBox { - public WelcomePage() { + public WelcomePage(JabRefFrame frame, GuiPreferences preferences) { setAlignment(Pos.CENTER); setSpacing(10); @@ -19,10 +26,28 @@ public WelcomePage() { welcomeLabel.setFont(new Font("Arial", 28)); welcomeLabel.setTextFill(Color.DARKSLATEGRAY); - Label instructions = new Label("Click 'New Library' to get started or open an existing database."); + Text normalText = new Text("Open a "); + normalText.setFont(new Font("Arial", 16)); + normalText.setFill(Color.GRAY); + + // Create a hyperlink for "New Library" + Hyperlink newLibraryLink = new Hyperlink("New Library"); + newLibraryLink.setFont(new Font("Arial", 16)); + newLibraryLink.setOnAction(e -> { + // Trigger NewDatabaseAction using frame and preferences + new NewDatabaseAction(frame, preferences).execute(); + }); + + // Create a TextFlow to combine normal text and the hyperlink + TextFlow textFlow = new TextFlow(normalText, newLibraryLink); + textFlow.setTextAlignment(javafx.scene.text.TextAlignment.CENTER); // Center the text within TextFlow + textFlow.setMaxWidth(Double.MAX_VALUE); + setAlignment(Pos.CENTER); // Center align VBox contents + + Label instructions = new Label("or open an existing database."); instructions.setFont(new Font("Arial", 16)); instructions.setTextFill(Color.GRAY); - getChildren().addAll(welcomeLabel, instructions); + getChildren().addAll(welcomeLabel, textFlow, instructions); } } From a031c352ef8e9df206ce52317f0d188f9dc92c9a Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 11:08:48 +1100 Subject: [PATCH 10/26] welcome screen now has links for new library and open library --- .../org/jabref/gui/frame/JabRefFrame.java | 25 +++++-- .../java/org/jabref/gui/util/WelcomePage.java | 74 +++++++++++++------ 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 720667d38eb..78384833998 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -125,7 +125,18 @@ public JabRefFrame(Stage mainStage, this.clipBoardManager = clipBoardManager; this.taskExecutor = taskExecutor; - this.welcomePage = new WelcomePage(this, preferences); + this.welcomePage = new WelcomePage( + this, + preferences, + aiService, + dialogService, + stateManager, + fileUpdateMonitor, + entryTypesManager, + undoManager, + clipBoardManager, + taskExecutor + ); setId("frame"); @@ -256,19 +267,17 @@ private void updateContent() { if (hasOpenDatabases) { if (!splitPane.getItems().contains(sidePane)) { - // Ensure side pane is added only once, with preferred width + // Set the preferred width for the side pane sidePane.setPrefWidth(260); splitPane.getItems().addFirst(sidePane); - } - // Ensure the divider position is updated appropriately - Platform.runLater(() -> { + // Ensure divider position is set before rendering splitPane.setDividerPositions(0.2); // Set divider to 20% width - }); - updateSidePane(); // Additional updates if necessary + // Ensure smooth transition by updating the layout immediately + Platform.runLater(() -> splitPane.setDividerPositions(0.2)); + } } else { - // Ensure side pane is removed when no databases are open splitPane.getItems().remove(sidePane); } } diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 33fb6464aae..67b61f1bc92 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -7,47 +7,75 @@ import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.Text; +import javafx.scene.text.TextAlignment; import javafx.scene.text.TextFlow; +import org.jabref.gui.ClipBoardManager; +import org.jabref.gui.DialogService; +import org.jabref.gui.StateManager; import org.jabref.gui.frame.JabRefFrame; import org.jabref.gui.importer.NewDatabaseAction; +import org.jabref.gui.importer.actions.OpenDatabaseAction; import org.jabref.gui.preferences.GuiPreferences; +import org.jabref.gui.undo.CountingUndoManager; +import org.jabref.logic.ai.AiService; +import org.jabref.logic.util.TaskExecutor; +import org.jabref.model.entry.BibEntryTypesManager; +import org.jabref.model.util.FileUpdateMonitor; /** * A simple Welcome Page for the JabRef application. */ public class WelcomePage extends VBox { - public WelcomePage(JabRefFrame frame, GuiPreferences preferences) { + public WelcomePage(JabRefFrame frame, + GuiPreferences preferences, + AiService aiService, + DialogService dialogService, + StateManager stateManager, + FileUpdateMonitor fileUpdateMonitor, + BibEntryTypesManager entryTypesManager, + CountingUndoManager undoManager, + ClipBoardManager clipBoardManager, + TaskExecutor taskExecutor) { + setAlignment(Pos.CENTER); setSpacing(10); + // Title Label welcomeLabel = new Label("Welcome to JabRef!"); - welcomeLabel.setFont(new Font("Arial", 28)); + welcomeLabel.setFont(new Font("Arial", 40)); welcomeLabel.setTextFill(Color.DARKSLATEGRAY); - Text normalText = new Text("Open a "); - normalText.setFont(new Font("Arial", 16)); - normalText.setFill(Color.GRAY); + // Text and hyperlink for "New Library" + Text openNewLibraryText = new Text("Open a "); + openNewLibraryText.setFont(new Font("Arial", 22)); - // Create a hyperlink for "New Library" Hyperlink newLibraryLink = new Hyperlink("New Library"); - newLibraryLink.setFont(new Font("Arial", 16)); - newLibraryLink.setOnAction(e -> { - // Trigger NewDatabaseAction using frame and preferences - new NewDatabaseAction(frame, preferences).execute(); - }); - - // Create a TextFlow to combine normal text and the hyperlink - TextFlow textFlow = new TextFlow(normalText, newLibraryLink); - textFlow.setTextAlignment(javafx.scene.text.TextAlignment.CENTER); // Center the text within TextFlow - textFlow.setMaxWidth(Double.MAX_VALUE); - setAlignment(Pos.CENTER); // Center align VBox contents - - Label instructions = new Label("or open an existing database."); - instructions.setFont(new Font("Arial", 16)); - instructions.setTextFill(Color.GRAY); - - getChildren().addAll(welcomeLabel, textFlow, instructions); + newLibraryLink.setFont(new Font("Arial", 22)); + newLibraryLink.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); + newLibraryLink.setStyle("-fx-text-fill: blue;"); // Set link color to blue + newLibraryLink.setVisited(false); // Prevent it from changing color on click + + // Text and hyperlink for "Open Library" + Hyperlink openLibraryLink = new Hyperlink("Existing Library"); + openLibraryLink.setFont(new Font("Arial", 22)); + openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, + entryTypesManager, undoManager, clipBoardManager, taskExecutor).execute()); + openLibraryLink.setStyle("-fx-text-fill: blue;"); // Set link color to blue + openLibraryLink.setVisited(false); // Prevent it from changing color on click + + Text orExistingDatabaseText = new Text(" or open an "); + orExistingDatabaseText.setFont(new Font("Arial", 22)); + + // TextFlows for each section + TextFlow newLibraryFlow = new TextFlow(openNewLibraryText, newLibraryLink); + newLibraryFlow.setTextAlignment(TextAlignment.CENTER); + + TextFlow openLibraryFlow = new TextFlow(orExistingDatabaseText, openLibraryLink); + openLibraryFlow.setTextAlignment(TextAlignment.CENTER); + + // Add elements to the VBox + getChildren().addAll(welcomeLabel, newLibraryFlow, openLibraryFlow); } } From 1b76f861980ef390f45336baa64e5e4588d853d1 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 11:13:24 +1100 Subject: [PATCH 11/26] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c84f5424c4..587837745d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658) - We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732) - We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825) +- We added a welcome screen that displays when no database is open [#koppor96](https://github.com/koppor/jabref/issues/96) ### Changed From 2e386359fa944965158f21310e8453b6c3a5225f Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 13:31:57 +1100 Subject: [PATCH 12/26] fix typo in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 587837745d3..fa9214b0cfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a different background color to the search bar to indicate when the search syntax is wrong. [#11658](https://github.com/JabRef/jabref/pull/11658) - We added a setting which always adds the literal "Cited on pages" text before each JStyle citation. [#11691](https://github.com/JabRef/jabref/pull/11732) - We added a new plain citation parser that uses LLMs. [#11825](https://github.com/JabRef/jabref/issues/11825) -- We added a welcome screen that displays when no database is open [#koppor96](https://github.com/koppor/jabref/issues/96) +- We added a welcome screen that displays when no database is open [koppor#96](https://github.com/koppor/jabref/issues/96) ### Changed From e9c04fd1409079d9640d5e48ce6172c568a1c922 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Fri, 18 Oct 2024 13:48:00 +1100 Subject: [PATCH 13/26] remove comments --- src/main/java/org/jabref/gui/frame/JabRefFrame.java | 12 ++++-------- src/main/java/org/jabref/gui/util/WelcomePage.java | 8 ++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 78384833998..6da5c02a37c 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -244,10 +244,7 @@ private void initLayout() { head.setSpacing(0d); setTop(head); - // Add welcome page and tabbed pane to content pane contentPane.getChildren().addAll(welcomePage, tabbedPane); - - // Initially only add contentPane to the splitPane, not sidePane splitPane.getItems().add(contentPane); SplitPane.setResizableWithParent(sidePane, false); @@ -267,12 +264,11 @@ private void updateContent() { if (hasOpenDatabases) { if (!splitPane.getItems().contains(sidePane)) { - // Set the preferred width for the side pane sidePane.setPrefWidth(260); splitPane.getItems().addFirst(sidePane); // Ensure divider position is set before rendering - splitPane.setDividerPositions(0.2); // Set divider to 20% width + splitPane.setDividerPositions(0.2); // Ensure smooth transition by updating the layout immediately Platform.runLater(() -> splitPane.setDividerPositions(0.2)); @@ -291,11 +287,11 @@ private void updateSidePane() { if (dividerSubscription != null) { dividerSubscription.unsubscribe(); } - splitPane.getItems().remove(sidePane); // Remove side pane if empty + splitPane.getItems().remove(sidePane); } else { if (!splitPane.getItems().contains(sidePane)) { - splitPane.getItems().addFirst(sidePane); // Add side pane back - updateDividerPosition(); // Adjust the divider position + splitPane.getItems().addFirst(sidePane); + updateDividerPosition(); } } } diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 67b61f1bc92..f56de8c6cd3 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -54,16 +54,16 @@ public WelcomePage(JabRefFrame frame, Hyperlink newLibraryLink = new Hyperlink("New Library"); newLibraryLink.setFont(new Font("Arial", 22)); newLibraryLink.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - newLibraryLink.setStyle("-fx-text-fill: blue;"); // Set link color to blue - newLibraryLink.setVisited(false); // Prevent it from changing color on click + newLibraryLink.setStyle("-fx-text-fill: blue;"); + newLibraryLink.setVisited(false); // Text and hyperlink for "Open Library" Hyperlink openLibraryLink = new Hyperlink("Existing Library"); openLibraryLink.setFont(new Font("Arial", 22)); openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager, taskExecutor).execute()); - openLibraryLink.setStyle("-fx-text-fill: blue;"); // Set link color to blue - openLibraryLink.setVisited(false); // Prevent it from changing color on click + openLibraryLink.setStyle("-fx-text-fill: blue;"); + openLibraryLink.setVisited(false); Text orExistingDatabaseText = new Text(" or open an "); orExistingDatabaseText.setFont(new Font("Arial", 22)); From 5d50f08eee4465087f6e8cfb8407fef90387491a Mon Sep 17 00:00:00 2001 From: u1041868 Date: Sat, 19 Oct 2024 09:54:21 +1100 Subject: [PATCH 14/26] move styling on WelcomePage to Base.css --- src/main/java/org/jabref/gui/Base.css | 20 +++++++++++++++++ .../java/org/jabref/gui/util/WelcomePage.java | 22 +++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index 49d581717c7..1b4c9dd98a8 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -1732,5 +1732,25 @@ We want to have a look that matches our icons in the tool-bar */ -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.6), 8, 0.0, 0, 0); } +/* Welcome Page Styles */ +.welcome-label { + -fx-font-size: 40px; + -fx-text-fill: -jr-theme-text; + -fx-font-family: "Arial"; +} + +.welcome-text { + -fx-font-size: 22px; + -fx-text-fill: -jr-gray-3; +} + +.welcome-hyperlink { + -fx-font-size: 22px; + -fx-text-fill: -jr-theme; +} + +.welcome-hyperlink:visited { + -fx-text-fill: -jr-theme; +} /* endregion */ diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index f56de8c6cd3..69a1a75ef0b 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -4,8 +4,6 @@ import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.text.TextAlignment; import javafx.scene.text.TextFlow; @@ -44,29 +42,25 @@ public WelcomePage(JabRefFrame frame, // Title Label welcomeLabel = new Label("Welcome to JabRef!"); - welcomeLabel.setFont(new Font("Arial", 40)); - welcomeLabel.setTextFill(Color.DARKSLATEGRAY); + welcomeLabel.getStyleClass().add("welcome-label"); // Text and hyperlink for "New Library" Text openNewLibraryText = new Text("Open a "); - openNewLibraryText.setFont(new Font("Arial", 22)); + openNewLibraryText.getStyleClass().add("welcome-text"); Hyperlink newLibraryLink = new Hyperlink("New Library"); - newLibraryLink.setFont(new Font("Arial", 22)); + newLibraryLink.getStyleClass().add("welcome-hyperlink"); newLibraryLink.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - newLibraryLink.setStyle("-fx-text-fill: blue;"); - newLibraryLink.setVisited(false); // Text and hyperlink for "Open Library" Hyperlink openLibraryLink = new Hyperlink("Existing Library"); - openLibraryLink.setFont(new Font("Arial", 22)); - openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, - entryTypesManager, undoManager, clipBoardManager, taskExecutor).execute()); - openLibraryLink.setStyle("-fx-text-fill: blue;"); - openLibraryLink.setVisited(false); + openLibraryLink.getStyleClass().add("welcome-hyperlink"); + openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, + stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager, + taskExecutor).execute()); Text orExistingDatabaseText = new Text(" or open an "); - orExistingDatabaseText.setFont(new Font("Arial", 22)); + orExistingDatabaseText.getStyleClass().add("welcome-text"); // TextFlows for each section TextFlow newLibraryFlow = new TextFlow(openNewLibraryText, newLibraryLink); From e15cdb9f2ecbd0c39942cd93521c35d49ecc2a4e Mon Sep 17 00:00:00 2001 From: u1041868 Date: Sun, 20 Oct 2024 19:34:51 +1100 Subject: [PATCH 15/26] remove comments from WelcomePage.java --- src/main/java/org/jabref/gui/util/WelcomePage.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 69a1a75ef0b..6a0cf16f90b 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -40,11 +40,9 @@ public WelcomePage(JabRefFrame frame, setAlignment(Pos.CENTER); setSpacing(10); - // Title Label welcomeLabel = new Label("Welcome to JabRef!"); welcomeLabel.getStyleClass().add("welcome-label"); - // Text and hyperlink for "New Library" Text openNewLibraryText = new Text("Open a "); openNewLibraryText.getStyleClass().add("welcome-text"); @@ -52,7 +50,6 @@ public WelcomePage(JabRefFrame frame, newLibraryLink.getStyleClass().add("welcome-hyperlink"); newLibraryLink.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - // Text and hyperlink for "Open Library" Hyperlink openLibraryLink = new Hyperlink("Existing Library"); openLibraryLink.getStyleClass().add("welcome-hyperlink"); openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, @@ -62,14 +59,12 @@ public WelcomePage(JabRefFrame frame, Text orExistingDatabaseText = new Text(" or open an "); orExistingDatabaseText.getStyleClass().add("welcome-text"); - // TextFlows for each section TextFlow newLibraryFlow = new TextFlow(openNewLibraryText, newLibraryLink); newLibraryFlow.setTextAlignment(TextAlignment.CENTER); TextFlow openLibraryFlow = new TextFlow(orExistingDatabaseText, openLibraryLink); openLibraryFlow.setTextAlignment(TextAlignment.CENTER); - // Add elements to the VBox getChildren().addAll(welcomeLabel, newLibraryFlow, openLibraryFlow); } } From eab1844ab1e92300be98cb1090148d2e6bc0a6bc Mon Sep 17 00:00:00 2001 From: u1041868 Date: Sun, 20 Oct 2024 19:47:25 +1100 Subject: [PATCH 16/26] modify updateContent() method --- src/main/java/org/jabref/gui/frame/JabRefFrame.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 6da5c02a37c..702174e8df2 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -267,11 +267,7 @@ private void updateContent() { sidePane.setPrefWidth(260); splitPane.getItems().addFirst(sidePane); - // Ensure divider position is set before rendering - splitPane.setDividerPositions(0.2); - - // Ensure smooth transition by updating the layout immediately - Platform.runLater(() -> splitPane.setDividerPositions(0.2)); + splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); } } else { splitPane.getItems().remove(sidePane); From b6169705dbe6769178c19b4317843339deb41ff2 Mon Sep 17 00:00:00 2001 From: u1041868 Date: Tue, 22 Oct 2024 20:34:06 +1100 Subject: [PATCH 17/26] modify updateSidePane method --- src/main/java/org/jabref/gui/frame/JabRefFrame.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 702174e8df2..d11a8100034 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -288,6 +288,10 @@ private void updateSidePane() { if (!splitPane.getItems().contains(sidePane)) { splitPane.getItems().addFirst(sidePane); updateDividerPosition(); + + // Rebind the dividerSubscription when sidePane is re-added + dividerSubscription = EasyBind.listen(sidePane.widthProperty(), + (obs, old, newVal) -> preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue())); } } } From 5b5a63cb124521b379925ff3dc602a45f3bb3888 Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:39:15 +1100 Subject: [PATCH 18/26] FIX: fix sidebar resizing exception --- .../org/jabref/gui/frame/JabRefFrame.java | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 702174e8df2..cbe36b1ad64 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -102,7 +102,7 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe private Subscription dividerSubscription; private final WelcomePage welcomePage; - private final StackPane contentPane = new StackPane(); // Holds both WelcomePage and TabPane + private final StackPane contentPane = new StackPane(); // Holds both WelcomePage and SplitPane public JabRefFrame(Stage mainStage, DialogService dialogService, @@ -244,15 +244,14 @@ private void initLayout() { head.setSpacing(0d); setTop(head); - contentPane.getChildren().addAll(welcomePage, tabbedPane); - splitPane.getItems().add(contentPane); - + splitPane.getItems().add(tabbedPane); + contentPane.getChildren().addAll(welcomePage, splitPane); SplitPane.setResizableWithParent(sidePane, false); sidePane.widthProperty().addListener(c -> updateSidePane()); sidePane.getChildren().addListener((InvalidationListener) c -> updateSidePane()); - - setCenter(splitPane); - updateContent(); // Ensure layout is consistent on load + setCenter(contentPane); + updateSidePane(); // Ensure layout is consistent on load + updateContent(); } private void updateContent() { @@ -260,18 +259,18 @@ private void updateContent() { // Toggle visibility between welcome page and tabbed pane welcomePage.setVisible(!hasOpenDatabases); - tabbedPane.setVisible(hasOpenDatabases); - - if (hasOpenDatabases) { - if (!splitPane.getItems().contains(sidePane)) { - sidePane.setPrefWidth(260); - splitPane.getItems().addFirst(sidePane); - - splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); - } - } else { - splitPane.getItems().remove(sidePane); - } + splitPane.setVisible(hasOpenDatabases); + +// if (hasOpenDatabases) { +// if (!splitPane.getItems().contains(sidePane)) { +// sidePane.setPrefWidth(260); +// splitPane.getItems().addFirst(sidePane); +// +// splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); +// } +// } else { +// splitPane.getItems().remove(sidePane); +// } } private void bindDatabaseChanges() { @@ -501,23 +500,23 @@ public void addTab(@NonNull LibraryTab libraryTab, boolean raisePanel) { libraryTab.setContextMenu(createTabContextMenuFor(libraryTab)); - // Ensure layout is updated - updateContent(); - updateSidePane(); - - // Set the preferred width and divider position explicitly - sidePane.setPrefWidth(260); - Platform.runLater(() -> { - if (!sidePane.getChildren().isEmpty() && !splitPane.getItems().contains(sidePane)) { - splitPane.getItems().addFirst(sidePane); - - // Force divider to a known position (e.g., 0.2 of the total width) - LOGGER.info("Forcing divider position after adding tab."); - splitPane.setDividerPositions(0.2); - - updateDividerPosition(); // Ensure any further updates are applied - } - }); +// // Ensure layout is updated +// updateContent(); +// updateSidePane(); +// +// // Set the preferred width and divider position explicitly +// sidePane.setPrefWidth(260); +// Platform.runLater(() -> { +// if (!sidePane.getChildren().isEmpty() && !splitPane.getItems().contains(sidePane)) { +// splitPane.getItems().addFirst(sidePane); +// +// // Force divider to a known position (e.g., 0.2 of the total width) +// LOGGER.info("Forcing divider position after adding tab."); +// splitPane.setDividerPositions(0.2); +// +// updateDividerPosition(); // Ensure any further updates are applied +// } +// }); } private ContextMenu createTabContextMenuFor(LibraryTab tab) { From 89d6985e3b2182d2a108d33c9a2219dfad10fc8e Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Thu, 24 Oct 2024 02:51:08 +1100 Subject: [PATCH 19/26] CHORE: remove unnecessary logic --- .../org/jabref/gui/frame/JabRefFrame.java | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index cbe36b1ad64..d57dee20145 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -260,17 +260,6 @@ private void updateContent() { // Toggle visibility between welcome page and tabbed pane welcomePage.setVisible(!hasOpenDatabases); splitPane.setVisible(hasOpenDatabases); - -// if (hasOpenDatabases) { -// if (!splitPane.getItems().contains(sidePane)) { -// sidePane.setPrefWidth(260); -// splitPane.getItems().addFirst(sidePane); -// -// splitPane.setDividerPositions(preferences.getGuiPreferences().getSidePaneWidth() / splitPane.getWidth()); -// } -// } else { -// splitPane.getItems().remove(sidePane); -// } } private void bindDatabaseChanges() { @@ -499,24 +488,6 @@ public void addTab(@NonNull LibraryTab libraryTab, boolean raisePanel) { } libraryTab.setContextMenu(createTabContextMenuFor(libraryTab)); - -// // Ensure layout is updated -// updateContent(); -// updateSidePane(); -// -// // Set the preferred width and divider position explicitly -// sidePane.setPrefWidth(260); -// Platform.runLater(() -> { -// if (!sidePane.getChildren().isEmpty() && !splitPane.getItems().contains(sidePane)) { -// splitPane.getItems().addFirst(sidePane); -// -// // Force divider to a known position (e.g., 0.2 of the total width) -// LOGGER.info("Forcing divider position after adding tab."); -// splitPane.setDividerPositions(0.2); -// -// updateDividerPosition(); // Ensure any further updates are applied -// } -// }); } private ContextMenu createTabContextMenuFor(LibraryTab tab) { From a495fe8831c7f9251580f21787298f55e9c10f72 Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:12:55 +1100 Subject: [PATCH 20/26] FEAT: made entire welcome sentences into links --- .../java/org/jabref/gui/util/WelcomePage.java | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 6a0cf16f90b..1f2144b3080 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -4,9 +4,6 @@ import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; import javafx.scene.layout.VBox; -import javafx.scene.text.Text; -import javafx.scene.text.TextAlignment; -import javafx.scene.text.TextFlow; import org.jabref.gui.ClipBoardManager; import org.jabref.gui.DialogService; @@ -43,28 +40,16 @@ public WelcomePage(JabRefFrame frame, Label welcomeLabel = new Label("Welcome to JabRef!"); welcomeLabel.getStyleClass().add("welcome-label"); - Text openNewLibraryText = new Text("Open a "); - openNewLibraryText.getStyleClass().add("welcome-text"); + Hyperlink newLibrary = new Hyperlink("Open a New Library"); + newLibrary.getStyleClass().add("welcome-hyperlink"); + newLibrary.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - Hyperlink newLibraryLink = new Hyperlink("New Library"); - newLibraryLink.getStyleClass().add("welcome-hyperlink"); - newLibraryLink.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - - Hyperlink openLibraryLink = new Hyperlink("Existing Library"); - openLibraryLink.getStyleClass().add("welcome-hyperlink"); - openLibraryLink.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, + Hyperlink openLibrary = new Hyperlink("or open an Existing Library"); + openLibrary.getStyleClass().add("welcome-hyperlink"); + openLibrary.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager, taskExecutor).execute()); - Text orExistingDatabaseText = new Text(" or open an "); - orExistingDatabaseText.getStyleClass().add("welcome-text"); - - TextFlow newLibraryFlow = new TextFlow(openNewLibraryText, newLibraryLink); - newLibraryFlow.setTextAlignment(TextAlignment.CENTER); - - TextFlow openLibraryFlow = new TextFlow(orExistingDatabaseText, openLibraryLink); - openLibraryFlow.setTextAlignment(TextAlignment.CENTER); - - getChildren().addAll(welcomeLabel, newLibraryFlow, openLibraryFlow); + getChildren().addAll(welcomeLabel, newLibrary, openLibrary); } } From aab2694783f696be3c8cf196cd32e1bc4f0b85c6 Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:18:02 +1100 Subject: [PATCH 21/26] FEAT: Localisation for welcome strings in welcome page --- src/main/java/org/jabref/gui/util/WelcomePage.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 1f2144b3080..1216b64af4e 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -14,6 +14,7 @@ import org.jabref.gui.preferences.GuiPreferences; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.logic.ai.AiService; +import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.util.FileUpdateMonitor; @@ -37,14 +38,14 @@ public WelcomePage(JabRefFrame frame, setAlignment(Pos.CENTER); setSpacing(10); - Label welcomeLabel = new Label("Welcome to JabRef!"); + Label welcomeLabel = new Label(Localization.lang("Welcome to JabRef!")); welcomeLabel.getStyleClass().add("welcome-label"); - Hyperlink newLibrary = new Hyperlink("Open a New Library"); + Hyperlink newLibrary = new Hyperlink(Localization.lang("Open a New Library")); newLibrary.getStyleClass().add("welcome-hyperlink"); newLibrary.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute()); - Hyperlink openLibrary = new Hyperlink("or open an Existing Library"); + Hyperlink openLibrary = new Hyperlink(Localization.lang("or open an Existing Library")); openLibrary.getStyleClass().add("welcome-hyperlink"); openLibrary.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager, From f8dabfbf818391911c9ea78d58a2f51a4100d7ae Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:23:15 +1100 Subject: [PATCH 22/26] CHORE: remove redundant divider subscription rebinding --- src/main/java/org/jabref/gui/frame/JabRefFrame.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index 300eca8d4c7..fc0ce2c51ad 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -276,10 +276,6 @@ private void updateSidePane() { if (!splitPane.getItems().contains(sidePane)) { splitPane.getItems().addFirst(sidePane); updateDividerPosition(); - - // Rebind the dividerSubscription when sidePane is re-added - dividerSubscription = EasyBind.listen(sidePane.widthProperty(), - (obs, old, newVal) -> preferences.getGuiPreferences().setSidePaneWidth(newVal.doubleValue())); } } } From 0e428ab74a2413a1ccec6b78a758cda280d3e271 Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:25:59 +1100 Subject: [PATCH 23/26] CHORE: remove welcome-text after making entire sentence link --- src/main/java/org/jabref/gui/Base.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index 1b4c9dd98a8..16b052d6267 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -1739,11 +1739,6 @@ We want to have a look that matches our icons in the tool-bar */ -fx-font-family: "Arial"; } -.welcome-text { - -fx-font-size: 22px; - -fx-text-fill: -jr-gray-3; -} - .welcome-hyperlink { -fx-font-size: 22px; -fx-text-fill: -jr-theme; From c72d89d368bfec67f99cf1d230cd7ccfaab847af Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 02:31:01 +1100 Subject: [PATCH 24/26] CHORE: revert lines to make PR cleaner --- src/main/java/org/jabref/gui/JabRefGUI.java | 10 ++++++---- src/main/java/org/jabref/gui/frame/JabRefFrame.java | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefGUI.java b/src/main/java/org/jabref/gui/JabRefGUI.java index b17f6704f0e..be4054302ff 100644 --- a/src/main/java/org/jabref/gui/JabRefGUI.java +++ b/src/main/java/org/jabref/gui/JabRefGUI.java @@ -87,10 +87,12 @@ public static void setup(List uiCommands, public void start(Stage stage) { this.mainStage = stage; - FallbackExceptionHandler.installExceptionHandler((exception, thread) -> UiTaskExecutor.runInJavaFXThread(() -> { - DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); - dialogService.showErrorDialogAndWait("Uncaught exception occurred in " + thread, exception); - })); + FallbackExceptionHandler.installExceptionHandler((exception, thread) -> { + UiTaskExecutor.runInJavaFXThread(() -> { + DialogService dialogService = Injector.instantiateModelOrService(DialogService.class); + dialogService.showErrorDialogAndWait("Uncaught exception occurred in " + thread, exception); + }); + }); initialize(); diff --git a/src/main/java/org/jabref/gui/frame/JabRefFrame.java b/src/main/java/org/jabref/gui/frame/JabRefFrame.java index fc0ce2c51ad..ed70823b9e5 100644 --- a/src/main/java/org/jabref/gui/frame/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/frame/JabRefFrame.java @@ -244,7 +244,7 @@ private void initLayout() { head.setSpacing(0d); setTop(head); - splitPane.getItems().add(tabbedPane); + splitPane.getItems().addAll(tabbedPane); contentPane.getChildren().addAll(welcomePage, splitPane); SplitPane.setResizableWithParent(sidePane, false); sidePane.widthProperty().addListener(c -> updateSidePane()); @@ -481,7 +481,6 @@ public void addTab(@NonNull BibDatabaseContext databaseContext, boolean raisePan public void addTab(@NonNull LibraryTab libraryTab, boolean raisePanel) { tabbedPane.getTabs().add(libraryTab); - if (raisePanel) { tabbedPane.getSelectionModel().select(libraryTab); tabbedPane.requestFocus(); From 1dcf28ec1767cfd234e02d6812390f279a67195d Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:49:34 +1100 Subject: [PATCH 25/26] FEAT: update JabRef_en.properties with localisation keys --- src/main/resources/l10n/JabRef_en.properties | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 2a51404215b..13a352823e6 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2800,3 +2800,7 @@ Store\ url\ for\ downloaded\ file=Store url for downloaded file Compare\ with\ existing\ entry=Compare with existing entry Library\ Entry=Library Entry Citation\ Entry=Citation Entry + +Open\ a\ New\ Library=Open a New Library +Welcome\ to\ JabRef!=Welcome to JabRef! +or\ open\ an\ Existing\ Library=or open an Existing Library From e3460766884c36f0800ae914511a2a9497d9ea6d Mon Sep 17 00:00:00 2001 From: Chethin Weerakkody <61727018+Chethin@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:14:46 +1100 Subject: [PATCH 26/26] CHORE: remove welcome page javadocs --- src/main/java/org/jabref/gui/util/WelcomePage.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/WelcomePage.java b/src/main/java/org/jabref/gui/util/WelcomePage.java index 1216b64af4e..272a2a53858 100644 --- a/src/main/java/org/jabref/gui/util/WelcomePage.java +++ b/src/main/java/org/jabref/gui/util/WelcomePage.java @@ -19,9 +19,6 @@ import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.util.FileUpdateMonitor; -/** - * A simple Welcome Page for the JabRef application. - */ public class WelcomePage extends VBox { public WelcomePage(JabRefFrame frame,