Fix for issue 13132: Show entry column only when not empty#13180
Conversation
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
|
@koppor thanks for your support under this issue, I made this solution to not show the empty column, hope it aligns with the requirements of the project, but if not, please let me know so I can come up with another solution:) |
koppor
left a comment
There was a problem hiding this comment.
The solution is kind of a "quick hack".
Works, but better is follows: A second method without entry is needed.
Create two helper methods:
- Create the initial dialog (
initDialog) - Create method filling the remainder (
finishDialog)
Use these methods in both constructors.
The constructor with entry does
dialog.addSource(Localization.lang("Entry"), entry);
Inbetween.
Much code, but a more clean interface at the caller side.
| jablib/src/main/resources/csl-styles | ||
| jablib/src/main/resources/csl-locales | ||
| jablib/src/main/abbrv.jabref.org | ||
| jablib/src/main/resources/csl-locales |
Thanks! working on that |
create helper methods initDialog and finishDialog
| * @param preferences the preferences to use. Full preference object is required, because of current implementation of {@link MultiMergeEntriesView}. | ||
| * @param taskExecutor the task executor to use when the multi merge dialog executes the importers. | ||
| */ | ||
|
|
There was a problem hiding this comment.
No new empty line (which IDE do you use?)
There was a problem hiding this comment.
I'm using IntelliJ
| * </ul> | ||
| * | ||
| * @param entry the entry to merge with | ||
| * @param entry the entry to merge with (only for {@link #createMergeDialog(BibEntry, Path, GuiPreferences, TaskExecutor)}) |
There was a problem hiding this comment.
No need to state the caller - because one does not know about future usages and IDEs offer the capabilities to see the known callers.
| * Two entry points are provided: | ||
| * <ul> | ||
| * <li>{@link #createMergeDialog(BibEntry, Path, GuiPreferences, TaskExecutor)} to merge a known entry with extracted data.</li> | ||
| * <li>{@link #createMergeDialog(Path, GuiPreferences, TaskExecutor)} to extract all data from the PDF without a preexisting entry.</li> | ||
| * </ul> |
There was a problem hiding this comment.
This is more a class comment - either refactor the whole description to be as a class comment - or remove this text.
There was a problem hiding this comment.
Just removed this one, is the
"
* Internally, this is split into two helper methods:
* < ul>
* < li>{@code initDialog} sets up the dialog with preferences and title.< /li>
* < li>{@code finishDialog} populates the dialog with all available import sources.< /li>
* </ ul>
"
also consider class comment?
There was a problem hiding this comment.
Can be removed completely, because the code is so short and one can read from the code.
| import org.jabref.model.entry.BibEntry; | ||
|
|
||
| public class PdfMergeDialog { | ||
|
|
|
Made required changes, please let me know if there's anything else needed |
| MultiMergeEntriesView dialog = new MultiMergeEntriesView(preferences, taskExecutor); | ||
| MultiMergeEntriesView dialog = initDialog(preferences, taskExecutor); | ||
|
|
||
| dialog.addSource(Localization.lang("Entry"), entry); |
There was a problem hiding this comment.
The method addSource is being passed a potentially null entry, which could lead to a NullPointerException. Consider using Optional to handle the possibility of null values.
koppor
left a comment
There was a problem hiding this comment.
Thank you for the follow-up.
I think, leaving JavaDoc as is, is OK. A follow-up can move it to the class, but I think, we save this loop in this context.
|
@Vane-Arellano Do you have time and energy to add a line to CHANGELOG.md? |
@koppor sure can do! :) thanks for all your guidance in this issue btw |
|
@trag-bot didn't find any issues in the code! ✅✨ |
Yes, that was right! - My answer wasn't sent somehow. I fixed the CHANGELOG.md entrfy to be user-facing and not programmer-facing. Now, its good to go. Thank you for adressing the review comments. |
Closes #13132
DRAFT PR, NEED FEEDBACK TO ENSURE THIS IS A DESIRED SOLUTION
This PR contains changes to PdfMergeDialog.java, where before adding the entry column, it validates if the entry coming to the dialog is empty. If it is not empty, it will create the entry column as usual.
Screenshot related to the solution implemented:

Test with the Lego4TOSCA-Composable-Building-Blocks-for-Cloud-Applications.pdf
Test with the multiple-meta-data.pdf

Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)