Skip to content

Hide tabs without restart#12958

Merged
Siedlerchr merged 5 commits into
mainfrom
avoid-restart
May 9, 2025
Merged

Hide tabs without restart#12958
Siedlerchr merged 5 commits into
mainfrom
avoid-restart

Conversation

@koppor

@koppor koppor commented Apr 17, 2025

Copy link
Copy Markdown
Member

Follow-up to #12919

Hides tabs without reload.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • [/] Screenshots added in PR description (if change is visible to the user)
  • [/] 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.

TaskExecutor taskExecutor
) {
super(aiService, aiPreferences, externalApplicationsPreferences, dialogService);
super(aiService, aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The constructor call in the superclass has been modified to include 'adaptVisibleTabs', but the JavaDoc for the constructor has not been updated to reflect this change.

private final AdaptVisibleTabs adaptVisibleTabs;

public AiPrivacyNoticeGuardedComponent(AiPreferences aiPreferences, ExternalApplicationsPreferences externalApplicationsPreferences, DialogService dialogService) {
public AiPrivacyNoticeGuardedComponent(AiPreferences aiPreferences, ExternalApplicationsPreferences externalApplicationsPreferences, DialogService dialogService, AdaptVisibleTabs adaptVisibleTabs) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The JavaDoc for the constructor should be updated to include the new parameter 'AdaptVisibleTabs adaptVisibleTabs' as per the special instructions.

AdaptVisibleTabs adaptVisibleTabs
) {
super(aiPreferences, externalApplicationsPreferences, dialogService);
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The constructor call now includes an additional parameter 'adaptVisibleTabs', but there is no JavaDoc update reflecting this change. JavaDoc should be updated to include this new parameter.

AdaptVisibleTabs adaptVisibleTabs
) {
super(aiPreferences, externalApplicationsPreferences, dialogService);
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The constructor call to the superclass now includes a new parameter 'adaptVisibleTabs', but the JavaDoc for the constructor has not been updated to reflect this change.

private final AiService aiService;
private final DialogService dialogService;
private final StateManager stateManager;
private final AdaptVisibleTabs adaptVisibleTabs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The field 'adaptVisibleTabs' is introduced but not documented in the JavaDoc of the constructor. This violates the requirement to update JavaDoc when method arguments change.

* The editors for fields are created via {@link org.jabref.gui.fieldeditors.FieldEditors}.
*/
public class EntryEditor extends BorderPane implements PreviewControls {
public class EntryEditor extends BorderPane implements PreviewControls, AdaptVisibleTabs {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The class now implements AdaptVisibleTabs, but the JavaDoc for the class does not reflect this change. The JavaDoc should be updated to include information about the new interface implementation.

// Actions are recreated here since this avoids passing more parameters and the amount of additional memory consumption is neglegtable.
new UndoAction(this::getCurrentLibraryTab, undoManager, dialogService, stateManager),
new RedoAction(this::getCurrentLibraryTab, undoManager, dialogService, stateManager));
Injector.setModelOrService(EntryEditor.class, entryEditor);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The Injector.setModelOrService call is duplicated in the patch. This could lead to unnecessary redundancy and potential maintenance issues.

this.dialogService = Objects.requireNonNull(dialogService);
this.aiService = Objects.requireNonNull(aiService);
this.preferences = Objects.requireNonNull(preferences);
this.adaptVisibleTabs = adaptVisibleTabs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The use of Objects.requireNonNull should be replaced with @nonnull annotation to ensure the adaptVisibleTabs parameter is not null, aligning with the project's guidelines.

this.dialogService = dialogService;
this.aiService = aiService;
this.stateManager = stateManager;
this.adaptVisibleTabs = adaptVisibleTabs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The assignment of adaptVisibleTabs in the constructor lacks a null check, which violates the fail-fast principle by not immediately handling invalid states.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 18, 2025
@koppor koppor requested review from Siedlerchr and calixtus April 18, 2025 18:00
@calixtus

Copy link
Copy Markdown
Member

I believe to correct future approach would be to observe an observable list of visible tabs, A Pane in the ai package would implement an interface of the EntryEditor interface and that could be added to or removed from the list.

@koppor

koppor commented Apr 18, 2025

Copy link
Copy Markdown
Member Author

I believe to correct future approach would be to observe an observable list of visible tabs, A Pane in the ai package would implement an interface of the EntryEditor interface and that could be added to or removed from the list.

Follow-up?

Still not clear how to access this list from "somewhere".

I was about to add an event bus for the general (cause sender and receiver are decoupled), but did not dare 😅

@calixtus

Copy link
Copy Markdown
Member

Yes follow up eventually. When we rewrite the entry editor. List would sit in the StateManager.

@Siedlerchr

Copy link
Copy Markdown
Member

Yeah, looks a bit weird now. I would have expected an observabelist of tabs in the state manager

@koppor

koppor commented Apr 21, 2025

Copy link
Copy Markdown
Member Author

Yeah, looks a bit weird now. I would have expected an observabelist of tabs in the state manager

That would have been much more effort for me 😅.

I did not use any dependency injection; instead explicitly passing the dependency down.

Proposal: Either someone improves the code significantly the next two weeks or we merge and do follow-up PRs.

Currently, restarting only because of hiding is bad UX IMHO.

@calixtus

Copy link
Copy Markdown
Member

Im ok with follow-up. We need to push forward here. Will also increase pressure on us to finally work on the issues with the entry editor.

@calixtus

Copy link
Copy Markdown
Member

Maybe put a fixme or todo in the code as a bad conscience reminder

@calixtus

Copy link
Copy Markdown
Member

This strategy might also solve #12865

@@ -0,0 +1,11 @@
package org.jabref.gui.entryeditor;

/// This interface is used to adapt the visible tabs in the entry editor based on updated preferences

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment is trivial as it restates the purpose of the interface, which is already clear from the interface name and method signature. Comments should provide additional insights or reasoning.

@trag-bot

trag-bot Bot commented May 9, 2025

Copy link
Copy Markdown

@trag-bot didn't find any issues in the code! ✅✨

@Siedlerchr Siedlerchr enabled auto-merge May 9, 2025 21:28
@Siedlerchr Siedlerchr added this pull request to the merge queue May 9, 2025
@github-actions

github-actions Bot commented May 9, 2025

Copy link
Copy Markdown
Contributor

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

Merged via the queue into main with commit f019d37 May 9, 2025
2 checks passed
@Siedlerchr Siedlerchr deleted the avoid-restart branch May 9, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: entry-editor status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants