Skip to content

Fix for issue 13132: Show entry column only when not empty#13180

Merged
koppor merged 7 commits into
JabRef:mainfrom
Vane-Arellano:fix-for-issue-13132
May 31, 2025
Merged

Fix for issue 13132: Show entry column only when not empty#13180
koppor merged 7 commits into
JabRef:mainfrom
Vane-Arellano:fix-for-issue-13132

Conversation

@Vane-Arellano

Copy link
Copy Markdown
Contributor

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
Screenshot 2025-05-28 at 12 34 05 p m

Test with the multiple-meta-data.pdf
Screenshot 2025-05-28 at 12 35 49 p m

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

# 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.
@Vane-Arellano Vane-Arellano changed the title Fix for issue 13132 Fix for issue 13132: Show entry column only when not empty May 28, 2025
@Vane-Arellano

Copy link
Copy Markdown
Contributor Author

@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 koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .gitignore Outdated
jablib/src/main/resources/csl-styles
jablib/src/main/resources/csl-locales
jablib/src/main/abbrv.jabref.org
jablib/src/main/resources/csl-locales

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is line 11 - remove it.

@Vane-Arellano

Copy link
Copy Markdown
Contributor Author

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.

Thanks! working on that

create helper methods initDialog and finishDialog
@Vane-Arellano Vane-Arellano requested a review from koppor May 29, 2025 17:09
* @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.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new empty line (which IDE do you use?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to state the caller - because one does not know about future usages and IDEs offer the capabilities to see the known callers.

Comment on lines +30 to +34
* 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>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more a class comment - either refactor the whole description to be as a class comment - or remove this text.

@Vane-Arellano Vane-Arellano May 29, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this empty line.

@Vane-Arellano Vane-Arellano requested a review from koppor May 29, 2025 22:19
@Vane-Arellano

Copy link
Copy Markdown
Contributor Author

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 koppor marked this pull request as ready for review May 29, 2025 22:57
koppor
koppor previously approved these changes May 29, 2025

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@koppor

koppor commented May 29, 2025

Copy link
Copy Markdown
Member

@Vane-Arellano Do you have time and energy to add a line to CHANGELOG.md?

@Vane-Arellano

Vane-Arellano commented May 30, 2025

Copy link
Copy Markdown
Contributor Author

@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
Should I place it under unreleased and then changed?

Comment thread CHANGELOG.md Outdated
@koppor koppor enabled auto-merge May 31, 2025 07:17
@trag-bot

trag-bot Bot commented May 31, 2025

Copy link
Copy Markdown

@trag-bot didn't find any issues in the code! ✅✨

@koppor

koppor commented May 31, 2025

Copy link
Copy Markdown
Member

@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 Should I place it under unreleased and then changed?

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.

@koppor koppor added this pull request to the merge queue May 31, 2025
Merged via the queue into JabRef:main with commit ea22869 May 31, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not show empty column in Merge Entries

2 participants