Skip to content

Hide Merge Metadata Dialog if there is nothing to merge#13309

Merged
koppor merged 17 commits into
JabRef:mainfrom
Nathaandev:fix-for-issue13262
Jun 19, 2025
Merged

Hide Merge Metadata Dialog if there is nothing to merge#13309
koppor merged 17 commits into
JabRef:mainfrom
Nathaandev:fix-for-issue13262

Conversation

@Nathaandev

@Nathaandev Nathaandev commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

Closes #13262
In this PR, I improved the behavior of the library creation dialog when importing PDF files. Specifically, when a PDF containing only a single column is dragged into a newly created library, the dialog now automatically closes. This fixes the issue where the dialog would remain open unnecessarily, improving the user experience during PDF import.

Steps to test

Create a new library in the application.

Drag'n'drop jablib\build\resources\test\pdfs\minimal.pdf into it

Observe that the dialog closes automatically after the PDF is added.

Screenshots

Dialog appears after dragging jablib\build\resources\test\pdfs\minimal.pdf into the new library
image

Dialog closes itself because there is only one column.
image

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.

@Nathaandev

Copy link
Copy Markdown
Contributor Author

I have no idea of why this changelog test is failing.

@calixtus calixtus 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.

Im not so sure about the fix. This seems to be a bit hacky to me.
The dialog now choses by itself when to show. There might be a scenario when the dialog should display anyway, that we don't think of now.
I believe the fix should happen where the dialog is called, not in the dialog itself.

Comment thread jabgui/src/main/java/org/jabref/gui/mergeentries/MultiMergeEntriesView.java Outdated
@calixtus

Copy link
Copy Markdown
Member

I have no idea of why this changelog test is failing.

you put your note in the wrong section, an old release. put your note into the section [unreleased]

@subhramit

Copy link
Copy Markdown
Member

I have no idea of why this changelog test is failing.

How to navigate: Have a look at the structure of the changelog and what each heading means. Then try to infer what the test says - "only unreleased touched".

You have added your entry under the 5.0-alpha version heading, when you had to put it under the unreleased section.

@calixtus calixtus changed the title Fix-for-issue13262 Hide Merge Metadata Dialog if there is nothing to merge Jun 12, 2025
@koppor

koppor commented Jun 12, 2025

Copy link
Copy Markdown
Member

Im not so sure about the fix. This seems to be a bit hacky to me.

Yeah, but improves workflow while working with JabRef

The dialog now choses by itself when to show. There might be a scenario when the dialog should display anyway, that we don't think of now.

Then we can disable.

I believe the fix should happen where the dialog is called, not in the dialog itself.

This is impossible - is it? @Nathaandev can you check

Because columns are filled dynamically.

@Nathaandev

Nathaandev commented Jun 12, 2025

Copy link
Copy Markdown
Contributor Author

I got a lot of failing tests this time, but I don't know why.

@subhramit

subhramit commented Jun 12, 2025

Copy link
Copy Markdown
Member

I got a lot of failing tests this time, but I don't know why.

Try to run JabRef. It probably does not compile.
No need to panic, one step at a time.

@Nathaandev

Copy link
Copy Markdown
Contributor Author

I got a lot of failing tests this time, but I don't know why.

Try to run JabRef. It probably does not compile. No need to panic, one step at a time.

It does compile, it works normally.

@subhramit

Copy link
Copy Markdown
Member

I got a lot of failing tests this time, but I don't know why.

Try to run JabRef. It probably does not compile. No need to panic, one step at a time.

It does compile, it works normally.

Apparently, CI checks are failing because half of the internet is down right now.
https://www.bleepingcomputer.com/news/technology/google-cloud-and-cloudflare-hit-by-widespread-service-outages/
So it's not you - don't worry.

@Nathaandev

Copy link
Copy Markdown
Contributor Author

I got a lot of failing tests this time, but I don't know why.

Try to run JabRef. It probably does not compile. No need to panic, one step at a time.

It does compile, it works normally.

Apparently, CI checks are failing because half of the internet is down right now. bleepingcomputer.com/news/technology/google-cloud-and-cloudflare-hit-by-widespread-service-outages So it's not you - don't worry.

Ah ok, so I have to wait and later I make another commit or there is another way to make the tests again?

