Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added support for import of a Refer/BibIX file format. [#13069](https://github.com/JabRef/jabref/issues/13069)
- We added a new `jabkit` command `pseudonymize` to pseudonymize the library. [#13109](https://github.com/JabRef/jabref/issues/13109)
- We added functionality to focus running instance when trying to start a second instance. [#13129](https://github.com/JabRef/jabref/issues/13129)
- We added a new setting in the 'Entry Editor' preferences to hide the 'File Annotations' tab when no annotations are available. [#13143](https://github.com/JabRef/jabref/issues/13143)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private List<EntryEditorTab> createTabs() {
}

tabs.add(new MathSciNetTab());
tabs.add(new FileAnnotationTab(stateManager));
tabs.add(new FileAnnotationTab(stateManager, preferences));
tabs.add(new SciteTab(preferences, taskExecutor, dialogService));
tabs.add(new CitationRelationsTab(dialogService, undoManager, stateManager, fileMonitor, preferences, taskExecutor, bibEntryTypesManager));
tabs.add(new RelatedArticlesTab(buildInfo, preferences, dialogService, stateManager, taskExecutor));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -161,6 +164,18 @@ public void setShouldShowLatexCitationsTab(boolean shouldShowLatexCitationsTab)
this.shouldShowLatexCitationsTab.set(shouldShowLatexCitationsTab);
}

public boolean shouldShowFileAnnotationsTab() {
Copy link

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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();
}
Expand Down
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
Copy link

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is that really necessary?

Copy link
Member

Choose a reason for hiding this comment

The 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()) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ public EntryEditorPreferences getEntryEditorPreferences() {
getBoolean(SHOW_AI_SUMMARY),
getBoolean(SHOW_AI_CHAT),
getBoolean(SHOW_LATEX_CITATIONS),
getBoolean(SHOW_FILE_ANNOTATIONS),
getBoolean(DEFAULT_SHOW_SOURCE),
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
Expand All @@ -491,6 +492,7 @@ public EntryEditorPreferences getEntryEditorPreferences() {
EasyBind.listen(entryEditorPreferences.shouldShowAiSummaryTabProperty(), (_, _, newValue) -> putBoolean(SHOW_AI_SUMMARY, newValue));
EasyBind.listen(entryEditorPreferences.shouldShowAiChatTabProperty(), (_, _, newValue) -> putBoolean(SHOW_AI_CHAT, newValue));
EasyBind.listen(entryEditorPreferences.shouldShowLatexCitationsTabProperty(), (_, _, newValue) -> putBoolean(SHOW_LATEX_CITATIONS, newValue));
EasyBind.listen(entryEditorPreferences.shouldShowFileAnnotationsTabProperty(), (_, _, newValue) -> putBoolean(SHOW_FILE_ANNOTATIONS, newValue));
EasyBind.listen(entryEditorPreferences.showSourceTabByDefaultProperty(), (_, _, newValue) -> putBoolean(DEFAULT_SHOW_SOURCE, newValue));
EasyBind.listen(entryEditorPreferences.enableValidationProperty(), (_, _, newValue) -> putBoolean(VALIDATE_IN_ENTRY_EDITOR, newValue));
EasyBind.listen(entryEditorPreferences.allowIntegerEditionBibtexProperty(), (_, _, newValue) -> putBoolean(ALLOW_INTEGER_EDITION_BIBTEX, newValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class EntryEditorTab extends AbstractPreferenceTabView<EntryEditorTabView
@FXML private CheckBox enableAiChatTab;
@FXML private CheckBox acceptRecommendations;
@FXML private CheckBox enableLatexCitationsTab;
@FXML private CheckBox enableFileAnnotationsTab;
@FXML private CheckBox enableValidation;
@FXML private CheckBox allowIntegerEdition;
@FXML private CheckBox journalPopupEnabled;
Expand Down Expand Up @@ -55,6 +56,7 @@ public void initialize() {
enableAiChatTab.selectedProperty().bindBidirectional(viewModel.enableAiChatTabProperty());
acceptRecommendations.selectedProperty().bindBidirectional(viewModel.acceptRecommendationsProperty());
enableLatexCitationsTab.selectedProperty().bindBidirectional(viewModel.enableLatexCitationsTabProperty());
enableFileAnnotationsTab.selectedProperty().bindBidirectional(viewModel.enableFileAnnotationsTabProperty());
enableValidation.selectedProperty().bindBidirectional(viewModel.enableValidationProperty());
allowIntegerEdition.selectedProperty().bindBidirectional(viewModel.allowIntegerEditionProperty());
journalPopupEnabled.selectedProperty().bindBidirectional(viewModel.journalPopupProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class EntryEditorTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty enableAiChatTabProperty = new SimpleBooleanProperty();
private final BooleanProperty acceptRecommendationsProperty = new SimpleBooleanProperty();
private final BooleanProperty enableLatexCitationsTabProperty = new SimpleBooleanProperty();
private final BooleanProperty enableFileAnnotationsTabProperty = new SimpleBooleanProperty();
private final BooleanProperty enableValidationProperty = new SimpleBooleanProperty();
private final BooleanProperty allowIntegerEditionProperty = new SimpleBooleanProperty();
private final BooleanProperty journalPopupProperty = new SimpleBooleanProperty();
Expand Down Expand Up @@ -62,6 +63,7 @@ public void setValues() {
enableAiChatTabProperty.setValue(entryEditorPreferences.shouldShowAiChatTab());
acceptRecommendationsProperty.setValue(mrDlibPreferences.shouldAcceptRecommendations());
enableLatexCitationsTabProperty.setValue(entryEditorPreferences.shouldShowLatexCitationsTab());
enableFileAnnotationsTabProperty.setValue(entryEditorPreferences.shouldShowFileAnnotationsTab());
enableValidationProperty.setValue(entryEditorPreferences.shouldEnableValidation());
allowIntegerEditionProperty.setValue(entryEditorPreferences.shouldAllowIntegerEditionBibtex());
journalPopupProperty.setValue(entryEditorPreferences.shouldEnableJournalPopup() == EntryEditorPreferences.JournalPopupEnabled.ENABLED);
Expand Down Expand Up @@ -98,6 +100,7 @@ public void storeSettings() {
entryEditorPreferences.setShouldShowAiChatTab(enableAiChatTabProperty.getValue());
mrDlibPreferences.setAcceptRecommendations(acceptRecommendationsProperty.getValue());
entryEditorPreferences.setShouldShowLatexCitationsTab(enableLatexCitationsTabProperty.getValue());
entryEditorPreferences.setShouldShowFileAnnotationsTab(enableFileAnnotationsTabProperty.getValue());
entryEditorPreferences.setShowSourceTabByDefault(defaultSourceProperty.getValue());
entryEditorPreferences.setEnableValidation(enableValidationProperty.getValue());
entryEditorPreferences.setAllowIntegerEditionBibtex(allowIntegerEditionProperty.getValue());
Expand Down Expand Up @@ -168,6 +171,10 @@ public BooleanProperty enableLatexCitationsTabProperty() {
return enableLatexCitationsTabProperty;
}

public BooleanProperty enableFileAnnotationsTabProperty() {
return enableFileAnnotationsTabProperty;
}

public BooleanProperty enableValidationProperty() {
return enableValidationProperty;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</CheckBox>
<CheckBox fx:id="defaultSource" text="%Show BibTeX source by default"/>
<CheckBox fx:id="enableLatexCitationsTab" text="%Show tab 'LaTeX citations'"/>
<CheckBox fx:id="enableFileAnnotationsTab" text="%Show tab 'File annotations' only if it contains highlights or comments"/>
<CheckBox fx:id="enableAiSummaryTab" text="%Show tab 'AI Summary'"/>
<CheckBox fx:id="enableAiChatTab" text="%Show tab 'AI Chat'"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public class JabRefCliPreferences implements CliPreferences {
public static final String NAME_FORMATER_KEY = "nameFormatterNames";
public static final String SHOW_RECOMMENDATIONS = "showRecommendations";
public static final String SHOW_AI_SUMMARY = "showAiSummary";
public static final String SHOW_FILE_ANNOTATIONS = "showFileAnnotations";
public static final String SHOW_AI_CHAT = "showAiChat";
public static final String ACCEPT_RECOMMENDATIONS = "acceptRecommendations";
public static final String SHOW_LATEX_CITATIONS = "showLatexCitations";
Expand Down Expand Up @@ -550,6 +551,7 @@ protected JabRefCliPreferences() {
defaults.put(SHOW_RECOMMENDATIONS, Boolean.TRUE);
defaults.put(SHOW_AI_CHAT, Boolean.TRUE);
defaults.put(SHOW_AI_SUMMARY, Boolean.TRUE);
defaults.put(SHOW_FILE_ANNOTATIONS, Boolean.TRUE);
defaults.put(ACCEPT_RECOMMENDATIONS, Boolean.FALSE);
defaults.put(SHOW_LATEX_CITATIONS, Boolean.TRUE);
defaults.put(SHOW_SCITE_TAB, Boolean.TRUE);
Expand Down
1 change: 1 addition & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,7 @@ There\ already\ exists\ an\ external\ file\ type\ with\ the\ same\ name=There al


Show\ tab\ 'LaTeX\ citations'=Show tab 'LaTeX citations'
Show\ tab\ 'File\ annotations'\ only\ if\ it\ contains\ highlights\ or\ comments=Show tab 'File annotations' only if it contains highlights or comments
Show\ tab\ 'Citation\ information'=Show tab 'Citation information'
Search\ scite.ai\ for\ Smart\ Citations=Search scite.ai for Smart Citations
See\ full\ report\ at\ [%0]=See full report at [%0]
Expand Down