IDEMPIERE-5921 Enable Multi-Selection on Search fields (Info Windows) by default (#2107)

* IDEMPIERE-5921 Enable Multi-Selection on Search fields (Info Windows) by default

* Fix first open as single selection
* Make it work as single selection for custom form (tested with Payment Allocation form)
* Added setMultipleSelection(boolean) api

* * Fix also Info Product on forms

---------

Co-authored-by: hengsin <hengsin@gmail.com>
This commit is contained in:
Carlos Ruiz 2023-11-13 15:34:51 +01:00 committed by GitHub
parent 75be677f2e
commit 2547edf522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -107,6 +107,8 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
protected ADWindow adwindow;
private EventListener<InputEvent> autoCompleteListener;
protected boolean multipleSelection = false;
/**
*
* @param gridField
@ -133,6 +135,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
init();
getComponent().setAttribute(ATTRIBUTE_IS_INFO_PANEL_OPEN, false);
multipleSelection = true;
}
@ -176,6 +179,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
columnName = lookup.getColumnName();
super.setColumnName(columnName);
init();
multipleSelection = false;
}
/**
@ -200,6 +204,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
this.columnName = columnName;
super.setColumnName(columnName);
init();
multipleSelection = false;
}
@ -512,7 +517,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
setTableAndKeyColumn();
// process input text with infopanel/infowindow
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), true, getWhereClause());
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), multipleSelection, getWhereClause());
if (ip != null && ip.loadedOK() && ip.getRowCount() == 1)
{
if (ip.getFirstRowKey() instanceof Integer)
@ -742,7 +747,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
if (m_tableName == null) // sets table name & key column
setTableAndKeyColumn();
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, queryValue, true, whereClause);
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, queryValue, multipleSelection, whereClause);
if (ip != null)
showInfoPanel(ip);
}
@ -977,6 +982,20 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
return s;
}
/**
* @return true if info window allow multiple selection
*/
public boolean isMultipleSelection() {
return multipleSelection;
}
/**
* @param multipleSelection
*/
public void setMultipleSelection(boolean multipleSelection) {
this.multipleSelection = multipleSelection;
}
/**
* Search box component
*/

View File

@ -164,7 +164,7 @@ public class DefaultInfoFactory implements IInfoFactory {
if (col.equals("M_Product_ID"))
{
InfoWindow infoWindow = new InfoProductWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, true, whereClause, AD_InfoWindow_ID, true, field);
InfoWindow infoWindow = new InfoProductWindow(lookup.getWindowNo(), tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID, true, field);
if (infoWindow.loadedOK())
return infoWindow;

View File

@ -141,7 +141,7 @@ public class InfoManager
if (service != null)
{
s_infoFactoryCache.put(serviceId, serviceReference);
ip = service.create(lookup, field, tableName, keyColumn, queryValue, false, whereClause, AD_InfoWindow_ID);
ip = service.create(lookup, field, tableName, keyColumn, queryValue, multiSelection, whereClause, AD_InfoWindow_ID);
if (ip != null)
break;
}