-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun
, check the results, commit, and push.
You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick review from my cellphone. A more deeper look will follow.
Hi @calixtus! Saw all the comments with respect to the PR. Will resolve them asap. Thanks for the review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.
In case of issues with the import order, double check that you activated Auto Import.
You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @oops-shlok, thanks for your contribution!
Please revert the submodule changes (steps linked below).
Also, please don't resolve conversations from your end until the reviewer who asked for the change is satisfied and does that - otherwise each comment has to be manually expanded when trying to gather context on the changes asked (when re-reviewing) or to read your replies and carry the discussion forward.
For very trivial comments (for example, these ones below), you can mark resolved once done.
buildres/abbrv.jabref.org
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo the changes to submodules. Follow the alternative method in https://devdocs.jabref.org/code-howtos/faq.html#submodules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted. Will do this from now. Reverted the changes to submodules.
src/main/resources/csl-styles
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the changes to submodules
})), | ||
Duration.seconds(5)); | ||
} else { | ||
LOGGER.warn("Library Tab is null as Welcome Tab is open"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a warning.
Please store tabSupplier.get()
in a variable. You can use the refacroing functionality of IntelliJ for that ("extract variable)
Just add a comment above the if to say that the tab is null in case of the welcome page.
if (libraryTab == null) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads like a code smell...
The action has to be disabled if no tab is opened. -- work on the bindings.
executable.bind(needsDatabase(stateManager));
is the code search hint.
See other fixes for other cases: #12199
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there is somewhere an instanceOf check missing where SaveDatabaseAction#save is called?
if (tabContainer.getLibraryTabs().isEmpty()) { | ||
return preferences.getFilePreferences().getWorkingDirectory(); | ||
} else { | ||
Optional<Path> databasePath = tabContainer.getCurrentLibraryTab().getBibDatabaseContext().getDatabasePath(); | ||
return databasePath.map(Path::getParent).orElse(preferences.getFilePreferences().getWorkingDirectory()); | ||
} | ||
|
||
LibraryTab currentTab = tabContainer.getCurrentLibraryTab(); | ||
if (currentTab == null) { | ||
return preferences.getFilePreferences().getWorkingDirectory(); | ||
} | ||
|
||
Optional<Path> databasePath = currentTab.getBibDatabaseContext().getDatabasePath(); | ||
return databasePath.map(Path::getParent).orElse(preferences.getFilePreferences().getWorkingDirectory()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getLibraryTabs is not empty, but getCurrentLibraryTab could be null?
fileHistory.setDisable(!hasRecentFiles); | ||
}); | ||
|
||
this.welcomePage = new WelcomePage( |
There was a problem hiding this comment.
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.
private final TaskExecutor taskExecutor; | ||
private final FileHistoryMenu fileHistoryMenu; | ||
|
||
public WelcomePage(JabRefFrame frame, |
There was a problem hiding this comment.
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.
public WelcomePage(JabRefFrame frame, | |
public WelcomePage(LibraryTabContainer tabContainer, |
import org.jabref.model.entry.BibEntryTypesManager; | ||
import org.jabref.model.util.FileUpdateMonitor; | ||
|
||
public class WelcomePage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrate into WelcomeTab
if (libraryTab == null) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there is somewhere an instanceOf check missing where SaveDatabaseAction#save is called?
Closes #12272
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)Screen.Recording.2025-02-04.at.3.49.55.PM.mov