-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add a new field for citation count #13531
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
Merged
Merged
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
dcc6076
first changes
SalvadorRomo 1a76c57
partial change
SalvadorRomo aaef2ce
add fields to GUI
SalvadorRomo 150bc2c
finish change
SalvadorRomo fe6b48d
fix citation count identifier
SalvadorRomo 23fbd53
adding tests
SalvadorRomo b37475d
Merge branch 'JabRef:main' into fix-for-issue-13477
SalvadorRomo f4fa327
add more testing
SalvadorRomo 1193823
merge files
SalvadorRomo 44de54c
remove unwanted logic
SalvadorRomo 05aa416
add entry to change log
SalvadorRomo 15baed1
resolve comments
SalvadorRomo 19923b8
resolve comments
SalvadorRomo db2ffd2
resolve conflicts
SalvadorRomo cd836e7
enhance citation count change log
SalvadorRomo a90024c
enhance citation count change log
SalvadorRomo 9c3facb
change assertion style
SalvadorRomo 84af44f
resolve conflicts
SalvadorRomo 1d265d3
resolve conflicts
SalvadorRomo 8bfc988
resolve conflicts
SalvadorRomo 83709c9
resolve test errors
SalvadorRomo 4333732
resolve conflicts
SalvadorRomo 18f9de0
fix branch
SalvadorRomo 91c8c62
fix test
SalvadorRomo 0cf3850
remove unused class
SalvadorRomo e4fdd97
merge incoming changes
SalvadorRomo e1928d8
resolve comment
SalvadorRomo 18e51bd
Update CHANGELOG.md
SalvadorRomo d12e8e4
resolve comments
SalvadorRomo 1f7f5cf
merge master
SalvadorRomo ba09528
fix comments
SalvadorRomo 25e3649
fix comments
SalvadorRomo 4e0c1af
fix comments
SalvadorRomo 1accb7c
fix issues
SalvadorRomo 85190f9
Merge branch 'main' into fix-for-issue-13477
SalvadorRomo 371f9f6
Merge branch 'main' into fix-for-issue-13477
SalvadorRomo 3074fde
Merge branch 'main' into fix-for-issue-13477
koppor 41deb2b
fix comments
SalvadorRomo fa1297f
remove unused import
SalvadorRomo 4f1250d
fix comments
SalvadorRomo 49d6d47
fix test cases
SalvadorRomo 827b4a7
Merge branch 'main' into fix-for-issue-13477
SalvadorRomo 0630f86
fix comments
f8a9733
Merge branch 'JabRef:main' into fix-for-issue-13477
SalvadorRomo 5bd1d5a
fix tests
83d3ada
Merge branch 'main' into fix-for-issue-13477
SalvadorRomo 7eb7102
Merge branch 'main' into fix-for-issue-13477
SalvadorRomo a1eae94
Merge branch 'main' into fix-for-issue-13477
koppor 2ce9536
Fix space in fieldname
koppor deee352
Use "error" from server for notification of error
koppor d2d060a
Fix requires for xmlunit
koppor 4734273
Ensure that streams are closed during test
koppor 51184fa
Fix test file
koppor 5933eed
Fix OpenRewrite
koppor 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
84 changes: 84 additions & 0 deletions
84
jabgui/src/main/java/org/jabref/gui/fieldeditors/CitationCountEditor.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,84 @@ | ||
package org.jabref.gui.fieldeditors; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.Parent; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Tooltip; | ||
import javafx.scene.layout.HBox; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.autocompleter.SuggestionProvider; | ||
import org.jabref.gui.fieldeditors.contextmenu.DefaultMenu; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.citation.SearchCitationsRelationsService; | ||
import org.jabref.logic.integrity.FieldCheckers; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.util.TaskExecutor; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.Field; | ||
|
||
import com.airhacks.afterburner.injection.Injector; | ||
import com.airhacks.afterburner.views.ViewLoader; | ||
import jakarta.inject.Inject; | ||
|
||
public class CitationCountEditor extends HBox implements FieldEditorFX { | ||
@FXML private CitationCountEditorViewModel viewModel; | ||
@FXML private EditorTextField textField; | ||
@FXML private Button fetchCitationCountButton; | ||
|
||
@Inject private DialogService dialogService; | ||
@Inject private GuiPreferences preferences; | ||
@Inject private UndoManager undoManager; | ||
@Inject private TaskExecutor taskExecutor; | ||
@Inject private StateManager stateManager; | ||
@Inject private SearchCitationsRelationsService searchCitationsRelationsService; | ||
|
||
public CitationCountEditor(Field field, | ||
SuggestionProvider<?> suggestionProvider, | ||
FieldCheckers fieldCheckers) { | ||
Injector.registerExistingAndInject(this); | ||
this.viewModel = new CitationCountEditorViewModel( | ||
field, | ||
suggestionProvider, | ||
fieldCheckers, | ||
taskExecutor, | ||
dialogService, | ||
undoManager, | ||
stateManager, | ||
preferences, | ||
searchCitationsRelationsService); | ||
|
||
ViewLoader.view(this) | ||
.root(this) | ||
.load(); | ||
|
||
textField.textProperty().bindBidirectional(viewModel.textProperty()); | ||
|
||
fetchCitationCountButton.setTooltip( | ||
new Tooltip(Localization.lang("Look up %0", field.getDisplayName()))); | ||
textField.initContextMenu(new DefaultMenu(textField), preferences.getKeyBindingRepository()); | ||
new EditorValidator(preferences).configureValidation(viewModel.getFieldValidator().getValidationStatus(), textField); | ||
} | ||
|
||
@FXML | ||
private void fetchCitationCount() { | ||
viewModel.getCitationCount(); | ||
} | ||
|
||
public CitationCountEditorViewModel getViewModel() { | ||
return viewModel; | ||
} | ||
|
||
@Override | ||
public void bindToEntry(BibEntry entry) { | ||
viewModel.bindToEntry(entry); | ||
} | ||
|
||
@Override | ||
public Parent getNode() { | ||
return this; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
jabgui/src/main/java/org/jabref/gui/fieldeditors/CitationCountEditorViewModel.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,74 @@ | ||
package org.jabref.gui.fieldeditors; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import javafx.beans.property.BooleanProperty; | ||
import javafx.beans.property.SimpleBooleanProperty; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.autocompleter.SuggestionProvider; | ||
import org.jabref.gui.preferences.GuiPreferences; | ||
import org.jabref.logic.citation.SearchCitationsRelationsService; | ||
import org.jabref.logic.integrity.FieldCheckers; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.util.BackgroundTask; | ||
import org.jabref.logic.util.TaskExecutor; | ||
import org.jabref.model.entry.field.Field; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class CitationCountEditorViewModel extends AbstractEditorViewModel { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(CitationCountEditorViewModel.class); | ||
|
||
protected final BooleanProperty fetchCitationCountInProgress = new SimpleBooleanProperty(false); | ||
private final TaskExecutor taskExecutor; | ||
private final DialogService dialogService; | ||
private final UndoManager undoManager; | ||
private final StateManager stateManager; | ||
private final GuiPreferences preferences; | ||
SalvadorRomo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private final SearchCitationsRelationsService searchCitationsRelationsService; | ||
public CitationCountEditorViewModel( | ||
Field field, | ||
SuggestionProvider<?> suggestionProvider, | ||
FieldCheckers fieldCheckers, | ||
TaskExecutor taskExecutor, | ||
DialogService dialogService, | ||
UndoManager undoManager, | ||
StateManager stateManager, | ||
GuiPreferences preferences, | ||
SearchCitationsRelationsService searchCitationsRelationsService) { | ||
super(field, suggestionProvider, fieldCheckers, undoManager); | ||
this.taskExecutor = taskExecutor; | ||
this.dialogService = dialogService; | ||
this.undoManager = undoManager; | ||
this.stateManager = stateManager; | ||
this.preferences = preferences; | ||
this.searchCitationsRelationsService = searchCitationsRelationsService; | ||
} | ||
|
||
public BooleanProperty fetchCitationCountInProgressProperty() { | ||
return fetchCitationCountInProgress; | ||
} | ||
|
||
public boolean getFetchCitationCountInProgress() { | ||
return fetchCitationCountInProgress.get(); | ||
} | ||
|
||
public void getCitationCount() { | ||
Optional<String> fieldContent = entry.getField(field); | ||
BackgroundTask.wrap(() -> searchCitationsRelationsService.getCitationCount(this.entry, fieldContent)) | ||
.onRunning(() -> fetchCitationCountInProgress.setValue(true)) | ||
.onFinished(() -> fetchCitationCountInProgress.setValue(false)) | ||
.onFailure(e -> { | ||
dialogService.notify(Localization.lang("Error occurred when getting citation count, please try again or check the identifier.\n\n%0", e.getLocalizedMessage())); | ||
LOGGER.error("Error while fetching citation count", e); | ||
}) | ||
.onSuccess(identifier -> { | ||
entry.setField(field, String.valueOf(identifier)); | ||
}).executeWith(taskExecutor); | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
jabgui/src/main/resources/org/jabref/gui/fieldeditors/CitationCountEditor.fxml
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.ProgressIndicator?> | ||
<?import javafx.scene.control.Tooltip?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.StackPane?> | ||
<?import org.jabref.gui.fieldeditors.EditorTextField?> | ||
<?import org.jabref.gui.icon.JabRefIconView?> | ||
<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.CitationCountEditor"> | ||
<EditorTextField fx:id="textField" prefHeight="0.0" HBox.hgrow="ALWAYS"/> | ||
<Button fx:id="fetchCitationCountButton" onAction="#fetchCitationCount" styleClass="icon-button"> | ||
<graphic> | ||
<StackPane> | ||
<JabRefIconView glyph="LOOKUP_IDENTIFIER" | ||
visible="${!controller.viewModel.fetchCitationCountInProgress}"/> | ||
<ProgressIndicator maxHeight="12.0" maxWidth="12.0" | ||
visible="${controller.viewModel.fetchCitationCountInProgress}"/> | ||
</StackPane> | ||
</graphic> | ||
</Button> | ||
</fx:root> |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Swing components in a JavaFX application violates the architectural decision to use only JavaFX. The UndoManager should be replaced with a JavaFX-specific implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JabRef uses this - which is OK.