-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
base: main
Are you sure you want to change the base?
Hide tabs without restart #12958
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.ai.components.aichat.AiChatGuardedComponent; | ||
import org.jabref.gui.entryeditor.AdaptVisibleTabs; | ||
import org.jabref.gui.frame.ExternalApplicationsPreferences; | ||
import org.jabref.gui.util.DynamicallyChangeableNode; | ||
import org.jabref.logic.ai.AiPreferences; | ||
|
@@ -16,11 +17,13 @@ public abstract class AiPrivacyNoticeGuardedComponent extends DynamicallyChangea | |
private final AiPreferences aiPreferences; | ||
private final ExternalApplicationsPreferences externalApplicationsPreferences; | ||
private final DialogService dialogService; | ||
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. Choose a reason for hiding this commentThe 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. |
||
this.aiPreferences = aiPreferences; | ||
this.externalApplicationsPreferences = externalApplicationsPreferences; | ||
this.dialogService = dialogService; | ||
this.adaptVisibleTabs = adaptVisibleTabs; | ||
|
||
aiPreferences.enableAiProperty().addListener(observable -> rebuildUi()); | ||
} | ||
|
@@ -34,7 +37,8 @@ public final void rebuildUi() { | |
aiPreferences, | ||
this::rebuildUi, | ||
externalApplicationsPreferences, | ||
dialogService | ||
dialogService, | ||
adaptVisibleTabs | ||
) | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.ai.components.privacynotice.AiPrivacyNoticeGuardedComponent; | ||
import org.jabref.gui.ai.components.util.errorstate.ErrorStateComponent; | ||
import org.jabref.gui.entryeditor.AdaptVisibleTabs; | ||
import org.jabref.gui.frame.ExternalApplicationsPreferences; | ||
import org.jabref.logic.ai.AiPreferences; | ||
import org.jabref.logic.ai.AiService; | ||
|
@@ -39,9 +40,10 @@ public SummaryComponent(BibDatabaseContext bibDatabaseContext, | |
AiPreferences aiPreferences, | ||
ExternalApplicationsPreferences externalApplicationsPreferences, | ||
CitationKeyPatternPreferences citationKeyPatternPreferences, | ||
DialogService dialogService | ||
DialogService dialogService, | ||
AdaptVisibleTabs adaptVisibleTabs | ||
) { | ||
super(aiPreferences, externalApplicationsPreferences, dialogService); | ||
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
this.bibDatabaseContext = bibDatabaseContext; | ||
this.entry = entry; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.ai.components.privacynotice.AiPrivacyNoticeGuardedComponent; | ||
import org.jabref.gui.ai.components.util.errorstate.ErrorStateComponent; | ||
import org.jabref.gui.entryeditor.AdaptVisibleTabs; | ||
import org.jabref.gui.frame.ExternalApplicationsPreferences; | ||
import org.jabref.gui.util.UiTaskExecutor; | ||
import org.jabref.logic.ai.AiPreferences; | ||
|
@@ -24,9 +25,10 @@ public abstract class EmbeddingModelGuardedComponent extends AiPrivacyNoticeGuar | |
public EmbeddingModelGuardedComponent(AiService aiService, | ||
AiPreferences aiPreferences, | ||
ExternalApplicationsPreferences externalApplicationsPreferences, | ||
DialogService dialogService | ||
DialogService dialogService, | ||
AdaptVisibleTabs adaptVisibleTabs | ||
) { | ||
super(aiPreferences, externalApplicationsPreferences, dialogService); | ||
super(aiPreferences, externalApplicationsPreferences, dialogService, adaptVisibleTabs); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
this.aiService = aiService; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jabref.gui.entryeditor; | ||
|
||
public interface AdaptVisibleTabs { | ||
/** | ||
* Adapt the visible tabs to the current entry type. | ||
*/ | ||
void adaptVisibleTabs(); | ||
} |
Original file line number | Diff line number | Diff line 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
private final AiPreferences aiPreferences; | ||
private final ExternalApplicationsPreferences externalApplicationsPreferences; | ||
private final CitationKeyPatternPreferences citationKeyPatternPreferences; | ||
|
@@ -26,10 +27,12 @@ public class AiSummaryTab extends EntryEditorTab { | |
public AiSummaryTab(AiService aiService, | ||
DialogService dialogService, | ||
StateManager stateManager, | ||
AdaptVisibleTabs adaptVisibleTabs, | ||
GuiPreferences preferences) { | ||
this.aiService = aiService; | ||
this.dialogService = dialogService; | ||
this.stateManager = stateManager; | ||
this.adaptVisibleTabs = adaptVisibleTabs; | ||
|
||
this.aiPreferences = preferences.getAiPreferences(); | ||
this.externalApplicationsPreferences = preferences.getExternalApplicationsPreferences(); | ||
|
@@ -58,7 +61,8 @@ protected void bindToEntry(BibEntry entry) { | |
aiPreferences, | ||
externalApplicationsPreferences, | ||
citationKeyPatternPreferences, | ||
dialogService | ||
dialogService, | ||
adaptVisibleTabs | ||
)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line 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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
private final Supplier<LibraryTab> tabSupplier; | ||
private final ExternalFilesEntryLinker fileLinker; | ||
private final PreviewPanel previewPanel; | ||
|
@@ -336,8 +336,8 @@ private List<EntryEditorTab> createTabs() { | |
tabs.add(sourceTab); | ||
tabs.add(new LatexCitationsTab(preferences, dialogService, stateManager, directoryMonitor)); | ||
tabs.add(new FulltextSearchResultsTab(stateManager, preferences, dialogService, taskExecutor)); | ||
tabs.add(new AiSummaryTab(aiService, dialogService, stateManager, preferences)); | ||
tabs.add(new AiChatTab(aiService, dialogService, preferences, stateManager, taskExecutor)); | ||
tabs.add(new AiSummaryTab(aiService, dialogService, stateManager, this, preferences)); | ||
tabs.add(new AiChatTab(aiService, dialogService, preferences, stateManager, this, taskExecutor)); | ||
|
||
return tabs; | ||
} | ||
|
@@ -374,10 +374,8 @@ private Map<String, Set<Field>> getAdditionalUserConfiguredTabs() { | |
return entryEditorTabList; | ||
} | ||
|
||
/** | ||
* Adapt the visible tabs to the current entry type. | ||
*/ | ||
private void adaptVisibleTabs() { | ||
@Override | ||
public void adaptVisibleTabs() { | ||
// We need to find out, which tabs will be shown (and which not anymore) and remove and re-add the appropriate tabs | ||
// to the editor. We cannot to simply remove all and re-add the complete list of visible tabs, because | ||
// the tabs give an ugly animation the looks like all tabs are shifting in from the right. In other words: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,12 @@ public JabRefFrame(Stage mainStage, | |
dialogService, | ||
SearchType.NORMAL_SEARCH); | ||
|
||
this.entryEditor = new EntryEditor(this::getCurrentLibraryTab, | ||
// 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. Choose a reason for hiding this commentThe 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.sidePane = new SidePane( | ||
this, | ||
this.preferences, | ||
|
@@ -177,17 +183,12 @@ public JabRefFrame(Stage mainStage, | |
dialogService, | ||
aiService, | ||
stateManager, | ||
entryEditor, | ||
fileUpdateMonitor, | ||
entryTypesManager, | ||
clipBoardManager, | ||
undoManager); | ||
|
||
this.entryEditor = new EntryEditor(this::getCurrentLibraryTab, | ||
// 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); | ||
|
||
this.pushToApplicationCommand = new PushToApplicationCommand( | ||
stateManager, | ||
dialogService, | ||
|
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.
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.