-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
base: main
Are you sure you want to change the base?
Conversation
@@ -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"); |
There was a problem hiding this comment.
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
…to ktooltip updates from jabref main
src/main/java/org/jabref/gui/fieldeditors/msccodes/MscCodeUtils.java
Outdated
Show resolved
Hide resolved
…to ktooltip pulling changes from main to local
Please fix the failing tests before. This reduces the burden of us maintainers to review incomplete PRs |
src/main/java/org/jabref/gui/fieldeditors/msccodes/MscCodeUtils.java
Outdated
Show resolved
Hide resolved
…iptions, bug: error when trying to cleanup when editor is open
…er and special characters were added
@@ -114,7 +114,8 @@ private boolean doCleanup(BibDatabaseContext databaseContext, CleanupPreferences | |||
CleanupWorker cleaner = new CleanupWorker( | |||
databaseContext, | |||
preferences.getFilePreferences(), | |||
preferences.getTimestampPreferences() | |||
preferences.getTimestampPreferences(), | |||
preferences.getBibEntryPreferences() |
There was a problem hiding this comment.
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.
src/main/java/org/jabref/logic/cleanup/ConvertMSCCodesCleanup.java
Outdated
Show resolved
Hide resolved
…to ktooltip adding changes from main
src/main/java/org/jabref/logic/cleanup/ConvertMSCCodesCleanup.java
Outdated
Show resolved
Hide resolved
MSCMigration tool = new MSCMigration(); | ||
isEditorOpen = tool.isEditorOpen(); | ||
|
||
if (!Platform.isFxApplicationThread() && isEditorOpen.get()) { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
@trag-bot didn't find any issues in the code! ✅✨ |
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
Cleanup
Before:
After:
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)