IDEMPIERE-3786 Number of records in detail grid must not be hardcoded

This commit is contained in:
Carlos Ruiz 2020-03-21 11:50:46 +01:00
parent e875d2cd6c
commit 1e638f5a28
4 changed files with 73 additions and 7 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3786 Number of records in detail grid must not be hardcoded
-- Mar 21, 2020, 11:37:03 AM CET
UPDATE AD_SysConfig SET Description='Default paging size for detail grid view in zk webui. It can be a single integer, or a list of components separated by semicolon (;). First component is the default, further components are exceptions as pair of [AD_Tab_ID|AD_Tab_UU|AD_TableName]:[size]',Updated=TO_DATE('2020-03-21 11:37:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID=200143
;
SELECT register_migration_script('202003211140_IDEMPIERE-3786.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-3786 Number of records in detail grid must not be hardcoded
-- Mar 21, 2020, 11:37:03 AM CET
UPDATE AD_SysConfig SET Description='Default paging size for detail grid view in zk webui. It can be a single integer, or a list of components separated by semicolon (;). First component is the default, further components are exceptions as pair of [AD_Tab_ID|AD_Tab_UU|AD_TableName]:[size]',Updated=TO_TIMESTAMP('2020-03-21 11:37:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID=200143
;
SELECT register_migration_script('202003211140_IDEMPIERE-3786.sql') FROM dual
;

View File

@ -1753,7 +1753,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
attachDetailPane();
}
ZKUpdateUtil.setVflex(this, "true");
listPanel.setDetailPaneMode(detailPaneMode);
listPanel.setDetailPaneMode(detailPaneMode, gridTab);
}
}

View File

@ -42,6 +42,7 @@ import org.compiere.model.GridTable;
import org.compiere.model.MSysConfig;
import org.compiere.model.StateChangeEvent;
import org.compiere.model.StateChangeListener;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -77,7 +78,7 @@ public class GridView extends Vlayout implements EventListener<Event>, IdSpace,
/**
*
*/
private static final long serialVersionUID = 3046157124327495333L;
private static final long serialVersionUID = 3995829393137424527L;
private static final String HEADER_GRID_STYLE = "border: none; margin:0; padding: 0;";
@ -97,6 +98,9 @@ public class GridView extends Vlayout implements EventListener<Event>, IdSpace,
private static final String ATTR_ON_POST_SELECTED_ROW_CHANGED = "org.adempiere.webui.adwindow.GridView.onPostSelectedRowChanged";
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (GridView.class);
private Grid listbox = null;
private int pageSize = DEFAULT_PAGE_SIZE;
@ -204,17 +208,60 @@ public class GridView extends Vlayout implements EventListener<Event>, IdSpace,
listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Processing")));
}
public void setDetailPaneMode(boolean detailPaneMode) {
public void setDetailPaneMode(boolean detailPaneMode, GridTab gridTab) {
if (this.detailPaneMode != detailPaneMode) {
this.detailPaneMode = detailPaneMode;
pageSize = detailPaneMode ? getDetailPageSize() : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20, Env.getAD_Client_ID(Env.getCtx()));
pageSize = detailPaneMode ? getDetailPageSize(gridTab) : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20, Env.getAD_Client_ID(Env.getCtx()));
updatePaging();
}
}
/** Returns the number of records to be displayed in detail grid (TODO : manage exceptions defined in SysConfig - see https://idempiere.atlassian.net/browse/IDEMPIERE-3786) */
int getDetailPageSize() {
return MSysConfig.getIntValue(MSysConfig.ZK_PAGING_DETAIL_SIZE, DEFAULT_DETAIL_PAGE_SIZE, Env.getAD_Client_ID(Env.getCtx()));
/** Returns the number of records to be displayed in detail grid */
private int getDetailPageSize(GridTab gridTab) {
int size = DEFAULT_DETAIL_PAGE_SIZE;
String pageDetailSizes = MSysConfig.getValue(MSysConfig.ZK_PAGING_DETAIL_SIZE, Env.getAD_Client_ID(Env.getCtx()));
if (Util.isEmpty(pageDetailSizes, true)) {
return size;
}
/* Format of ZK_PAGING_DETAIL_SIZE is a list of components separated by ;
* first component is the wide default
* next components are exceptions defined as pair of tab:size - where tab can be AD_Tab_ID, AD_Tab_UU or AD_TableName
*/
for (String pageDetailSize : pageDetailSizes.split(";")) {
String[] parts = pageDetailSize.split(":");
if (parts.length < 1 || parts.length > 2) {
s_log.warning("Misconfiguration of ZK_PAGING_DETAIL_SIZE - cannot split : in -> " + pageDetailSize);
return size;
}
String sizeToParse = null;
if (parts.length == 1) {
sizeToParse = parts[0];
} else {
String tab = parts[0];
if ( tab.equalsIgnoreCase(String.valueOf(gridTab.getAD_Tab_ID()))
|| tab.equalsIgnoreCase(String.valueOf(gridTab.getAD_Tab_UU()))
|| tab.equalsIgnoreCase(String.valueOf(gridTab.getTableName()))) {
sizeToParse = parts[1];
}
}
if (sizeToParse != null) {
int sizeParsed = -1;
try {
sizeParsed = Integer.valueOf(sizeToParse);
} catch (NumberFormatException e) {
s_log.warning("Misconfiguration of ZK_PAGING_DETAIL_SIZE - cannot parse as integer -> " + sizeToParse);
return size;
}
if (sizeParsed > 0) {
size = sizeParsed;
if (parts.length > 1) {
// found a specific tab size configuration
break;
}
}
}
}
return size;
}
public boolean isDetailPaneMode() {