-
-
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
base: main
Are you sure you want to change the base?
Changes from all commits
3ddf7aa
9deeb9c
eab0d25
667308a
9f06f1b
2a33b4e
d5b7033
2d65f10
eade1cf
8463aeb
ebcdbfb
da76288
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,7 +163,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)) | ||
|
@@ -180,10 +181,10 @@ public MainTable(MainTableDataModel model, | |
// force match category column to be the first sort order, (match_category column is always the first column) | ||
this.getSortOrder().addFirst(getColumns().getFirst()); | ||
this.getSortOrder().addListener((ListChangeListener<TableColumn<BibEntryTableViewModel, ?>>) change -> { | ||
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. Do not create white space changes unless necessary. |
||
if (!this.getSortOrder().getFirst().equals(getColumns().getFirst())) { | ||
this.getSortOrder().addFirst(getColumns().getFirst()); | ||
} | ||
}); | ||
if (!this.getSortOrder().getFirst().equals(getColumns().getFirst())) { | ||
this.getSortOrder().addFirst(getColumns().getFirst()); | ||
} | ||
}); | ||
|
||
mainTablePreferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel -> | ||
this.getColumns().stream() | ||
|
@@ -414,7 +415,7 @@ private void setupKeyBindings(KeyBindingRepository keyBindings) { | |
event.consume(); | ||
break; | ||
case SCROLL_TO_PREVIOUS_MATCH_CATEGORY: | ||
scrollToPreviousMatchCategory(); | ||
scrollToPreviousMatchCategory(); | ||
event.consume(); | ||
break; | ||
case OPEN_URL_OR_DOI: | ||
|
@@ -576,13 +577,13 @@ public void setCitationMergeMode(boolean citationMerge) { | |
} | ||
|
||
private void updatePlaceholder(VBox placeholderBox) { | ||
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 same comments go to the rest of the changes in this file. Do not create whitespace changes unless necessary. |
||
if (database.getDatabase().getEntries().isEmpty()) { | ||
this.setPlaceholder(placeholderBox); | ||
// [impl->req~maintable.focus~1] | ||
requestFocus(); | ||
} else { | ||
this.setPlaceholder(null); | ||
} | ||
if (database.getDatabase().getEntries().isEmpty()) { | ||
this.setPlaceholder(placeholderBox); | ||
// [impl->req~maintable.focus~1] | ||
requestFocus(); | ||
} else { | ||
this.setPlaceholder(null); | ||
} | ||
} | ||
|
||
private BibEntry addExampleEntry() { | ||
|
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) { | ||
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 check is unnecessary, since the bibEntries.size() != 1 would not possibly occur in the context of where this action is used. Note that if, more than one entry is selected, the menu button would automatically turn to disabled mode. |
||
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); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
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); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.