@subhramit

Copy link
Copy Markdown
Member

Ah ok, so I have to wait and later I make another commit or there is another way to make the tests again?

In the guide to set up a local workspace, there is a hint on how to run a unit test locally. Checkstyle will already warn you via intelliJ, for openrewrite you can follow the developer faqs if you wish to run locally.

@Nathaandev

Copy link
Copy Markdown
Contributor Author

Ah ok, so I have to wait and later I make another commit or there is another way to make the tests again?

In the guide to set up a local workspace, there is a hint on how to run a unit test locally. Checkstyle will already warn you via intelliJ, for openrewrite you can follow the developer faqs if you wish to run locally.

Thanks!

@Nathaandev

Nathaandev commented Jun 13, 2025

Copy link
Copy Markdown
Contributor Author

Im not so sure about the fix. This seems to be a bit hacky to me.

Yeah, but improves workflow while working with JabRef

The dialog now choses by itself when to show. There might be a scenario when the dialog should display anyway, that we don't think of now.

Then we can disable.

I believe the fix should happen where the dialog is called, not in the dialog itself.

This is impossible - is it? @Nathaandev can you check

Because columns are filled dynamically.

I've explored the possibility, but it appears to be impossible. But perhaps I just wasn't good enough so i'm not 100% sure it is impossible. If the current fix still seems a bit hacky for you, I can definitely look into an alternative.

@Nathaandev

Copy link
Copy Markdown
Contributor Author

@calixtus if the current fix isn't quite right, i'm happy to discuss other approaches.

@Nathaandev Nathaandev requested a review from calixtus June 13, 2025 05:06
"Could not extract Metadata from: %0",
String.join(", ", viewModel.failedSuppliersProperty())));
// Closes the dialog if the there is only one active column.
active_columns = viewModel.entriesProperty().get().size() - viewModel.failedSuppliersProperty().get().size();

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 snake case in JabRef.

@Nathaandev Nathaandev Jun 13, 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.

No snake case in JabRef.

Would it be ok if I rename the variable to "activecolumns"?

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.

Would it be ok if I rename the variable to "activecolumns"?

read about snake casing and camel casing. In languages like python, we generally follow snake_casing. In Java, the default convention is camelCasing. So that would make it activeColumns

@Nathaandev Nathaandev Jun 13, 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.

Would it be ok if I rename the variable to "activecolumns"?

read about snake casing and camel casing. In languages like python, we generally follow snake_casing. In Java, the default convention is camelCasing. So that would make it activeColumns

I understand. whenever I was making my projects, I did not care about camelCasing or snake_casing, I would just give them any name. But it's good to learn that it's important. But what about the constants, is this rule applicable to them as well?

@subhramit subhramit Jun 13, 2025

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.

But what about the constants, is this rule applicable to them as well?

No. Constants generally have capital letters, and once we fix case, camel case cannot separate words anymore. So, then, we need underscores, for example, private static final int DEFAULT_RETURN_VALUE = 40.
We use Checkstyle with some custom rules to enforce these. Checkstyle's default configuration is based on Google's style guide, so a lot of these practices are inherited from them.
Logically, code style does not matter, but when it's a large codebase with multiple people working on it and changing code written by others, and adding many lines of their own, it becomes important to have readability and maintainability as a concern, and having a uniform style throughout helps.

@Nathaandev Nathaandev Jun 13, 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.

But what about the constants, is this rule applicable to them as well?

No. Constants generally have capital letters, and once we fix case, camel case cannot separate words anymore. So, then, we need underscores, for example, private static final int DEFAULT_RETURN_VALUE = 40. We use Checkstyle with some custom rules to enforce these. Checkstyle's default configuration is based on Google's style guide, so a lot of these practices are inherited from them. Logically, code style does not matter, but when it's a large codebase with multiple people working on it and changing code written by others, and adding many lines of their own, it becomes important to have readability and maintainability as a concern, and having a uniform style throughout helps.

Thank you for the patience and for explaining to me. You guy are helping me a lot.

Comment thread jabgui/src/main/java/org/jabref/gui/mergeentries/MultiMergeEntriesView.java Outdated
@Nathaandev Nathaandev requested a review from koppor June 13, 2025 17:52
@Nathaandev

