Hide tabs without restart#12958
Conversation
| TaskExecutor taskExecutor | ||
| ) { | ||
| super(aiService, aiPreferences, externalApplicationsPreferences, dialogService); | ||
| super(aiService, aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
The assignment of adaptVisibleTabs in the constructor lacks a null check, which violates the fail-fast principle by not immediately handling invalid states.
|
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 😅 |
|
Yes follow up eventually. When we rewrite the entry editor. List would sit in the StateManager. |
|
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. |
|
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. |
|
Maybe put a fixme or todo in the code as a bad conscience reminder |
|
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 | |||
There was a problem hiding this comment.
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 didn't find any issues in the code! ✅✨ |
|
The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build. |
Follow-up to #12919
Hides tabs without reload.
Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)