-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Open
brandon-lau0
wants to merge
11
commits into
JabRef:main
Choose a base branch
from
brandon-lau0:configurable_external_search_features
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+316
−48
Open
Changes from all commits
Commits
Show all changes
11 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,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...")), | ||
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 'SEARCH' action should be grouped with other search-related actions to maintain semantic consistency and improve code organization. |
||
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), | ||
|
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) { | ||
dialogService.notify(Localization.lang("This operation requires exactly one item to be selected.")); | ||
calixtus marked this conversation as resolved.
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.
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.