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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added "IEEE" as another option for parsing plain text citations. [#14233](github.com/JabRef/jabref/pull/14233)
- We added automatic date-based groups that create year/month/day subgroups from an entry’s date fields. [#10822](https://github.com/JabRef/jabref/issues/10822)
- We added `doi-to-bibtex` to `JabKit`. [#14244](https://github.com/JabRef/jabref/pull/14244)
- We added support for "Search Google Scholar" to quickly search for a selected entry's title in Google Scholar directly from the main table's context menu [#12268](https://github.com/JabRef/jabref/issues/12268)
- We introduced a new "Search Engine URL Template" setting in Preferences to allow users to customize their search engine URL templates [#12268](https://github.com/JabRef/jabref/issues/12268)

### Changed

Expand Down Expand Up @@ -47,6 +49,18 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- When adding an entry to a library, a warning is displayed if said entry already exists in an active library. [#13261](https://github.com/JabRef/jabref/issues/13261)
- We added the field `monthfiled` to the default list of fields to resolve BibTeX-Strings for [#13375](https://github.com/JabRef/jabref/issues/13375)
- We added a new ID based fetcher for [EuropePMC](https://europepmc.org/). [#13389](https://github.com/JabRef/jabref/pull/13389)
- We added an initial [cite as you write](https://retorque.re/zotero-better-bibtex/citing/cayw/) endpoint. [#13187](https://github.com/JabRef/jabref/issues/13187)

### Changed

- We improved the citations relations caching by implementing an offline storage. [#11189](https://github.com/JabRef/jabref/issues/11189)
- We added a tooltip to keywords that resemble Math Subject Classification (MSC) codes. [#12944](https://github.com/JabRef/jabref/issues/12944)
- We added a formatter to convert keywords that resemble MSC codes to their descriptions. [#12944](https://github.com/JabRef/jabref/issues/12944)
- We introduced a new command line application called `jabkit`. [#13012](https://github.com/JabRef/jabref/pull/13012) [#110](https://github.com/JabRef/jabref/issues/110)
- We added a new "Add JabRef suggested groups" option in the context menu of "All entries". [#12659](https://github.com/JabRef/jabref/issues/12659)
- We added an option to create entries directly from Bib(La)TeX sources to the 'Create New Entry' tool. [#8808](https://github.com/JabRef/jabref/issues/8808)
- We added the provision to choose different CSL bibliography body formats (e.g. First Line Indent, Hanging Indent, Bibliography 1, etc.) in the LibreOffice integration. [#13049](https://github.com/JabRef/jabref/issues/13049)
- We added "Bibliography Heading" to the available CSL bibliography header formats in the LibreOffice integration. [#13049](https://github.com/JabRef/jabref/issues/13049)
- We added quick settings for welcome tab. [#12664](https://github.com/JabRef/jabref/issues/12664)
- We added pagination support for the web search entries dialog, improving navigation for large search results. [#5507](https://github.com/JabRef/jabref/issues/5507)
- We added "copy preview as markdown" feature. [#12552](https://github.com/JabRef/jabref/issues/12552)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public enum StandardActions implements Action {
EXTRACT_FILE_REFERENCES_OFFLINE(Localization.lang("Extract references from file (offline)"), IconTheme.JabRefIcons.FILE_STAR),
OPEN_URL(Localization.lang("Open URL or DOI"), IconTheme.JabRefIcons.WWW, KeyBinding.OPEN_URL_OR_DOI),
SEARCH_SHORTSCIENCE(Localization.lang("Search ShortScience")),
SEARCH_GOOGLE_SCHOLAR(Localization.lang("Search Google Scholar")),
SEARCH(Localization.lang("Search...")),
MERGE_WITH_FETCHED_ENTRY(Localization.lang("Get bibliographic data from %0", "DOI/ISBN/..."), KeyBinding.MERGE_WITH_FETCHED_ENTRY),
BATCH_MERGE_WITH_FETCHED_ENTRY(Localization.lang("Get bibliographic data from %0 (fully automated)", "DOI/ISBN/...")),
ATTACH_FILE(Localization.lang("Attach file"), IconTheme.JabRefIcons.ATTACH_FILE),
Expand Down
3 changes: 2 additions & 1 deletion jabgui/src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public MainTable(MainTableDataModel model,
taskExecutor,
Injector.instantiateModelOrService(JournalAbbreviationRepository.class),
entryTypesManager,
importHandler))
importHandler,
preferences.getImporterPreferences()))
.withPseudoClass(MATCHING_SEARCH_AND_GROUPS, entry -> entry.matchCategory().isEqualTo(MatchCategory.MATCHING_SEARCH_AND_GROUPS))
.withPseudoClass(MATCHING_SEARCH_NOT_GROUPS, entry -> entry.matchCategory().isEqualTo(MatchCategory.MATCHING_SEARCH_NOT_GROUPS))
.withPseudoClass(MATCHING_GROUPS_NOT_SEARCH, entry -> entry.matchCategory().isEqualTo(MatchCategory.MATCHING_GROUPS_NOT_SEARCH))
Expand Down
20 changes: 17 additions & 3 deletions jabgui/src/main/java/org/jabref/gui/maintable/RightClickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
Expand All @@ -60,7 +61,8 @@ public static ContextMenu create(BibEntryTableViewModel entry,
TaskExecutor taskExecutor,
JournalAbbreviationRepository abbreviationRepository,
BibEntryTypesManager entryTypesManager,
ImportHandler importHandler) {
ImportHandler importHandler,
ImporterPreferences importerPreferences) {
ActionFactory factory = new ActionFactory();
ContextMenu contextMenu = new ContextMenu();

Expand Down Expand Up @@ -99,8 +101,7 @@ public static ContextMenu create(BibEntryTableViewModel entry,
extractFileReferencesOffline,

factory.createMenuItem(StandardActions.OPEN_URL, new OpenUrlAction(dialogService, stateManager, preferences)),
factory.createMenuItem(StandardActions.SEARCH_SHORTSCIENCE, new SearchShortScienceAction(dialogService, stateManager, preferences)),

createSearchSubMenu(factory, dialogService, stateManager, preferences, importerPreferences),
new SeparatorMenuItem(),

new ChangeEntryTypeMenu(libraryTab.getSelectedEntries(), libraryTab.getBibDatabaseContext(), undoManager, entryTypesManager).asSubMenu(),
Expand Down Expand Up @@ -237,4 +238,17 @@ private static Menu createSendSubMenu(ActionFactory factory,

return sendMenu;
}

private static Menu createSearchSubMenu(ActionFactory factory,
DialogService dialogService,
StateManager stateManager,
GuiPreferences preferences,
ImporterPreferences importerPreferences) {
Menu searchMenu = factory.createMenu(StandardActions.SEARCH);
searchMenu.getItems().addAll(
factory.createMenuItem(StandardActions.SEARCH_SHORTSCIENCE, new SearchShortScienceAction(dialogService, stateManager, preferences, importerPreferences)),
factory.createMenuItem(StandardActions.SEARCH_GOOGLE_SCHOLAR, new SearchGoogleScholarAction(dialogService, stateManager, preferences, importerPreferences))
);
return searchMenu;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.jabref.gui.maintable;

import java.io.IOException;
import java.util.List;

import javafx.beans.binding.BooleanExpression;

import org.jabref.gui.DialogService;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.ExternalLinkCreator;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;

import static org.jabref.gui.actions.ActionHelper.isFieldSetForSelectedEntry;
import static org.jabref.gui.actions.ActionHelper.needsEntriesSelected;

public class SearchGoogleScholarAction extends SimpleCommand {
private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;
private final ExternalLinkCreator externalLinkCreator;

public SearchGoogleScholarAction(DialogService dialogService, StateManager stateManager, GuiPreferences preferences, ImporterPreferences importerPreferences) {
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.externalLinkCreator = new ExternalLinkCreator(importerPreferences);

BooleanExpression fieldIsSet = isFieldSetForSelectedEntry(StandardField.TITLE, stateManager);
this.executable.bind(needsEntriesSelected(1, stateManager).and(fieldIsSet));
}

@Override
public void execute() {
stateManager.getActiveDatabase().ifPresent(databaseContext -> {
final List<BibEntry> bibEntries = stateManager.getSelectedEntries();
externalLinkCreator.getGoogleScholarSearchURL(bibEntries.getFirst()).ifPresent(url -> {
try {
NativeDesktop.openExternalViewer(databaseContext, preferences, url, StandardField.URL, dialogService, bibEntries.getFirst());
} catch (IOException ex) {
dialogService.showErrorDialogAndWait(Localization.lang("Unable to open Google Scholar."), ex);
}
});
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.ExternalLinkCreator;
import org.jabref.model.entry.BibEntry;
Expand All @@ -22,11 +23,13 @@ public class SearchShortScienceAction extends SimpleCommand {
private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;
private final ExternalLinkCreator externalLinkCreator;

public SearchShortScienceAction(DialogService dialogService, StateManager stateManager, GuiPreferences preferences) {
public SearchShortScienceAction(DialogService dialogService, StateManager stateManager, GuiPreferences preferences, ImporterPreferences importerPreferences) {
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.externalLinkCreator = new ExternalLinkCreator(importerPreferences);

BooleanExpression fieldIsSet = isFieldSetForSelectedEntry(StandardField.TITLE, stateManager);
this.executable.bind(needsEntriesSelected(1, stateManager).and(fieldIsSet));
Expand All @@ -41,7 +44,7 @@ public void execute() {
dialogService.notify(Localization.lang("This operation requires exactly one item to be selected."));
return;
}
ExternalLinkCreator.getShortScienceSearchURL(bibEntries.getFirst()).ifPresent(url -> {
externalLinkCreator.getShortScienceSearchURL(bibEntries.getFirst()).ifPresent(url -> {
try {
NativeDesktop.openExternalViewer(databaseContext, preferences, url, StandardField.URL, dialogService, bibEntries.getFirst());
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.jabref.gui.preferences.websearch;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class SearchEngineItem {
private final StringProperty name;
private final StringProperty urlTemplate;

public SearchEngineItem(String name, String urlTemplate) {
this.name = new SimpleStringProperty(name);
this.urlTemplate = new SimpleStringProperty(urlTemplate);
}

public StringProperty nameProperty() {
return name;
}

public StringProperty urlTemplateProperty() {
return urlTemplate;
}

public String getName() {
return name.get();
}

public String getUrlTemplate() {
return urlTemplate.get();
}

public void setUrlTemplate(String urlTemplate) {
this.urlTemplate.set(urlTemplate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewMode
@FXML private CheckBox grobidEnabled;
@FXML private TextField grobidURL;

@FXML private TableView<SearchEngineItem> searchEngineTable;
@FXML private TableColumn<SearchEngineItem, String> searchEngineName;
@FXML private TableColumn<SearchEngineItem, String> searchEngineUrlTemplate;

@FXML private TableView<FetcherApiKey> apiKeySelectorTable;
@FXML private TableColumn<FetcherApiKey, String> apiKeyName;
@FXML private TableColumn<FetcherApiKey, String> customApiKey;
@FXML private TableColumn<FetcherApiKey, Boolean> useCustomApiKey;
@FXML private Button testCustomApiKey;

@FXML private CheckBox persistApiKeys;
@FXML private SplitPane persistentTooltipWrapper; // The disabled persistApiKeys control does not show tooltips
@FXML private TableView<StudyCatalogItem> catalogTable;
@FXML private TableColumn<StudyCatalogItem, Boolean> catalogEnabledColumn;
@FXML private TableColumn<StudyCatalogItem, String> catalogColumn;

@FXML private VBox fetchersContainer;

private final ReadOnlyBooleanProperty refAiEnabled;
Expand Down Expand Up @@ -77,6 +93,16 @@ public String getTabName() {
public void initialize() {
this.viewModel = new WebSearchTabViewModel(preferences, refAiEnabled, taskExecutor);

searchEngineName.setCellValueFactory(param -> param.getValue().nameProperty());
searchEngineName.setCellFactory(TextFieldTableCell.forTableColumn());
searchEngineName.setEditable(false);

searchEngineUrlTemplate.setCellValueFactory(param -> param.getValue().urlTemplateProperty());
searchEngineUrlTemplate.setCellFactory(TextFieldTableCell.forTableColumn());
searchEngineUrlTemplate.setEditable(true);

searchEngineTable.setItems(viewModel.getSearchEngines());

enableWebSearch.selectedProperty().bindBidirectional(viewModel.enableWebSearchProperty());
warnAboutDuplicatesOnImport.selectedProperty().bindBidirectional(viewModel.warnAboutDuplicatesOnImportProperty());
downloadLinkedOnlineFiles.selectedProperty().bindBidirectional(viewModel.shouldDownloadLinkedOnlineFiles());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.function.Consumer;
Expand Down Expand Up @@ -72,6 +73,8 @@ public class WebSearchTabViewModel implements PreferenceTabViewModel {
private final BooleanProperty apikeyPersistProperty = new SimpleBooleanProperty();
private final BooleanProperty apikeyPersistAvailableProperty = new SimpleBooleanProperty();

private final ObservableList<SearchEngineItem> searchEngines = FXCollections.observableArrayList();

private final CliPreferences preferences;
private final DOIPreferences doiPreferences;
private final GrobidPreferences grobidPreferences;
Expand All @@ -96,6 +99,7 @@ public WebSearchTabViewModel(CliPreferences preferences, ReadOnlyBooleanProperty
this.refAiEnabled = refAiEnabled;

setupPlainCitationParsers(preferences);
setupSearchEngines();
}

private void setupPlainCitationParsers(CliPreferences preferences) {
Expand Down Expand Up @@ -136,6 +140,14 @@ private void setupPlainCitationParsers(CliPreferences preferences) {
});
}

private void setupSearchEngines() {
// Add default search engines
searchEngines.addAll(
new SearchEngineItem("Google Scholar", "https://scholar.google.com/scholar?q={title}"),
new SearchEngineItem("Short Science", "https://www.shortscience.org/internalsearch?q={title}")
);
}

@Override
public void setValues() {
enableWebSearchProperty.setValue(importerPreferences.areImporterEnabled());
Expand Down Expand Up @@ -184,6 +196,13 @@ public void setValues() {

apikeyPersistAvailableProperty.setValue(OS.isKeyringAvailable());
apikeyPersistProperty.setValue(preferences.getImporterPreferences().shouldPersistCustomKeys());

// Load custom URL templates from preferences if they exist
Map<String, String> savedTemplates = preferences.getImporterPreferences().getSearchEngineUrlTemplates();
if (!savedTemplates.isEmpty()) {
searchEngines.clear();
savedTemplates.forEach((name, url) -> searchEngines.add(new SearchEngineItem(name, url)));
}
}

@Override
Expand Down Expand Up @@ -223,6 +242,14 @@ public void storeSettings() {
if (apikeyPersistAvailableProperty.get()) {
preferences.getImporterPreferences().getApiKeys().addAll(apiKeysToStore);
}

// Save custom URL templates to preferences
Map<String, String> templates = searchEngines.stream()
.collect(Collectors.toMap(
SearchEngineItem::getName,
SearchEngineItem::getUrlTemplate
));
preferences.getImporterPreferences().setSearchEngineUrlTemplates(templates);
}

public BooleanProperty enableWebSearchProperty() {
Expand Down Expand Up @@ -289,6 +316,10 @@ public IntegerProperty citationsRelationsStoreTTLProperty() {
return citationsRelationStoreTTL;
}

public ObservableList<SearchEngineItem> getSearchEngines() {
return searchEngines;
}

public void checkApiKey(FetcherViewModel fetcherViewModel, String apiKey, Consumer<Boolean> onFinished) {
Callable<Boolean> tester = () -> {
WebFetcher webFetcher = fetcherViewModel.getFetcher();
Expand Down
Loading
Loading