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
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
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;

Expand All @@ -15,7 +11,6 @@
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;

Expand All @@ -37,15 +32,18 @@ public FileAnnotationTab(StateManager stateManager,

@Override
public boolean shouldShow(BibEntry entry) {
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;

return entry.getField(StandardField.FILE).isPresent()
&& stateManager.activeTabProperty().get()
.map(tab -> tab.getAnnotationCache()
.getFromCache(entry)
.values()
.stream()
.anyMatch(list -> !list.isEmpty()))
.orElse(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public EntryEditorPreferences getEntryEditorPreferences() {
getBoolean(SHOW_AI_SUMMARY),
getBoolean(SHOW_AI_CHAT),
getBoolean(SHOW_LATEX_CITATIONS),
getBoolean(SHOW_FILE_ANNOTATIONS),
getBoolean(SMART_FILE_ANNOTATIONS),
getBoolean(DEFAULT_SHOW_SOURCE),
getBoolean(VALIDATE_IN_ENTRY_EDITOR),
getBoolean(ALLOW_INTEGER_EDITION_BIBTEX),
Expand All @@ -492,7 +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.shouldShowFileAnnotationsTabProperty(), (_, _, newValue) -> putBoolean(SMART_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,7 +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 smartFileAnnotationsTab;
@FXML private CheckBox enableValidation;
@FXML private CheckBox allowIntegerEdition;
@FXML private CheckBox journalPopupEnabled;
Expand Down Expand Up @@ -56,7 +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());
smartFileAnnotationsTab.selectedProperty().bindBidirectional(viewModel.smartFileAnnotationsTabProperty());
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,7 +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 smartFileAnnotationsTabProperty = new SimpleBooleanProperty();
private final BooleanProperty enableValidationProperty = new SimpleBooleanProperty();
private final BooleanProperty allowIntegerEditionProperty = new SimpleBooleanProperty();
private final BooleanProperty journalPopupProperty = new SimpleBooleanProperty();
Expand Down Expand Up @@ -63,7 +63,7 @@ public void setValues() {
enableAiChatTabProperty.setValue(entryEditorPreferences.shouldShowAiChatTab());
acceptRecommendationsProperty.setValue(mrDlibPreferences.shouldAcceptRecommendations());
enableLatexCitationsTabProperty.setValue(entryEditorPreferences.shouldShowLatexCitationsTab());
enableFileAnnotationsTabProperty.setValue(entryEditorPreferences.shouldShowFileAnnotationsTab());
smartFileAnnotationsTabProperty.setValue(entryEditorPreferences.shouldShowFileAnnotationsTab());
enableValidationProperty.setValue(entryEditorPreferences.shouldEnableValidation());
allowIntegerEditionProperty.setValue(entryEditorPreferences.shouldAllowIntegerEditionBibtex());
journalPopupProperty.setValue(entryEditorPreferences.shouldEnableJournalPopup() == EntryEditorPreferences.JournalPopupEnabled.ENABLED);
Expand Down Expand Up @@ -100,7 +100,7 @@ public void storeSettings() {
entryEditorPreferences.setShouldShowAiChatTab(enableAiChatTabProperty.getValue());
mrDlibPreferences.setAcceptRecommendations(acceptRecommendationsProperty.getValue());
entryEditorPreferences.setShouldShowLatexCitationsTab(enableLatexCitationsTabProperty.getValue());
entryEditorPreferences.setShouldShowFileAnnotationsTab(enableFileAnnotationsTabProperty.getValue());
entryEditorPreferences.setShouldShowFileAnnotationsTab(smartFileAnnotationsTabProperty.getValue());
entryEditorPreferences.setShowSourceTabByDefault(defaultSourceProperty.getValue());
entryEditorPreferences.setEnableValidation(enableValidationProperty.getValue());
entryEditorPreferences.setAllowIntegerEditionBibtex(allowIntegerEditionProperty.getValue());
Expand Down Expand Up @@ -171,8 +171,8 @@ public BooleanProperty enableLatexCitationsTabProperty() {
return enableLatexCitationsTabProperty;
}

public BooleanProperty enableFileAnnotationsTabProperty() {
return enableFileAnnotationsTabProperty;
public BooleanProperty smartFileAnnotationsTabProperty() {
return smartFileAnnotationsTabProperty;
}

public BooleanProperty enableValidationProperty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +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="smartFileAnnotationsTab" 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 @@ -258,7 +258,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 SMART_FILE_ANNOTATIONS = "smartFileAnnotations";
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 @@ -553,7 +553,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(SMART_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