Skip to content
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

Show information about the journal #10015

Merged
merged 44 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d64b87a
add script for getting journal data
aqurilla Jun 16, 2023
44abbc2
reduce json size
aqurilla Jun 16, 2023
c01434a
add journal info UI button & gui components
aqurilla Jun 18, 2023
047ad88
add placeholder charts
aqurilla Jun 19, 2023
dd1532f
add journal information fetcher
aqurilla Jun 20, 2023
68fc579
run fetch as background task
aqurilla Jun 22, 2023
3069b02
fetch data using entry issn
aqurilla Jun 22, 2023
88c7f51
add journal information preferences
aqurilla Jun 25, 2023
99fdc18
make journal info service opt-in
aqurilla Jun 25, 2023
ef3d677
add fields to journal info view
aqurilla Jun 25, 2023
3c122ef
update fetcher to use jabref api
aqurilla Jun 27, 2023
564e222
parse remaining fields from json response
aqurilla Jun 28, 2023
a98e233
handle journal info fetching errors
aqurilla Jun 29, 2023
4f93c62
add charts to journal info view
aqurilla Jun 29, 2023
d835179
add fetcher tests
aqurilla Jul 1, 2023
6d03e5b
Update url
tobiasdiez Jul 6, 2023
f96eab5
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 7, 2023
fe7a990
update translation keys, add script comments
aqurilla Jul 7, 2023
db461de
use issn parser
aqurilla Jul 7, 2023
016a3c2
check error in api response
aqurilla Jul 9, 2023
6bcab0a
add enablement states for online service
aqurilla Jul 9, 2023
5f9a387
add journal info button to ISSN editor
aqurilla Jul 10, 2023
2bc7c78
Merge branch 'main' into fix-for-issue-6189
koppor Jul 11, 2023
8fc14a9
update chart titles and error msg
aqurilla Jul 12, 2023
a5208b3
Merge branch 'main' into fix-for-issue-6189
koppor Jul 12, 2023
3d9a303
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 13, 2023
9b1b2aa
use enum string in preferences
aqurilla Jul 13, 2023
979b855
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 15, 2023
b536850
add support for journal name in fetcher
aqurilla Jul 15, 2023
541a56c
update journal info ui
aqurilla Jul 15, 2023
095a715
fix localization tests
aqurilla Jul 15, 2023
2a38fc7
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 18, 2023
6ec5026
add changelog entry
aqurilla Jul 18, 2023
7156553
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 22, 2023
9fbeb1c
Remove script to get journal data
tobiasdiez Jul 26, 2023
a6f6473
Change API url to production
tobiasdiez Jul 26, 2023
d3312f2
Merge branch 'main' into fix-for-issue-6189
aqurilla Jul 30, 2023
48a8f9e
change log pattern, make popover detachable
aqurilla Jul 30, 2023
0892751
show info only on fetch failure
aqurilla Jul 30, 2023
257e389
Merge branch 'main' into fix-for-issue-6189
aqurilla Aug 1, 2023
ee104ac
Merge branch 'main' into fix-for-issue-6189
aqurilla Aug 9, 2023
77b3f09
Merge branch 'main' into fix-for-issue-6189
aqurilla Aug 10, 2023
85216eb
update tests
aqurilla Aug 10, 2023
c289c50
Merge branch 'main' into fix-for-issue-6189
aqurilla Aug 16, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We integrated two mail actions ("As Email" and "To Kindle") under a new "Send" option in the right-click & Tools menus. The Kindle option creates an email targeted to the user's Kindle email, which can be set in preferences under "External programs" [#6186](https://github.com/JabRef/jabref/issues/6186)
- We added an option to clear recent libraries' history. [#10003](https://github.com/JabRef/jabref/issues/10003)
- We added an option to encrypt and remember the proxy password. [#8055](https://github.com/JabRef/jabref/issues/8055)[#10044](https://github.com/JabRef/jabref/issues/10044)
- We added support for showing journal information, via info buttons next to the `Journal` and `ISSN` fields in the entry editor. [#6189](https://github.com/JabRef/jabref/issues/6189)
- We added support for pushing citations to Sublime Text 3 [#10098](https://github.com/JabRef/jabref/issues/10098)

### Changed
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static FieldEditorFX getForField(final Field field,
} else if (fieldProperties.contains(FieldProperty.EXTERNAL)) {
return new UrlEditor(field, dialogService, suggestionProvider, fieldCheckers, preferences);
} else if (fieldProperties.contains(FieldProperty.JOURNAL_NAME)) {
return new JournalEditor(field, journalAbbreviationRepository, preferences, suggestionProvider, fieldCheckers);
return new JournalEditor(field, taskExecutor, dialogService, journalAbbreviationRepository, preferences, suggestionProvider, fieldCheckers);
} else if (fieldProperties.contains(FieldProperty.DOI) || fieldProperties.contains(FieldProperty.EPRINT) || fieldProperties.contains(FieldProperty.ISBN)) {
return new IdentifierEditor(field, taskExecutor, dialogService, suggestionProvider, fieldCheckers, preferences);
} else if (field == StandardField.OWNER) {
Expand Down Expand Up @@ -97,6 +97,8 @@ public static FieldEditorFX getForField(final Field field,
return new KeywordsEditor(field, suggestionProvider, fieldCheckers, preferences);
} else if (field == InternalField.KEY_FIELD) {
return new CitationKeyEditor(field, preferences, suggestionProvider, fieldCheckers, databaseContext, undoManager, dialogService);
} else if (field == StandardField.ISSN) {
return new ISSNEditor(field, suggestionProvider, fieldCheckers, preferences, taskExecutor, dialogService);
} else {
// default
return new SimpleEditor(field, suggestionProvider, fieldCheckers, preferences, isMultiLine);
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Tooltip?>
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import javafx.scene.layout.VBox?>
<?import org.jabref.gui.fieldeditors.EditorTextArea?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.ISSNEditor">
<EditorTextArea fx:id="textArea"/>
<VBox>
<Button fx:id="journalInfoButton"
onAction="#showJournalInfo"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="VIEW_JOURNAL_INFO"/>
</graphic>
<tooltip>
<Tooltip text="%View journal info"/>
</tooltip>
</Button>
</VBox>
</fx:root>
77 changes: 77 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.jabref.gui.fieldeditors;

import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;

import org.jabref.gui.DialogService;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.fieldeditors.contextmenu.DefaultMenu;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.Field;
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;

public class ISSNEditor extends HBox implements FieldEditorFX {
@FXML private ISSNEditorViewModel viewModel;
@FXML private EditorTextArea textArea;
@FXML private Button journalInfoButton;
private final DialogService dialogService;
private final PreferencesService preferencesService;

public ISSNEditor(Field field,
SuggestionProvider<?> suggestionProvider,
FieldCheckers fieldCheckers,
PreferencesService preferences,
TaskExecutor taskExecutor,
DialogService dialogService) {
this.preferencesService = preferences;
this.dialogService = dialogService;

this.viewModel = new ISSNEditorViewModel(
field,
suggestionProvider,
fieldCheckers,
taskExecutor,
dialogService);

ViewLoader.view(this)
.root(this)
.load();

textArea.textProperty().bindBidirectional(viewModel.textProperty());
textArea.initContextMenu(new DefaultMenu(textArea));

new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textArea);
}

public ISSNEditorViewModel getViewModel() {
return viewModel;
}

@Override
public void bindToEntry(BibEntry entry) {
viewModel.bindToEntry(entry);
}

@Override
public Parent getNode() {
return this;
}

@Override
public void requestFocus() {
textArea.requestFocus();
}

@FXML
private void showJournalInfo() {
if (JournalInfoOptInDialogHelper.isJournalInfoEnabled(dialogService, preferencesService.getJournalInformationPreferences())) {
viewModel.showJournalInfo(journalInfoButton);
}
}
}
29 changes: 29 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/ISSNEditorViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jabref.gui.fieldeditors;

import javafx.scene.control.Button;

import org.jabref.gui.DialogService;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.model.entry.field.Field;

public class ISSNEditorViewModel extends AbstractEditorViewModel {
private final TaskExecutor taskExecutor;
private final DialogService dialogService;

public ISSNEditorViewModel(
Field field,
SuggestionProvider<?> suggestionProvider,
FieldCheckers fieldCheckers,
TaskExecutor taskExecutor,
DialogService dialogService) {
super(field, suggestionProvider, fieldCheckers);
this.taskExecutor = taskExecutor;
this.dialogService = dialogService;
}

public void showJournalInfo(Button journalInfoButton) {
PopOverUtil.showJournalInfo(journalInfoButton, entry, dialogService, taskExecutor);
}
}
31 changes: 22 additions & 9 deletions src/main/java/org/jabref/gui/fieldeditors/JournalEditor.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
<?import javafx.scene.layout.HBox?>
<?import org.jabref.gui.fieldeditors.EditorTextField?>
<?import org.jabref.gui.icon.JabRefIconView?>
<?import javafx.scene.layout.VBox?>
<fx:root xmlns:fx="http://javafx.com/fxml/1" type="HBox" xmlns="http://javafx.com/javafx/8.0.112"
fx:controller="org.jabref.gui.fieldeditors.JournalEditor">
<EditorTextField fx:id="textField"/>
<Button onAction="#toggleAbbreviation"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="TOGGLE_ABBREVIATION"/>
</graphic>
<tooltip>
<Tooltip text="%Switches between full and abbreviated journal name if the journal name is known."/>
</tooltip>
</Button>
<VBox>
<Button onAction="#toggleAbbreviation"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="TOGGLE_ABBREVIATION"/>
</graphic>
<tooltip>
<Tooltip text="%Switches between full and abbreviated journal name if the journal name is known."/>
</tooltip>
</Button>
<Button fx:id="journalInfoButton"
onAction="#showJournalInfo"
styleClass="icon-button">
<graphic>
<JabRefIconView glyph="VIEW_JOURNAL_INFO"/>
</graphic>
<tooltip>
<Tooltip text="%View journal info"/>
</tooltip>
</Button>
</VBox>
</fx:root>
26 changes: 25 additions & 1 deletion src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import javafx.fxml.FXML;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;

import org.jabref.gui.DialogService;
import org.jabref.gui.autocompleter.AutoCompletionTextInputBinding;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.fieldeditors.contextmenu.DefaultMenu;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.model.entry.BibEntry;
Expand All @@ -19,13 +22,27 @@ public class JournalEditor extends HBox implements FieldEditorFX {

@FXML private JournalEditorViewModel viewModel;
@FXML private EditorTextField textField;
@FXML private Button journalInfoButton;
private final DialogService dialogService;
private final PreferencesService preferencesService;

public JournalEditor(Field field,
TaskExecutor taskExecutor,
DialogService dialogService,
JournalAbbreviationRepository journalAbbreviationRepository,
PreferencesService preferences,
SuggestionProvider<?> suggestionProvider,
FieldCheckers fieldCheckers) {
this.viewModel = new JournalEditorViewModel(field, suggestionProvider, journalAbbreviationRepository, fieldCheckers);
this.dialogService = dialogService;
this.preferencesService = preferences;

this.viewModel = new JournalEditorViewModel(
field,
suggestionProvider,
journalAbbreviationRepository,
fieldCheckers,
taskExecutor,
dialogService);

ViewLoader.view(this)
.root(this)
Expand Down Expand Up @@ -57,4 +74,11 @@ public Parent getNode() {
private void toggleAbbreviation() {
viewModel.toggleAbbreviation();
}

@FXML
private void showJournalInfo() {
if (JournalInfoOptInDialogHelper.isJournalInfoEnabled(dialogService, preferencesService.getJournalInformationPreferences())) {
viewModel.showJournalInfo(journalInfoButton);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
package org.jabref.gui.fieldeditors;

import javafx.scene.control.Button;

import org.jabref.gui.DialogService;
import org.jabref.gui.autocompleter.SuggestionProvider;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.integrity.FieldCheckers;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.model.entry.field.Field;
import org.jabref.model.strings.StringUtil;

public class JournalEditorViewModel extends AbstractEditorViewModel {
private final JournalAbbreviationRepository journalAbbreviationRepository;
private final TaskExecutor taskExecutor;
private final DialogService dialogService;

public JournalEditorViewModel(Field field, SuggestionProvider<?> suggestionProvider, JournalAbbreviationRepository journalAbbreviationRepository, FieldCheckers fieldCheckers) {
public JournalEditorViewModel(
Field field,
SuggestionProvider<?> suggestionProvider,
JournalAbbreviationRepository journalAbbreviationRepository,
FieldCheckers fieldCheckers,
TaskExecutor taskExecutor,
DialogService dialogService) {
super(field, suggestionProvider, fieldCheckers);
this.journalAbbreviationRepository = journalAbbreviationRepository;
this.taskExecutor = taskExecutor;
this.dialogService = dialogService;
}

public void toggleAbbreviation() {
Expand All @@ -28,4 +42,8 @@ public void toggleAbbreviation() {
// panel.getUndoManager().addEdit(new UndoableFieldChange(entry, editor.getName(), text, nextAbbreviation));
});
}

public void showJournalInfo(Button journalInfoButton) {
PopOverUtil.showJournalInfo(journalInfoButton, entry, dialogService, taskExecutor);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.jabref.gui.fieldeditors;

import org.jabref.gui.DialogService;
import org.jabref.logic.journals.JournalInformationPreferences;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.util.EnablementStatus;

public class JournalInfoOptInDialogHelper {

/**
* Using the journal information data fetcher service needs to be opt-in for GDPR compliance.
*/
public static boolean isJournalInfoEnabled(DialogService dialogService, JournalInformationPreferences preferences) {
if (preferences.getEnablementStatus() == EnablementStatus.ENABLED) {
return true;
}

if (preferences.getEnablementStatus() == EnablementStatus.DISABLED) {
dialogService.notify(
Localization.lang("Please enable journal information fetching in %0 > %1",
Localization.lang("Preferences"),
Localization.lang("Web search"))
);
return false;
}

boolean journalInfoEnabled = dialogService.showConfirmationDialogAndWait(
Localization.lang("Remote services"),
Localization.lang("Allow sending ISSN to a JabRef online service (SCimago) for fetching journal information"));

preferences.setEnablementStatus(journalInfoEnabled ? EnablementStatus.ENABLED : EnablementStatus.DISABLED);
return journalInfoEnabled;
}
}
52 changes: 52 additions & 0 deletions src/main/java/org/jabref/gui/fieldeditors/PopOverUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.jabref.gui.fieldeditors;

import java.util.Optional;

import javafx.scene.control.Button;
import javafx.scene.control.ProgressIndicator;

import org.jabref.gui.DialogService;
import org.jabref.gui.fieldeditors.journalinfo.JournalInfoView;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;

import org.controlsfx.control.PopOver;

public class PopOverUtil {

public static void showJournalInfo(Button button, BibEntry entry, DialogService dialogService, TaskExecutor taskExecutor) {
Optional<String> optionalIssn = entry.getField(StandardField.ISSN);
Optional<String> optionalJournalName = entry.getField(StandardField.JOURNAL);

if (optionalIssn.isPresent() || optionalJournalName.isPresent()) {
PopOver popOver = new PopOver();
ProgressIndicator progressIndicator = new ProgressIndicator();
progressIndicator.setMaxSize(30, 30);
popOver.setContentNode(progressIndicator);
popOver.setDetachable(true);
popOver.setTitle(Localization.lang("Journal Information"));
popOver.setArrowLocation(PopOver.ArrowLocation.BOTTOM_CENTER);
popOver.setArrowSize(0);
popOver.show(button, 0);

BackgroundTask
.wrap(() -> new JournalInfoView().populateJournalInformation(optionalIssn.orElse(""), optionalJournalName.orElse("")))
.onSuccess(updatedNode -> {
popOver.setContentNode(updatedNode);
popOver.show(button, 0);
})
.onFailure(exception -> {
popOver.hide();
String message = Localization.lang("Error while fetching journal information: %0",
exception.getMessage());
dialogService.notify(message);
})
.executeWith(taskExecutor);
} else {
dialogService.notify(Localization.lang("ISSN or journal name required for fetching journal information"));
}
}
}
Loading