Skip to content

OpenOffice refactoring- subtask: Break down large methods like guiActionInsertEntry()#15380

Draft
anuv-bit wants to merge 24 commits intoJabRef:mainfrom
anuv-bit:fixes-for-issue-11829
Draft

OpenOffice refactoring- subtask: Break down large methods like guiActionInsertEntry()#15380
anuv-bit wants to merge 24 commits intoJabRef:mainfrom
anuv-bit:fixes-for-issue-11829

Conversation

@anuv-bit
Copy link
Copy Markdown

@anuv-bit anuv-bit commented Mar 20, 2026

Related issues and pull requests

Closes #11829

PR Description

This PR focuses on the subtask of breaking down the large methods guiActionInsertEntry() and guiActionUpdateDocument() in OOBibBase.java. Next steps would be making sure changes line up with the guidelines.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • [/] I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@anuv-bit anuv-bit changed the title Fix-for-issue #11829- subtask: Break down large methods like guiActionInsertEntry() OpenOffice refactoring- subtask: Break down large methods like guiActionInsertEntry() Mar 20, 2026
@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete status: no-bot-comments and removed status: changes-required Pull requests that are not yet complete labels Mar 20, 2026
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.


public void guiActionSelectDocument(boolean autoSelectForSingle) throws WrappedTargetException, NoSuchElementException {
final String errorTitle = Localization.lang("Problem connecting");
final String connectionError = Localization.lang("Problem connecting");
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 revert these renamings - since they are function-local, they needn't be more specific

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Understood, I reverted them. Are there more magic strings that you would like replaced with constants (that I have not already replaced)? My understanding was that not every single string needed to be replaced with a constant, especially in cases where the string is unique and is only used once.

Thank you!

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.

These above were not magic strings. They were already constants.
Yes, ideally we extract constants for strings used more than once.
But there is one other case - when the string reduces readability of the code, or is long.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for the confirmation! To clarify: I was referring to changes made in a previous commit in which I did replace magic strings with constants, not this commit which was just renaming the existing constants.

/// @param citationType Indicates whether it is an in-text citation, a citation in parenthesis or an invisible citation.
/// @param citationStyle Indicates style, name and path of citation
/// @param syncOptions Indicates whether in-text citations should be refreshed in the document. Optional.empty() indicates no refresh. Otherwise, provides options for refreshing the reference list.
public void guiActionCSLCitationHandler(List<BibEntry> entries, XTextDocument doc, CitationType citationType, CitationStyle citationStyle,
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.

These are more like class names - please use names denoting actions for methods

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

…s-for-issue-11829

# Conflicts:
#	jabgui/src/main/java/org/jabref/gui/openoffice/OOBibBase.java
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@github-actions github-actions bot added status: changes-required Pull requests that are not yet complete status: no-bot-comments and removed status: no-bot-comments status: changes-required Pull requests that are not yet complete labels Mar 27, 2026
Comment on lines -636 to +582
LOGGER.error("Could not insert entry", e);
OOError.fromMisc(e).setTitle(errorTitle).showErrorDialog(dialogService);
throw new RuntimeException(e);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this still use OOError.fromMisc?

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.

Yes
@anuv-bit why was this changed?

@pluto-han
Copy link
Copy Markdown
Contributor

pluto-han commented Mar 28, 2026

Could you please also extract methods for JStyle and CSL in guiActionUpdateDocument like the way you did in guiActionInsertEntry?

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

@testlens-app
Copy link
Copy Markdown

testlens-app bot commented Mar 28, 2026

✅ All tests passed ✅

🏷️ Commit: 0751f17
▶️ Tests: 10206 executed
⚪️ Checks: 52/52 completed


Learn more about TestLens at testlens.app.

@amanda-d-e
Copy link
Copy Markdown

amanda-d-e commented Mar 28, 2026

Could you please also extract methods for JStyle and CSL in guiActionUpdateDocument like the way you did in guiActionInsertEntry?

Thank you for the guidance @pluto-han. I extracted a 'performPreUpdateChecks()' method similar to the 'performPreInsertionChecks()' method extracted from guiActionInsertEntry. Is this what you were looking for, or would you like me to also restructure the try/catch blocks inside guiActionUpdateDocument to match guiActionInsertEntry?

@subhramit
Copy link
Copy Markdown
Member

Could you please also extract methods for JStyle and CSL in guiActionUpdateDocument like the way you did in guiActionInsertEntry?

Thank you for helping in reviews @pluto-han!

@pluto-han
Copy link
Copy Markdown
Contributor

would you like me to also restructure the try/catch blocks inside guiActionUpdateDocument to match guiActionInsertEntry?

For me, I would prefer include try-catch as well for more readability, but I am not maintainer cannot simply decide it.
@subhramit Should try-catch be included in the extracted method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project: Refactor and unify JabRef OO components

5 participants