Skip to content

Keyword Tooltip/Cleanup for MSC codes added to Keyword Editor #12914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

JustinHennis1
Copy link

@JustinHennis1 JustinHennis1 commented Apr 9, 2025

Closes #12944

Created a JSON file to hold key-value pairs of MSC codes to their respective descriptions/classifications by parsing msc_2020.pdf (which was provided in link to zbmath).

Created MscCodeUtils.java class that implements a method to load a JSON file and converts said file into a Map object.

Created ConvertMSCCodesCleanupTest.java, added to panel, and when user selects preference to convert and saves, the codes are converted to descriptions. Alternatively, when unselected, descriptions are reverted back to code.

In KeywordsEditor.java I added a private variable, mscmap, that calls the above method. Using this map object, I added a condition in the create tag method to check if the label text matches any of the keys. If it does, then we initialize a Tooltip and call install onMouseEnter and uninstall onMouseExited.

ToolTip

Screenshot (18)
Screenshot (19)

Cleanup

Before:

jabref_cleanup

After:

jabrefcleanup2

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.

@@ -50,6 +55,8 @@ public class KeywordsEditor extends HBox implements FieldEditorFX {
private static final Logger LOGGER = LoggerFactory.getLogger(KeywordsEditor.class);
private static final PseudoClass FOCUSED = PseudoClass.getPseudoClass("focused");

private Map<String, String> mscmap = MscCodeUtils.loadMscCodesFromJson("../../resources/main/org/jabref/gui/fieldeditors/msccodes/msc_codes.json");
Copy link
Member

Choose a reason for hiding this comment

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

This won't work inside a jar, you need to use class.getResource

@JustinHennis1 JustinHennis1 reopened this Apr 10, 2025
@Siedlerchr
Copy link
Member

Please fix the failing tests before. This reduces the burden of us maintainers to review incomplete PRs

…iptions, bug: error when trying to cleanup when editor is open
@JustinHennis1 JustinHennis1 reopened this Apr 14, 2025
@@ -114,7 +114,8 @@ private boolean doCleanup(BibDatabaseContext databaseContext, CleanupPreferences
CleanupWorker cleaner = new CleanupWorker(
databaseContext,
preferences.getFilePreferences(),
preferences.getTimestampPreferences()
preferences.getTimestampPreferences(),
preferences.getBibEntryPreferences()
Copy link

Choose a reason for hiding this comment

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

The addition of preferences.getBibEntryPreferences() to the CleanupWorker constructor requires updating the JavaDoc for doCleanup method to reflect this change in parameters.

@JustinHennis1 JustinHennis1 changed the title Keyword Tooltip for MSC codes added to Keyword Editor Keyword Tooltip/Cleanup for MSC codes added to Keyword Editor Apr 16, 2025
@JustinHennis1 JustinHennis1 marked this pull request as draft April 16, 2025 00:24
@JustinHennis1 JustinHennis1 marked this pull request as ready for review April 16, 2025 23:49
MSCMigration tool = new MSCMigration();
isEditorOpen = tool.isEditorOpen();

if (!Platform.isFxApplicationThread() && isEditorOpen.get()) {
Copy link

Choose a reason for hiding this comment

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

The code does not follow the fail-fast principle. It should return early if the condition is false, instead of nesting the logic inside an else branch.

}

String keywordsStr = entry.getField(StandardField.KEYWORDS).orElse("");
if (keywordsStr.trim().isEmpty()) {
Copy link

Choose a reason for hiding this comment

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

The code does not follow the fail-fast principle. It should return early if the condition is false, instead of nesting the logic inside an else branch.

}

@Test
void cleanupHandlesInvalidMSCCode() {
Copy link

Choose a reason for hiding this comment

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

The test method name should be more descriptive to indicate it tests the preservation of invalid MSC codes alongside valid keywords.

}

@Test
void cleanupHandlesNoKeywordsField() {
Copy link

Choose a reason for hiding this comment

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

The test method name should be more descriptive to indicate it tests the behavior when no keywords field is present in the BibEntry.

}

@Test
void cleanupHandlesMultipleMSCCodes() {
Copy link

Choose a reason for hiding this comment

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

The test method name should be more descriptive to indicate it tests the conversion of multiple MSC codes within a single entry.

Copy link

trag-bot bot commented Apr 21, 2025

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

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.

Add Mathematics Subject Classification as tooltip to keywords
3 participants