-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Web Import: Add New Entries to 'Imported Entries' Group #12998
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
2732800
to
d9ea011
Compare
jabgui/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java
Outdated
Show resolved
Hide resolved
@@ -61,6 +62,10 @@ public static String getShortDescriptionAllEntriesGroup() { | |||
return Localization.lang("<b>All Entries</b> (this group cannot be edited or removed)"); | |||
} | |||
|
|||
public static String getShortDescriptionSmartGroup(SmartGroup smartGroup) { |
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 method getShortDescriptionSmartGroup returns a String, which could potentially be null. New public methods should not return null and should use java.util.Optional instead.
@@ -61,6 +62,10 @@ public static String getShortDescriptionAllEntriesGroup() { | |||
return Localization.lang("<b>All Entries</b> (this group cannot be edited or removed)"); | |||
} | |||
|
|||
public static String getShortDescriptionSmartGroup(SmartGroup smartGroup) { | |||
return Localization.lang("<b>Smart Group</b> (Import Entries)"); |
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 string 'Smart Group' should be in sentence case as per the guidelines, so it should be 'Smart group'.
@@ -17,6 +17,7 @@ | |||
import org.jabref.model.groups.GroupTreeNode; | |||
import org.jabref.model.groups.KeywordGroup; | |||
import org.jabref.model.groups.SearchGroup; | |||
import org.jabref.model.groups.SmartGroup; |
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 uses Java SWING imports, which contradicts the instruction to use only JavaFX for UI technology. This could lead to inconsistencies in the UI framework used.
jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
Show resolved
Hide resolved
@@ -26,6 +27,19 @@ private static String serializeAllEntriesGroup() { | |||
return MetadataSerializationConfiguration.ALL_ENTRIES_GROUP_ID; | |||
} | |||
|
|||
private String serializeSmartGroup(SmartGroup group) { |
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 method serializeSmartGroup is private and returns a String. If this method is intended to be used externally, it should return an Optional instead of null, following modern Java practices.
@@ -206,6 +210,24 @@ private static KeywordGroup keywordGroupFromString(String s, Character keywordSe | |||
return newGroup; | |||
} | |||
|
|||
private static SmartGroup smartGroupFromString(String input, Character keywordSeparator) throws ParseException { | |||
if (!input.startsWith(MetadataSerializationConfiguration.SMART_GROUP_ID)) { |
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.
Using exceptions for control flow is not recommended. Instead of throwing an IllegalArgumentException, consider using a different approach to handle this condition.
@@ -26,6 +27,19 @@ private static String serializeAllEntriesGroup() { | |||
return MetadataSerializationConfiguration.ALL_ENTRIES_GROUP_ID; | |||
} | |||
|
|||
private String serializeSmartGroup(SmartGroup group) { |
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 method serializeSmartGroup is private and returns a String. According to the special instructions, new public methods should not return null and should use java.util.Optional. Consider making this method public and returning Optional.
@@ -206,6 +210,24 @@ private static KeywordGroup keywordGroupFromString(String s, Character keywordSe | |||
return newGroup; | |||
} | |||
|
|||
private static SmartGroup smartGroupFromString(String input, Character keywordSeparator) throws ParseException { |
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 method 'smartGroupFromString' throws a ParseException for normal control flow when parsing context fails. Exceptions should be used for exceptional states, not for normal control flow.
jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
Show resolved
Hide resolved
jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTab.java
Show resolved
Hide resolved
this.addImportedEntries.set(addImportedEntries); | ||
} | ||
|
||
public String getAddImportedEntriesGroupName() { |
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 method should return an Optional instead of a potentially null String to prevent null-related issues and align with modern Java practices.
@@ -206,6 +210,24 @@ private static KeywordGroup keywordGroupFromString(String s, Character keywordSe | |||
return newGroup; | |||
} | |||
|
|||
private static SmartGroup smartGroupFromString(String input, Character keywordSeparator) throws ParseException { | |||
if (!input.startsWith(MetadataSerializationConfiguration.SMART_GROUP_ID)) { | |||
throw new IllegalArgumentException("SmartGroup cannot be created from \"" + input + "\"."); |
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.
Avoid using exceptions for normal control flow. Consider using a different approach to handle this condition.
jablib/src/main/java/org/jabref/logic/util/MetadataSerializationConfiguration.java
Show resolved
Hide resolved
@trag-bot didn't find any issues in the code! ✅✨ |
Closes #12548
This PR introduce feature to add new group "Imported Entries"
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)