Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a welcome screen if no database is open #12461

Merged
merged 70 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
08ec5d8
Fix #12272 - Show a welcome screen if no database is open
oops-shlok Feb 4, 2025
684f7df
Fix #12272 - Fix missing localisation keys for WelcomePage
oops-shlok Feb 4, 2025
3759e24
Fix #12272 - Fix missing localisation keys for WelcomePage
oops-shlok Feb 4, 2025
9fc595d
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 5, 2025
4e576e9
Fix #12272 - Addressed 1st Review Changes
oops-shlok Feb 5, 2025
52409bd
Fix #12272 - Checkstyle issue fix in ExportCommand file
oops-shlok Feb 5, 2025
f130244
Reverted csl-styles submodule changes
oops-shlok Feb 5, 2025
2559f22
Reverted abbrv.jabref.org submodule changes
oops-shlok Feb 5, 2025
0d240c9
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 6, 2025
cb05ec7
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 11, 2025
0489da1
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 13, 2025
669083d
Integrated WelcomePage in WelcomeTab and code changes
oops-shlok Feb 13, 2025
cf3188e
Implemented Review Changes 5
oops-shlok Feb 14, 2025
e5a4840
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 14, 2025
d4332c6
Fix #12272 - Localization key fix in JabRef_en.properties
oops-shlok Feb 14, 2025
c11ca80
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 17, 2025
5c0b6ee
Implemented Open Welcome tab in help menu option and open welcome tab…
oops-shlok Feb 17, 2025
f97be18
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 18, 2025
cdc1977
Implemented Review Changes 6
oops-shlok Feb 18, 2025
7db3b81
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 23, 2025
4de4651
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Feb 25, 2025
815ba53
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Feb 26, 2025
c401e67
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 4, 2025
dea3f05
Merge branch 'fix-for-issue-#12272' of https://github.com/oops-shlok/…
oops-shlok Mar 4, 2025
40c4ca3
Reverted Interface changes and fixed save as and save for welcome tab
oops-shlok Mar 4, 2025
a8ee2c8
Fixed checkstyle import issue
oops-shlok Mar 4, 2025
f048c4b
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 4, 2025
0e5ed41
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 6, 2025
76b1aba
Simplify and fix casting
calixtus Mar 6, 2025
970d7e8
Fix casting
calixtus Mar 6, 2025
fbf3405
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 7, 2025
5e199c4
Merge branch 'fix-for-issue-#12272' of https://github.com/oops-shlok/…
oops-shlok Mar 7, 2025
e373b34
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 8, 2025
fc78dc5
Fixed Responsiveness
oops-shlok Mar 8, 2025
66ccb58
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 10, 2025
1e24223
Undo newlines in MainToolBar.java
calixtus Mar 10, 2025
8efa826
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 11, 2025
5196593
Merge branch 'fix-for-issue-#12272' of https://github.com/oops-shlok/…
oops-shlok Mar 11, 2025
afa8b54
Added Footer for Welcome Tab
oops-shlok Mar 11, 2025
d920d6c
Fixed Localization issues
oops-shlok Mar 11, 2025
5aa63d2
Merge branch 'main' of https://github.com/JabRef/jabref into fix-for-…
oops-shlok Mar 17, 2025
fcc5be3
Fixed Recents Library issue
oops-shlok Mar 17, 2025
a6d50e2
Fixed Tragbot review for Footer
oops-shlok Mar 17, 2025
2f9811f
Refactored the code as suggested in review comments
oops-shlok Mar 17, 2025
8885b4d
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 17, 2025
721a77f
Introduced URLs Util
oops-shlok Mar 17, 2025
6744ec2
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 17, 2025
22347f8
Fixed Localization issues
oops-shlok Mar 17, 2025
a8ac3e5
Fixed Localization issues
oops-shlok Mar 17, 2025
cc78bbe
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 17, 2025
cd11463
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 17, 2025
efc4767
Fixed Localization issues
oops-shlok Mar 17, 2025
c0a4696
Merge branch 'fix-for-issue-#12272' of https://github.com/oops-shlok/…
oops-shlok Mar 17, 2025
8aed6f7
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 17, 2025
7ba378d
Fixed missing Localization in WelcomeTab
oops-shlok Mar 17, 2025
95a93eb
Fixed missing Localization in WelcomeTab
oops-shlok Mar 17, 2025
0e786cc
Fixed Review changes
oops-shlok Mar 17, 2025
f6a5587
Added Changelog entry
oops-shlok Mar 17, 2025
ba1ad6f
Update src/main/java/org/jabref/gui/frame/JabRefFrame.java
koppor Mar 19, 2025
23891b6
Update src/main/java/org/jabref/gui/WelcomeTab.java
koppor Mar 19, 2025
4bc74b6
Update src/main/java/org/jabref/gui/frame/JabRefFrame.java
koppor Mar 19, 2025
0076919
Fixed Localization issue
oops-shlok Mar 19, 2025
a71d9fb
Merge branch 'main' into fix-for-issue-#12272
oops-shlok Mar 19, 2025
3c14ba8
Fix position of showing welcome tab
koppor Mar 19, 2025
c94fb15
Streamline wording
koppor Mar 19, 2025
c695f5b
Merge branch 'fix-for-issue-#12272' of https://github.com/oops-shlok/…
koppor Mar 19, 2025
5115579
Remove obsolete strings
koppor Mar 19, 2025
f7c0c3b
Fix obsolete code
koppor Mar 19, 2025
5d84d89
Fix comment
koppor Mar 19, 2025
37e24d2
Fix localization
koppor Mar 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1734,9 +1734,41 @@ 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-label {
-fx-font-size: 40px;
-fx-text-fill: -jr-theme-text;
-fx-font-family: "Arial";
}

