Skip to content

Conversation

@Sara-S-Dev
Copy link
Contributor

@Sara-S-Dev Sara-S-Dev commented Jul 7, 2025

fixes #12565 refine file exists warning

  • Allow "Keep both" option to avoid overwriting files
  • Add tooltip showing the new unique filename
  • Add "Provide alternative file name" option
  • Improve title and message content for better clarity

new buttons

keep both

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.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Code looks OK - someone needs to try out.


Do\ not\ wrap\ when\ saving=Do not wrap when saving

File\ already\ exists=File already exists
Copy link
Member

Choose a reason for hiding this comment

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

Pleae group to line 2999

(there is File '%0' already exists. Overwriting.)

@koppor koppor changed the title Fix issue 12565 Refine "File exists" warning Jul 7, 2025
Comment on lines 290 to 294
// Build the dialog window
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle(Localization.lang("File already exists"));
dialog.setContentText(Localization.lang("File name: \n'%0'", targetFileName));
dialog.getDialogPane().getButtonTypes().addAll(Replace, keepBoth, provideAlternative, cancel);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be in viewmodel

koppor
koppor previously requested changes Jul 7, 2025
ButtonType cancel = new ButtonType(Localization.lang("Cancel"), ButtonBar.ButtonData.OTHER);

// Build the dialog window
Dialog<ButtonType> dialog = new Dialog<>();
Copy link
Member

Choose a reason for hiding this comment

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

Please rework. Use org.jabref.gui.JabRefDialogService. Please do not create dialogs on your own. - For example, look at the removed code 😅

MVVM is about testability.

This will also help to test this --> try to craft a test case after you use the JabRefDialogService :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created a custom modal because the current JabRefDialogService methods don’t support tooltips on buttons.
Should I add a new function to JabRefDialogService for this, or is there a better approach you’d recommend?

Copy link
Member

Choose a reason for hiding this comment

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

Yes please add a new function, maybe with a supplier as parameter for the tool tips

@Sara-S-Dev Sara-S-Dev requested a review from koppor July 14, 2025 13:16
ButtonType replace = new ButtonType(Localization.lang("Replace"), ButtonBar.ButtonData.OTHER);
ButtonType keepBoth = new ButtonType(Localization.lang("Keep both"), ButtonBar.ButtonData.OTHER);
ButtonType provideAlternative = new ButtonType(Localization.lang("Provide alternative file name"), ButtonBar.ButtonData.OTHER);
ButtonType cancel = new ButtonType(Localization.lang("Cancel"), ButtonBar.ButtonData.OTHER);
Copy link
Member

Choose a reason for hiding this comment

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

should be cancel close for button data

@trag-bot
Copy link

trag-bot bot commented Jul 14, 2025

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

@Siedlerchr Siedlerchr enabled auto-merge July 14, 2025 18:38
@Siedlerchr Siedlerchr added this pull request to the merge queue Jul 14, 2025
@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 14, 2025
auto-merge was automatically disabled July 14, 2025 18:50

Pull Request is not mergeable

Merged via the queue into JabRef:main with commit 66393da Jul 14, 2025
1 check passed
Do\ not\ wrap\ when\ saving=Do not wrap when saving

File\ already\ exists=File already exists
File\ name\:\ \n'%0'=File name: \n'%0'
Copy link
Member

Choose a reason for hiding this comment

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

There should be no space before newline

Maybe you can submit a follow-up PR?

Siedlerchr added a commit that referenced this pull request Aug 2, 2025
* upstream/main:
  Bump com.squareup.okhttp3:okhttp from 5.0.0 to 5.1.0 in /versions (#13541)
  Fixed Issue 13418: "Search ShortSience" should do a latex-to-unicode conversion (#13532)
  New Crowdin updates (#13548)
  Add focus to field Link in the "Add file link" dialog. (#13520)
  Bump org.ow2.asm:asm from 9.6 to 9.8 in /versions (#13547)
  Make validation optional for saving library properties preferences (#13488)
  Bump org.apache.commons:commons-lang3 from 3.17.0 to 3.18.0 in /versions (#13546)
  --porcelain does not output any info or warn errors on the console (#13469)
  Bump jablib/src/main/resources/csl-locales from `7e137db` to `3bad433` (#13545)
  Refine "File exists" warning (#13491)
  Bump org.openrewrite.recipe:rewrite-recipe-bom from 3.8.0 to 3.11.1 (#13544)
  Bump org.openrewrite.rewrite from 7.8.0 to 7.11.0 (#13542)
  Bump jablib/src/main/resources/csl-styles from `704ff9f` to `59f124d` (#13540)
  Add architecture test for logging infrastructure (#13534)
  More harsh test on title of PR
  New Crowdin updates (#13533)
  Update extra-java-module-info plugin (#13527)
  [Junie]: fix: display help output for --help argument (#13446)
  Refactor OpenExternalFileAction  (#13508)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refine "File exists" warning

4 participants