Skip to content

Commit

Permalink
ItemComboBoxBuilder.normalize() added
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorndarri committed Nov 29, 2024
1 parent dd5b797 commit 3ba6665
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Codion Change Log
- Completion.NORMALIZE configuration value added.
- Completion.COMBO_BOX_COMPLETION_MODE renamed COMPLETION_MODE.
- ComboBoxBuilder.normalize() added.
- ItemComboBoxBuilder.normalize() added.

## 0.18.21
### is.codion.common.db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ final class DefaultItemComboBoxBuilder<T> extends AbstractComponentBuilder<T, JC
private boolean sorted = false;
private boolean nullable;
private Completion.Mode completionMode = Completion.COMPLETION_MODE.get();
private Completion.Normalize normalize = Completion.NORMALIZE.get();
private boolean mouseWheelScrolling = true;
private boolean mouseWheelScrollingWithWrapAround = false;
private int maximumRowCount = -1;
Expand Down Expand Up @@ -101,6 +102,12 @@ public ItemComboBoxBuilder<T> completionMode(Completion.Mode completionMode) {
return this;
}

@Override
public ItemComboBoxBuilder<T> normalize(Completion.Normalize normalize) {
this.normalize = requireNonNull(normalize);
return this;
}

@Override
public ItemComboBoxBuilder<T> mouseWheelScrolling(boolean mouseWheelScrolling) {
this.mouseWheelScrolling = mouseWheelScrolling;
Expand Down Expand Up @@ -153,7 +160,9 @@ public ItemComboBoxBuilder<T> itemListener(ItemListener itemListener) {
protected JComboBox<Item<T>> createComponent() {
FilterComboBoxModel<Item<T>> itemComboBoxModel = comboBoxModel == null ? createItemComboBoxModel() : comboBoxModel;
JComboBox<Item<T>> comboBox = new FocusableComboBox<>(itemComboBoxModel);
Completion.enable(comboBox, completionMode);
if (editor == null) {
Completion.enable(comboBox, completionMode, normalize);
}
if (renderer != null) {
comboBox.setRenderer(renderer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public interface ItemComboBoxBuilder<T> extends ComponentBuilder<T, JComboBox<It
*/
ItemComboBoxBuilder<T> completionMode(Completion.Mode completionMode);

/**
* Specifies whether to normalize strings during auto completion
* @param normalize true if strings should be normalized during autocomplete
* @return this builder instance
* @see #completionMode(Completion.Mode)
*/
ItemComboBoxBuilder<T> normalize(Completion.Normalize normalize);

/**
* Enable mouse wheel scrolling on the combo box
* @param mouseWheelScrolling true if mouse wheel scrolling should be enabled
Expand Down

0 comments on commit 3ba6665

Please sign in to comment.