Skip to content

Hide tabs without restart #12958

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Hide tabs without restart #12958

wants to merge 2 commits into from

Conversation

koppor
Copy link
Member

@koppor koppor commented Apr 17, 2025

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

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.


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

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.

) {
super(aiPreferences, externalApplicationsPreferences, dialogService);
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs);
Copy link

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.

) {
super(aiPreferences, externalApplicationsPreferences, dialogService);
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs);
Copy link

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.

@@ -18,6 +18,7 @@ public class AiSummaryTab extends EntryEditorTab {
private final AiService aiService;
private final DialogService dialogService;
private final StateManager stateManager;
private final AdaptVisibleTabs adaptVisibleTabs;
Copy link

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.

@@ -87,7 +87,7 @@
* <p>
* 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

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

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.

TaskExecutor taskExecutor,
CustomLocalDragboard localDragboard
) {
this.stateManager = Objects.requireNonNull(stateManager);
this.dialogService = Objects.requireNonNull(dialogService);
this.aiService = Objects.requireNonNull(aiService);
this.preferences = Objects.requireNonNull(preferences);
this.adaptVisibleTabs = adaptVisibleTabs;
Copy link

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.

@@ -50,6 +53,7 @@ public SidePaneContentFactory(LibraryTabContainer tabContainer,
this.dialogService = dialogService;
this.aiService = aiService;
this.stateManager = stateManager;
this.adaptVisibleTabs = adaptVisibleTabs;
Copy link

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.

Copy link
Contributor

The build of this PR is available at https://builds.jabref.org/pull/12958/merge.

@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
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
Copy link
Member Author

koppor commented Apr 18, 2025

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
Member

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

@Siedlerchr
Copy link
Member

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

@koppor
Copy link
Member Author

koppor commented Apr 21, 2025

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
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
Member

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

@calixtus
Copy link
Member

This strategy might also solve #12865

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