.description-label {
-fx-font-size: 25px;
-fx-font-family: "Arial";
}

.header-label {
-fx-font-size: 20px;
-fx-font-weight: bold;
-fx-font-family: "Arial";
}

.no-recent-label {
-fx-font-size: 18px;
-fx-text-fill: -jr-theme;
-fx-font-family: "Arial";
}

.welcome-hyperlink {
-fx-font-size: 18px;
-fx-text-fill: -jr-theme;
}

.welcome-hyperlink:visited {
-fx-text-fill: -jr-theme;
}

/* AboutDialog */
#aboutDialog .about-heading {
-fx-font-size: 30;
-fx-font-size: 31;
-fx-text-fill: -jr-theme;
}

Expand Down
54 changes: 49 additions & 5 deletions src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import javafx.collections.transformation.FilteredList;
import javafx.event.Event;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
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.stage.Stage;

Expand All @@ -49,6 +51,7 @@
import org.jabref.gui.sidepane.SidePaneType;
import org.jabref.gui.undo.CountingUndoManager;
import org.jabref.gui.util.BindingsHelper;
import org.jabref.gui.util.WelcomePage;
import org.jabref.logic.UiCommand;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.journals.JournalAbbreviationRepository;
Expand Down Expand Up @@ -104,6 +107,9 @@ public class JabRefFrame extends BorderPane implements LibraryTabContainer, UiMe

private Subscription dividerSubscription;

private final WelcomePage welcomePage;
private final StackPane contentPane = new StackPane();

public JabRefFrame(Stage mainStage,
DialogService dialogService,
FileUpdateMonitor fileUpdateMonitor,
Expand All @@ -125,6 +131,30 @@ public JabRefFrame(Stage mainStage,
this.clipBoardManager = clipBoardManager;
this.taskExecutor = taskExecutor;

this.fileHistory = new FileHistoryMenu(
this.preferences.getLastFilesOpenedPreferences().getFileHistory(),
dialogService,
getOpenDatabaseAction());

this.fileHistory.getItems().addListener((ListChangeListener<MenuItem>) change -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace addListener stuff with a proper binding.
fileHistory.disableProperty().bind(Bindings.isEmpty(fileHistory.getItems()));

boolean hasRecentFiles = !fileHistory.getItems().isEmpty();
fileHistory.setDisable(!hasRecentFiles);
});

this.welcomePage = new WelcomePage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you initialize this here? Just put all the WelcomePage stuff into the tab. You do not reuse the WelcomePage in JabRefFrame.

this,
preferences,
aiService,
dialogService,
stateManager,
fileUpdateMonitor,
entryTypesManager,
undoManager,
clipBoardManager,
taskExecutor,
fileHistory
);

setId("frame");

// Create components
Expand Down Expand Up @@ -174,10 +204,6 @@ public JabRefFrame(Stage mainStage,
this.preferences,
taskExecutor);

this.fileHistory = new FileHistoryMenu(
this.preferences.getLastFilesOpenedPreferences().getFileHistory(),
dialogService,
getOpenDatabaseAction());
this.setOnKeyTyped(key -> {
if (this.fileHistory.isShowing()) {
if (this.fileHistory.openFileByKey(key)) {
Expand All @@ -191,6 +217,8 @@ public JabRefFrame(Stage mainStage,
frameDndHandler.initDragAndDrop();
initBindings();
initTabBarManager();
bindDatabaseChanges();
updateContent();
}

private void initLayout() {
Expand Down Expand Up @@ -230,11 +258,27 @@ private void initLayout() {
setTop(head);

splitPane.getItems().addAll(tabbedPane);
contentPane.getChildren().addAll(welcomePage, splitPane);
SplitPane.setResizableWithParent(sidePane, false);
sidePane.widthProperty().addListener(c -> updateSidePane());
sidePane.getChildren().addListener((InvalidationListener) c -> updateSidePane());
updateSidePane();
setCenter(splitPane);
setCenter(contentPane);
updateSidePane();
updateContent();
}

private void updateContent() {
boolean hasOpenDatabases = !stateManager.getOpenDatabases().isEmpty();
welcomePage.setVisible(!hasOpenDatabases);
splitPane.setVisible(hasOpenDatabases);

boolean hasRecentFiles = !fileHistory.getItems().isEmpty();
fileHistory.setDisable(!hasRecentFiles);
}

private void bindDatabaseChanges() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method used anywhere? Does not look like it. Can't find a call to.

stateManager.getOpenDatabases().addListener((InvalidationListener) obs -> Platform.runLater(this::updateContent));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why runLater?
Unused variables should be replaced by an underscore _.

}

private void updateSidePane() {
Expand Down
124 changes: 124 additions & 0 deletions src/main/java/org/jabref/gui/util/WelcomePage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package org.jabref.gui.util;

import javafx.collections.ListChangeListener;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

import org.jabref.gui.ClipBoardManager;
import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.frame.FileHistoryMenu;
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.l10n.Localization;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.util.FileUpdateMonitor;

public class WelcomePage extends VBox {

private final VBox recentLibrariesBox;

public WelcomePage(JabRefFrame frame,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use the smalles possible scope to avoid unneccessary dependencies.

Suggested change
public WelcomePage(JabRefFrame frame,
public WelcomePage(LibraryTabContainer tabContainer,

GuiPreferences preferences,
AiService aiService,
DialogService dialogService,
StateManager stateManager,
FileUpdateMonitor fileUpdateMonitor,
BibEntryTypesManager entryTypesManager,
CountingUndoManager undoManager,
ClipBoardManager clipBoardManager,
TaskExecutor taskExecutor,
FileHistoryMenu fileHistoryMenu) {

setAlignment(Pos.CENTER);
setSpacing(10);

this.recentLibrariesBox = new VBox(5);

VBox welcomeBox = createWelcomeBox();
VBox startBox = createStartBox(frame, preferences, aiService, dialogService, stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager, taskExecutor);
VBox recentBox = createRecentBox(fileHistoryMenu);

VBox container = new VBox(20, welcomeBox, startBox, recentBox);
container.setAlignment(Pos.CENTER);

HBox mainContainer = new HBox(20, container);
mainContainer.setAlignment(Pos.CENTER);

getChildren().add(mainContainer);
}

private VBox createWelcomeBox() {
Label welcomeLabel = new Label(Localization.lang("Welcome to JabRef"));
welcomeLabel.getStyleClass().add("welcome-label");

Label descriptionLabel = new Label(Localization.lang("Stay on top of your Literature"));
descriptionLabel.getStyleClass().add("description-label");

return createBox(Pos.TOP_LEFT, welcomeLabel, descriptionLabel);
}

private VBox createStartBox(JabRefFrame frame, GuiPreferences preferences, AiService aiService, DialogService dialogService, StateManager stateManager, FileUpdateMonitor fileUpdateMonitor, BibEntryTypesManager entryTypesManager, CountingUndoManager undoManager, ClipBoardManager clipBoardManager, TaskExecutor taskExecutor) {
Label startLabel = new Label(Localization.lang("Start"));
startLabel.getStyleClass().add("header-label");

Hyperlink newLibrary = new Hyperlink(Localization.lang("New Library"));
newLibrary.getStyleClass().add("welcome-hyperlink");
newLibrary.setOnAction(e -> new NewDatabaseAction(frame, preferences).execute());

Hyperlink openLibrary = new Hyperlink(Localization.lang("Open Library"));
openLibrary.getStyleClass().add("welcome-hyperlink");
openLibrary.setOnAction(e -> new OpenDatabaseAction(frame, preferences, aiService, dialogService,
stateManager, fileUpdateMonitor, entryTypesManager, undoManager, clipBoardManager,
taskExecutor).execute());

return createBox(Pos.TOP_LEFT, startLabel, newLibrary, openLibrary);
}

private VBox createRecentBox(FileHistoryMenu fileHistoryMenu) {
Label recentLabel = new Label(Localization.lang("Recent"));
recentLabel.getStyleClass().add("header-label");

recentLibrariesBox.setAlignment(Pos.TOP_LEFT);
updateRecentLibraries(fileHistoryMenu);

fileHistoryMenu.getItems().addListener((ListChangeListener<MenuItem>) change -> updateRecentLibraries(fileHistoryMenu));

return createBox(Pos.TOP_LEFT, recentLabel, recentLibrariesBox);
}

private void updateRecentLibraries(FileHistoryMenu fileHistoryMenu) {
recentLibrariesBox.getChildren().clear();

if (fileHistoryMenu.getItems().isEmpty()) {
Label noRecentLibrariesLabel = new Label(Localization.lang("No Recent Libraries"));
noRecentLibrariesLabel.getStyleClass().add("no-recent-label");
recentLibrariesBox.getChildren().add(noRecentLibrariesLabel);
} else {
for (MenuItem item : fileHistoryMenu.getItems()) {
String filePath = item.getText();
Hyperlink recentLibraryLink = new Hyperlink(filePath);
recentLibraryLink.getStyleClass().add("welcome-hyperlink");
recentLibraryLink.setOnAction(item.getOnAction());
recentLibrariesBox.getChildren().add(recentLibraryLink);
}
}
}

private VBox createBox(Pos alignment, Node... nodes) {
VBox box = new VBox(5);
box.setAlignment(alignment);
box.getChildren().addAll(nodes);
return box;
}
}
8 changes: 8 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2832,3 +2832,11 @@ Include=Include
Exclude=Exclude
Include\ or\ exclude\ cross-referenced\ entries=Include or exclude cross-referenced entries
Would\ you\ like\ to\ include\ cross-reference\ entries\ in\ the\ current\ operation?=Would you like to include cross-reference entries in the current operation?

New\ Library=New Library
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very strange that a new localization is needed.

Please rework the strings to be in line with the other casing in JabRef

grafik

No\ Recent\ Libraries=No Recent Libraries
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
No\ Recent\ Libraries=No Recent Libraries
No\ recent\ libraries=No recent libraries

JabRef uses lower case:

grafik

Open\ Library=Open Library
Recent=Recent
Start=Start
Stay\ on\ top\ of\ your\ Literature=Stay on top of your Literature
Welcome\ to\ JabRef=Welcome to JabRef