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

Fix disable some actions when no libraries are open #19129 #11928

Closed
wants to merge 4 commits into from

Conversation

lzmmxh
Copy link
Contributor

@lzmmxh lzmmxh commented Oct 12, 2024

This PR improves the user interface by disabling certain menu items and toolbar buttons when no library is open.
Specifically:
"Save All" menu item in MainMenu.java is now disabled (greyed out) when there are no open libraries.
"New entry from plain text" menu item in MainMenu.java is now disabled when there are no open libraries.
"Global Search" bar in the main toolbar (MainToolBar.java) is now disabled when there are no open libraries.
"New entry from plain text" button in the main toolbar (MainToolBar.java) is now disabled when there are no open libraries.

Here's the screenshot:

1 2 3

Here's the demo video:

2024-10-12.19-15-50.mp4

Closes #19129

#11923

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Besides minor comments, LGTM 👍. The changes need a second review and thus this PR awaits a second review.

Please also add a CHANGELOG.md entry

@@ -105,6 +106,10 @@ private void createToolBar() {
final Button pushToApplicationButton = factory.createIconButton(pushToApplicationCommand.getAction(), pushToApplicationCommand);
pushToApplicationCommand.registerReconfigurable(pushToApplicationButton);

Button newEntryFromPlainTextButton = factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new PlainCitationParserAction(dialogService));

Copy link
Member

Choose a reason for hiding this comment

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

Remove empty line - these two statements belong together.

@@ -118,12 +123,12 @@ private void createToolBar() {
globalSearchBar,

rightSpacer,

Copy link
Member

Choose a reason for hiding this comment

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

Do not add spaces. --> Place the cursor on a line with text in IntelliJ and then save.

new HBox(
factory.createIconButton(StandardActions.NEW_ARTICLE, new NewEntryAction(frame::getCurrentLibraryTab, StandardEntryType.Article, dialogService, preferences, stateManager)),
factory.createIconButton(StandardActions.NEW_ENTRY, new NewEntryAction(frame::getCurrentLibraryTab, dialogService, preferences, stateManager)),
createNewEntryFromIdButton(),
factory.createIconButton(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new PlainCitationParserAction(dialogService)),
newEntryFromPlainTextButton, // Use the modified button here
Copy link
Member

Choose a reason for hiding this comment

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

No need for the comment - it is self explainiing

Suggested change
newEntryFromPlainTextButton, // Use the modified button here
newEntryFromPlainTextButton,

(Did you use ChatGPT? This comment is AI generated, isn't it?)

Comment on lines +150 to +154
MenuItem saveAllMenuItem = factory.createMenuItem(StandardActions.SAVE_ALL, new SaveAllAction(frame::getLibraryTabs, preferences, dialogService));
MenuItem newEntryFromPlainTextMenuItem = factory.createMenuItem(StandardActions.NEW_ENTRY_FROM_PLAIN_TEXT, new PlainCitationParserAction(dialogService));

saveAllMenuItem.disableProperty().bind(Bindings.isEmpty(stateManager.getOpenDatabases()));
newEntryFromPlainTextMenuItem.disableProperty().bind(Bindings.isEmpty(stateManager.getOpenDatabases()));
Copy link
Member

Choose a reason for hiding this comment

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

Reorder:

Variable declaration and binding should be grouped.

Now you have

  • A-init
  • B-init
  • empty line
  • A-binding
  • B-binding

It shoudl be

  • A-init
  • A-binding
  • empty line
  • B-init
  • B-binding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will change it.

@lzmmxh lzmmxh closed this Oct 12, 2024
@lzmmxh lzmmxh deleted the fix#19129 branch October 12, 2024 09:34
@lzmmxh lzmmxh restored the fix#19129 branch October 12, 2024 09:34
@Siedlerchr
Copy link
Member

please do not delete and re-create your PR! justpush your changes! PR will be auto updted

@koppor
Copy link
Member

koppor commented Oct 12, 2024

Follow up PR is #11936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants