Skip to content
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

enchancement SearchTextField #177

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gemsfx/src/main/java/com/dlsc/gemsfx/SearchTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class SearchTextField extends CustomTextField {
private static final boolean DEFAULT_ADDING_ITEM_TO_HISTORY_ON_ENTER = true;
private static final boolean DEFAULT_ADDING_ITEM_TO_HISTORY_ON_FOCUS_LOST = true;

/**
* Using Unicode Record Separator as a delimiter. This separator is utilized for separating history items when storing.
* This character is unlikely to be utilized within the history items.
*/
private static final String DELIMITER = "␞";

private static final PseudoClass DISABLED_POPUP_PSEUDO_CLASS = PseudoClass.getPseudoClass("disabled-popup");
private static final PseudoClass HISTORY_POPUP_SHOWING_PSEUDO_CLASS = PseudoClass.getPseudoClass("history-popup-showing");

Expand Down Expand Up @@ -125,16 +131,16 @@ public SearchTextField(boolean round) {
private void storeHistory() {
Preferences preferences = getPreferences();
if (preferences != null) {
preferences.put("search-items", String.join(",", getUnmodifiableHistory()));
preferences.put("history-items", String.join(DELIMITER, getUnmodifiableHistory()));
}
}

private void loadHistory() {
Preferences preferences = getPreferences();
if (preferences != null) {
String items = preferences.get("search-items", "");
String items = preferences.get("history-items", "");
if (StringUtils.isNotEmpty(items)) {
history.setAll(items.split(","));
history.setAll(items.split(DELIMITER));
}
// else { history.clear(); }
}
Expand Down
Loading