Copy link
Copy Markdown
Contributor Author

@calixtus @koppor Is there anything else I have to do?

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
@Nathaandev

Copy link
Copy Markdown
Contributor Author

@Nathaandev code wise looks good to me. Can you provide some screenshots in the description (and tick off the respective mandatory check)?

Done! And I have commited your suggestion as well.

subhramit
subhramit previously approved these changes Jun 18, 2025

@subhramit subhramit 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.

I am not sure about the "and the user did not do any manual changes" part of the issue if it would require any special handling, but with the context I could gather, looks good. Requires a second review.

@subhramit subhramit added the status: awaiting-second-review For non-trivial changes label Jun 18, 2025
@koppor

koppor commented Jun 18, 2025

Copy link
Copy Markdown
Member

I am not sure about the "and the user did not do any manual changes" part of the issue if it would require any special handling,

When the decision to close is made, check if the merged entry is the same (equals should work) as the remaining one.

It could be that a user begins to change something. However, here, it are only 2 seconds or so; thus, this is maybe cosmetics only.

@koppor

koppor commented Jun 18, 2025

Copy link
Copy Markdown
Member

Let's see what users will report.

On the first load, I had a long respoonse time from Grobid - and could have typed something in the dialog. The subsequent runs were very fast. Thus, I don't see a risk of loosing data if the dialog is closed.

Thus, I approve. Thank you for spending time with us @Nathaandev

@koppor koppor enabled auto-merge June 18, 2025 23:21
koppor
koppor previously approved these changes Jun 18, 2025
@koppor koppor disabled auto-merge June 18, 2025 23:21
@koppor koppor dismissed stale reviews from subhramit and themself via 94d6b2f June 18, 2025 23:26
@koppor

koppor commented Jun 18, 2025

Copy link
Copy Markdown
Member

I inlined a variable at 95b50f9 (#13309).

Since the code could cause questions while reading, I added some requirements text. I think, our team agrees to have "Requirements" first and not just issues linked in the code? @subhramit

@koppor koppor removed the status: awaiting-second-review For non-trivial changes label Jun 18, 2025
String.join(", ", viewModel.failedSuppliersProperty())));
int activeColumns = viewModel.entriesProperty().get().size() - viewModel.failedSuppliersProperty().get().size();
if (activeColumns < ACTIVE_COLUMNS_MINIMUM) {
// [impl->req~ux.auto-close.merge-entries~1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment does not provide meaningful information about the code's purpose or reasoning. Implementation details should be documented in requirements, not in code comments.

@koppor koppor enabled auto-merge June 18, 2025 23:29
@koppor

koppor commented Jun 18, 2025

Copy link
Copy Markdown
Member

I added to the merge queue to keep things going. We can fix the text as a follow up.

@koppor koppor added this pull request to the merge queue Jun 19, 2025
Merged via the queue into JabRef:main with commit ef7ecfe Jun 19, 2025
1 check passed
@Nathaandev Nathaandev deleted the fix-for-issue13262 branch June 20, 2025 17:34
Siedlerchr added a commit that referenced this pull request Jun 20, 2025
* upstream/main:
  Make snap available for arm64 as well (#13383)
  Hide Merge Metadata Dialog if there is nothing to merge (#13309)
  Fix #13269 : support multi-file import across different formats (#13271)
  Fix Javadoc in CitaviXmlImporter.java/getPages (#13381)
@Nathaandev

Copy link
Copy Markdown
Contributor Author

Hello, @koppor @subhramit,

Thanks for the help on this issue. I wanted to ask you if it is ok if I make a Linkedin post about JabRef and this issue, I am looking for my first job as a Junior back-end developer and I would appreciate sharing my learning progress on LinkedIn. Thanks.

@koppor

koppor commented Jun 22, 2025

Copy link
Copy Markdown
Member

Thanks for the help on this issue. I wanted to ask you if it is ok if I make a Linkedin post about JabRef and this issue,

Sure! Go ahead! Please use #JabRef in the post :)

@Siedlerchr

Copy link
Copy Markdown
Member

@Nathaandev Sure, you can also tag @JabRef on linkedin, our page

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 "Merge PDF metadata" dialog if there is nothing to merge

5 participants