-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: support open reference at google scholar #13153
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
Closed
brandon-lau0
wants to merge
18
commits into
JabRef:main
from
brandon-lau0:configurable_external_search_features
Closed
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
3ddf7aa
feat: support searching via google scholar
brandon-lau0 9deeb9c
feat: move search short science and google scholar under search sub-menu
brandon-lau0 eab0d25
feat: allow shortscience and googlescholar search to be configurable
brandon-lau0 667308a
feat: update change log
brandon-lau0 9f06f1b
feat: fix tests
brandon-lau0 2a33b4e
feat: fix import errors
brandon-lau0 d5b7033
test to use List.of()
brandon-lau0 2d65f10
fix import err
brandon-lau0 eade1cf
fix merge conflicts and external link creator tests
brandon-lau0 8463aeb
fix test to use mock for importerpreferences
brandon-lau0 ebcdbfb
remove unused import
brandon-lau0 da76288
Merge branch 'main' into configurable_external_search_features
koppor 483a338
Address comments partially, trigger CI
subhramit 78439d9
Move changelog entries
subhramit c5de9d1
Enhance external link creator
subhramit 4dedbb0
[AI] Enhance test class
subhramit b0e4193
l10n
subhramit 222812c
Resolve changelog conflicts
subhramit 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
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
jabgui/src/main/java/org/jabref/gui/maintable/SearchGoogleScholarAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| 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(); | ||
|
|
||
| if (bibEntries.size() != 1) { | ||
subhramit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dialogService.notify(Localization.lang("This operation requires exactly one item to be selected.")); | ||
calixtus marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
| externalLinkCreator.getGoogleScholarSearchURL(bibEntries.getFirst()).ifPresent(url -> { | ||
| try { | ||
| NativeDesktop.openExternalViewer(databaseContext, preferences, url, StandardField.URL, dialogService, bibEntries.getFirst()); | ||
| } catch (IOException ex) { | ||
calixtus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| dialogService.showErrorDialogAndWait(Localization.lang("Unable to open Google Scholar."), ex); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
jabgui/src/main/java/org/jabref/gui/preferences/websearch/SearchEngineItem.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.