Skip to content

Commit

Permalink
EntitySearchField, limit added to settings panel
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorndarri committed Nov 6, 2023
1 parent d25a4fa commit 668fbf6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9848,4 +9848,5 @@
SelectionProvider renamed Selector and moved to SelectionDialogBuilder, select() parameter now JComponent dialogOwner
EntitySearchModel.limit() added, along with builder method and configuration value
EntitySearchField now displays a message in case the search result limit has been reached
EntitySearchField.Builder.limit() convenience method added
EntitySearchField.Builder.limit() convenience method added
EntitySearchField, limit added to settings panel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import static is.codion.swing.common.ui.Colors.darker;
import static is.codion.swing.common.ui.Utilities.linkToEnabledState;
import static is.codion.swing.common.ui.border.Borders.emptyBorder;
import static is.codion.swing.common.ui.component.Components.gridLayoutPanel;
import static is.codion.swing.common.ui.component.Components.menu;
import static is.codion.swing.common.ui.component.text.TextComponents.selectAllOnFocusGained;
import static is.codion.swing.common.ui.layout.Layouts.borderLayout;
Expand Down Expand Up @@ -476,9 +477,7 @@ private void initializeUI(EntitySearchModel searchModel) {
setLayout(borderLayout());
setBorder(emptyBorder());
add(createSearchColumnPanel(searchModel), BorderLayout.CENTER);
if (!searchModel.singleSelection()) {
add(createSeparatorPanel(searchModel), BorderLayout.SOUTH);
}
add(createSouthPanel(searchModel), BorderLayout.SOUTH);
}

private static JPanel createSearchColumnPanel(EntitySearchModel searchModel) {
Expand All @@ -503,17 +502,39 @@ private static JPanel createSearchColumnPanel(EntitySearchModel searchModel) {
.build();
}

private static JPanel createSouthPanel(EntitySearchModel searchModel) {
PanelBuilder southPanelBuilder = gridLayoutPanel(1, 0)
.border(BorderFactory.createTitledBorder(""));
if (!searchModel.singleSelection()) {
southPanelBuilder.add(createSeparatorPanel(searchModel));
}
else {
southPanelBuilder.add(new JLabel());
}
southPanelBuilder.add(createLimitPanel(searchModel));

return southPanelBuilder.build();
}

private static JPanel createSeparatorPanel(EntitySearchModel searchModel) {
return Components.borderLayoutPanel()
.border(BorderFactory.createTitledBorder(""))
.centerComponent(new JLabel(MESSAGES.getString("multiple_item_separator")))
.westComponent(Components.textField(searchModel.separator())
.westComponent(new JLabel(MESSAGES.getString("multiple_item_separator")))
.centerComponent(Components.textField(searchModel.separator())
.columns(1)
.maximumLength(1)
.build())
.build();
}

private static JPanel createLimitPanel(EntitySearchModel searchModel) {
return Components.borderLayoutPanel()
.westComponent(new JLabel(MESSAGES.getString("result_limit")))
.centerComponent(Components.integerField(searchModel.limit())
.columns(4)
.build())
.build();
}

private static JPanel createColumnSettingsPanel(EntitySearchModel.SearchSettings settings) {
return Components.gridLayoutPanel(3, 1)
.add(Components.checkBox(settings.caseSensitive())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ prefix_wildcard=Auto-prefix wildcard
select_entity=Select record
searching=Searching
result_limited=Result limited to {0, choice, 1#record|1<{0, number, integer} records}
result_limit=Result limit
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ prefix_wildcard=Sj\u00E1lfkrafa algildi fyrir framan
select_entity=Veldu f\u00E6rslu
searching=Leita
result_limited=Ni\u00F0urst\u00F6\u00F0ur takmarka\u00F0ar vi\u00F0 {0, choice, 1#f\u00E6rslu|1<{0, number, integer} f\u00E6rslur}
result_limit=Fj\u00F6ldatakm\u00F6rkun

0 comments on commit 668fbf6

Please sign in to comment.