-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add a "view as BibTeX" option before importing an entry from the cita… #11847
base: main
Are you sure you want to change the base?
Conversation
ca.appendText(getSourceString(entry, mode, fieldPreferences)); | ||
} catch ( | ||
IOException ex) { | ||
ca = null; |
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.
Never return null
. Use Optional<CodeArea>
or throw an exception: The caller should explicitly know that null is returned.
Reason: We do not rely on null
annotations really.
} catch ( | ||
IOException ex) { |
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.
Try to keep it in one line. We know that IntelliJ outformats it like that - we did not find a way to fix this issue.
@@ -2782,3 +2782,8 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The | |||
Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0' | |||
Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0' | |||
Store\ url\ for\ downloaded\ file=Store url for downloaded file | |||
BibTeX\ of\ that\ entry=BibTeX of that entry |
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.
Re-use "Show BibTeX source" (or "Show %0 source". Just check the existing strings.)
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.
Exits only "Show/edit %0 source"
BibTeX\ of\ that\ entry=BibTeX of that entry | ||
Could\ not\ load\ %0\ source=Could not load %0 source | ||
BibTeX\ source=BibTeX source |
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.
Please check the existing one. I think, it is %0 source
.
@@ -2782,3 +2782,8 @@ Warning\:\ The\ selected\ directory\ is\ not\ a\ valid\ directory.=Warning: The | |||
Currently\ selected\ JStyle\:\ '%0' = Currently selected JStyle: '%0' | |||
Currently\ selected\ CSL\ Style\:\ '%0' = Currently selected CSL Style: '%0' | |||
Store\ url\ for\ downloaded\ file=Store url for downloaded file | |||
BibTeX\ of\ that\ entry=BibTeX of that entry | |||
Could\ not\ load\ %0\ source=Could not load %0 source |
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.
Not more information than "Error". Thus, please use "Error" as string - and not a new text.
private EntryEditor createEntryEditor() { | ||
Supplier<LibraryTab> tabSupplier = () -> this.libraryTab; | ||
return new EntryEditor(this.libraryTab, | ||
// Actions are recreated here since this avoids passing more parameters and the amount of additional memory consumption is neglegtable. |
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.
I think, the main reason is that undo and redo are independent here. Thus, these should be fake ones? -- The BibTeX is from the external service and NOT contained in the current library. Thus, it has NOTHING to do with the current library and thus no undo/redo relation with it.
Update: I think, this is not necessary at all. No entry editor is needed.
if (codeArea == null) { | ||
dialogService.showWarningDialogAndWait(Localization.lang("BibTeX source", databaseContext.getMode().getFormattedName()), Localization.lang("Could not load %0 source", databaseContext.getMode().getFormattedName())); |
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.
How often does this occur? Bug in the code or real use? I think, its bug in the code. Thus, please use LOGGER.warn(...)
instead of a dialog service.
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.
Also just return then. #FailFast. Do not use } else {
.
Button showEntrySource = IconTheme.JabRefIcons.SOURCE.asButton(); | ||
showEntrySource.setTooltip(new Tooltip(Localization.lang("Show %0 source", databaseContext.getMode().getFormattedName()))); | ||
showEntrySource.setOnMouseClicked(event -> { | ||
this.entryEditor = createEntryEditor(); |
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.
Why do you need a full entry editor? I think, you can just show the source without full editing capabilities.
Thank you for your feedback! I've addressed the issues you pointed out and made the necessary changes. Please take a look and let me know if everything looks good now. |
StringWriter writer = new StringWriter(); | ||
BibWriter bibWriter = new BibWriter(writer, OS.NEWLINE); | ||
FieldWriter fieldWriter = FieldWriter.buildIgnoreHashes(this.preferences.getFieldPreferences()); | ||
new BibEntryWriter(fieldWriter, new BibEntryTypesManager()).write(entry, bibWriter, type); |
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.
Can you try to get the BibEntryTypesManager
be passed? It should be available "somewhere" in the call hierarchy. org.jabref.gui.collab.entrychange.PreviewWithSourceTab
also has it.
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.
Please add an @implNote
that this code is similar to PreviewWithSourceTab#getSourceString
.
@Siedlerchr I think it is OK to have code duplication here. Alternatively, we could introduce org.jabref.logic.exporter.BibEntryPrinter
having a single method getAsString
.
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.
Duplicated code is imho okay, just the EntryTypesManaager as constructor parameter
DialogPane dialogPane = new DialogPane(); | ||
dialogPane.setPrefSize(800, 400); | ||
dialogPane.setContent(scrollPane); | ||
String title = Localization.lang("%0 source", "Show BibTeX"); |
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.
"Show BibTeX" is not localized.
String title = Localization.lang("%0 source", "Show BibTeX"); | |
String title = Localization.lang("Show BibTeX source"); |
@@ -254,6 +271,14 @@ private void styleFetchedListView(CheckListView<CitationRelationItem> listView) | |||
vContainer.getChildren().addLast(openWeb); | |||
} | |||
|
|||
Button showEntrySource = IconTheme.JabRefIcons.SOURCE.asButton(); | |||
showEntrySource.setTooltip(new Tooltip(Localization.lang("%0 source", databaseContext.getMode().getFormattedName()))); |
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.
I am not sure if it is really BibLaTeX in this case - the citatoin fetcher always uses the bibtex dialect? Can you check? If unsure, just always use "BibTeX".
@@ -74,6 +87,9 @@ public class CitationRelationsTab extends EntryEditorTab { | |||
private final BibEntryRelationsRepository bibEntryRelationsRepository; | |||
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel; | |||
private final DuplicateCheck duplicateCheck; | |||
private EntryEditor entryEditor; | |||
|
|||
private StateManager stateManager; |
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.
Not used. Remove.
@@ -74,6 +87,9 @@ public class CitationRelationsTab extends EntryEditorTab { | |||
private final BibEntryRelationsRepository bibEntryRelationsRepository; | |||
private final CitationsRelationsTabViewModel citationsRelationsTabViewModel; | |||
private final DuplicateCheck duplicateCheck; | |||
private EntryEditor entryEditor; |
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.
Not used. Please remove.
It would be really nice if you scrolled through your source code in IntelliJ. That variable should be in light gray meaning: not used. 😅
The thing is that we as reviewers could overlook things. Moreover, if we comment on these kind things, there is no time to check the harder questions... 😇
…07/jabref into feat-for-issue-11826
Thank you for the feedback and the tips! I've addressed the comments and reviewed the code in IntelliJ. Please take a look at the updates and let me know if everything looks good. |
this.taskExecutor = taskExecutor; | ||
setText(Localization.lang("Citation relations")); | ||
setTooltip(new Tooltip(Localization.lang("Show articles related by citation"))); | ||
|
||
this.duplicateCheck = new DuplicateCheck(new BibEntryTypesManager()); | ||
this.entryTypesManager = new BibEntryTypesManager(); |
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.
You can pass the instance from the caller (see EntryEditor.java)
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.
Originally in "this.duplicateCheck = new DuplicateCheck(new BibEntryTypesManager());" a new instance is created, if I take over the instance from EntryEditor should I leave the original solution for "DuplicateCheck" or move the instance from EntryEditor as well ?
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.
Use the instance from EntryEditor as well. Mabe, this will also fix some bugs...
Fixed |
Add a "view as BibTeX" option before importing an entry from the cita…tion relation tab #11826
This PR implements the feature requested in issue #10869. It adds a button that allows users to display a dialog showing the full BibTeX entry when importing citations from the Citation Relation tab. This enhancement will help users decide whether to import a potentially "duplicate" record by allowing them to see the full details of the entry in BibTeX format.
Closes #11826
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)