-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Added a setting to show File annotations' tab only when the PDF actually contains highlights or comments #13279
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
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 |
|---|---|---|
|
|
@@ -43,6 +43,7 @@ public static JournalPopupEnabled fromString(String status) { | |
| private final BooleanProperty shouldShowAiSummaryTab; | ||
| private final BooleanProperty shouldShowAiChatTab; | ||
| private final BooleanProperty shouldShowLatexCitationsTab; | ||
| private final BooleanProperty shouldShowFileAnnotationsTab; | ||
| private final BooleanProperty showSourceTabByDefault; | ||
| private final BooleanProperty enableValidation; | ||
| private final BooleanProperty allowIntegerEditionBibtex; | ||
|
|
@@ -59,6 +60,7 @@ public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList, | |
| boolean shouldShowAiSummaryTab, | ||
| boolean shouldShowAiChatTab, | ||
| boolean shouldShowLatexCitationsTab, | ||
| boolean shouldShowFileAnnotationsTab, | ||
| boolean showSourceTabByDefault, | ||
| boolean enableValidation, | ||
| boolean allowIntegerEditionBibtex, | ||
|
|
@@ -75,6 +77,7 @@ public EntryEditorPreferences(Map<String, Set<Field>> entryEditorTabList, | |
| this.shouldShowAiSummaryTab = new SimpleBooleanProperty(shouldShowAiSummaryTab); | ||
| this.shouldShowAiChatTab = new SimpleBooleanProperty(shouldShowAiChatTab); | ||
| this.shouldShowLatexCitationsTab = new SimpleBooleanProperty(shouldShowLatexCitationsTab); | ||
| this.shouldShowFileAnnotationsTab = new SimpleBooleanProperty(shouldShowFileAnnotationsTab); | ||
| this.showSourceTabByDefault = new SimpleBooleanProperty(showSourceTabByDefault); | ||
| this.enableValidation = new SimpleBooleanProperty(enableValidation); | ||
| this.allowIntegerEditionBibtex = new SimpleBooleanProperty(allowIntegerEditionBibtex); | ||
|
|
@@ -161,6 +164,18 @@ public void setShouldShowLatexCitationsTab(boolean shouldShowLatexCitationsTab) | |
| this.shouldShowLatexCitationsTab.set(shouldShowLatexCitationsTab); | ||
| } | ||
|
|
||
| public boolean shouldShowFileAnnotationsTab() { | ||
|
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 method should return an Optional instead of a primitive boolean to avoid returning null and adhere to modern Java practices.
Contributor
Author
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. is that really necessary?I don't think it could ever return a null value
Member
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. Take the comments with a grain of salt. In this case the bot is wrong |
||
| return shouldShowFileAnnotationsTab.get(); | ||
| } | ||
|
|
||
| public BooleanProperty shouldShowFileAnnotationsTabProperty() { | ||
| return shouldShowFileAnnotationsTab; | ||
| } | ||
|
|
||
| public void setShouldShowFileAnnotationsTab(boolean shouldShowFileAnnotationsTab) { | ||
| this.shouldShowFileAnnotationsTab.set(shouldShowFileAnnotationsTab); | ||
| } | ||
|
|
||
| public boolean showSourceTabByDefault() { | ||
| return showSourceTabByDefault.get(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,51 @@ | ||
| package org.jabref.gui.entryeditor.fileannotationtab; | ||
|
|
||
| import java.nio.file.Path; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import javafx.scene.Parent; | ||
| import javafx.scene.control.Tooltip; | ||
|
|
||
| import org.jabref.gui.StateManager; | ||
| import org.jabref.gui.entryeditor.EntryEditorPreferences; | ||
| import org.jabref.gui.entryeditor.EntryEditorTab; | ||
| import org.jabref.gui.preferences.GuiPreferences; | ||
| import org.jabref.logic.l10n.Localization; | ||
| import org.jabref.logic.pdf.FileAnnotationCache; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.StandardField; | ||
| import org.jabref.model.pdf.FileAnnotation; | ||
|
|
||
| import com.airhacks.afterburner.views.ViewLoader; | ||
|
|
||
| public class FileAnnotationTab extends EntryEditorTab { | ||
|
|
||
| public static final String NAME = "File annotations"; | ||
|
|
||
| private final StateManager stateManager; | ||
| private final EntryEditorPreferences entryEditorPreferences; | ||
|
|
||
| public FileAnnotationTab(StateManager stateManager) { | ||
| public FileAnnotationTab(StateManager stateManager, | ||
| GuiPreferences preferences) { | ||
|
Comment on lines
+29
to
+30
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 should not allow null values for 'stateManager' and 'preferences'. Consider using JSpecify @nonnull annotations to enforce non-null parameters.
Contributor
Author
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. is that really necessary?
Member
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. no |
||
| this.stateManager = stateManager; | ||
| this.entryEditorPreferences = preferences.getEntryEditorPreferences(); | ||
|
|
||
| setText(Localization.lang("File annotations")); | ||
| setTooltip(new Tooltip(Localization.lang("Show file annotations"))); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean shouldShow(BibEntry entry) { | ||
| return entry.getField(StandardField.FILE).isPresent(); | ||
| boolean hasAnnotations = false; | ||
| if (!entryEditorPreferences.shouldShowFileAnnotationsTab()) { | ||
| return entry.getField(StandardField.FILE).isPresent(); | ||
| } | ||
| if (stateManager.activeTabProperty().get().isPresent()) { | ||
ZodGaz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Map<Path, List<FileAnnotation>> fileAnnotations = stateManager.activeTabProperty().get().get().getAnnotationCache().getFromCache(entry); | ||
| hasAnnotations = fileAnnotations.values().stream().anyMatch(list -> !list.isEmpty()); | ||
| } | ||
| return entry.getField(StandardField.FILE).isPresent() && hasAnnotations; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.