From 00f22bb30af0c2714cb8e85ed26edebddd1e7302 Mon Sep 17 00:00:00 2001 From: igorpojzl <59439434+igorpojzl@users.noreply.github.com> Date: Tue, 5 Jan 2021 14:15:26 +0100 Subject: [PATCH] IDEMPIERE-4485 Info Window Columns has no Value preference (#501) * IDEMPIERE-4485 Info Window Columns has no Value preference * IDEMPIERE-4485 Fix Query Parameter SQLWhere build. * IDEMPIERE-4485 Info Window Columns - shorter code. --- .../org/adempiere/webui/info/InfoWindow.java | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index ce9491c595..81b53abda9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -153,6 +153,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL protected WQuickEntry vqe; private List gridFields; + private TreeMap> parameterTree; private Checkbox checkAND; // F3P: Keep original values: when a row is unselected, restore original values @@ -593,6 +594,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL infoColumns = InfoColumnVO.create(Env.getCtx(), p_infoColumns); gridFields = new ArrayList(); + parameterTree = new TreeMap>(); for(InfoColumnVO infoColumn : infoColumns) { if (infoColumn.isKey()) @@ -624,6 +626,19 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL vo.IsReadOnly = infoColumn.isReadOnly(); GridField gridField = new GridField(vo); gridFields.add(gridField); + + //IDEMPIERE-4485 Clone new Gridfields with IsReadOnly = false + if(infoColumn.isQueryCriteria()) { + vo = vo.clone(infoContext, p_WindowNo, 0, vo.AD_Window_ID, 0, false); + gridField = new GridField(vo); + List list = parameterTree.get(infoColumn.getSeqNoSelection()); + if (list == null) { + list = new ArrayList(); + parameterTree.put(infoColumn.getSeqNoSelection(), list); + } + + list.add(new Object[]{infoColumn, gridField}); + } } // If we have a process and at least one process and an editable field, change to the info window rendered @@ -945,7 +960,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL builder.append(whereClause); } } else if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) { - InfoColumnVO InfoColumnVO = findInfoColumn(editor.getGridField()); + InfoColumnVO InfoColumnVO = findInfoColumnParameter(editor.getGridField()); if (InfoColumnVO == null || InfoColumnVO.getSelectClause().equals("0")) { continue; } @@ -1049,6 +1064,18 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL return null; } + protected InfoColumnVO findInfoColumnParameter(GridField gridField) { + for (Integer i : parameterTree.keySet()) { + List list = parameterTree.get(i); + for(Object[] value : list) { + if (gridField == value[1]) { + return (InfoColumnVO) value[0]; + } + } + } + return null; + } + /** * Check has new parameter is change or new input * in case first time search, return true @@ -1074,7 +1101,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL continue; if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) { - InfoColumnVO InfoColumnVO = findInfoColumn(editor.getGridField()); + InfoColumnVO InfoColumnVO = findInfoColumnParameter(editor.getGridField()); if (InfoColumnVO == null || InfoColumnVO.getSelectClause().equals("0")) { continue; } @@ -1116,7 +1143,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL continue; if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) { - InfoColumnVO InfoColumnVO = findInfoColumn(editor.getGridField()); + InfoColumnVO InfoColumnVO = findInfoColumnParameter(editor.getGridField()); if (InfoColumnVO == null || InfoColumnVO.getSelectClause().equals("0")) { continue; } @@ -1421,21 +1448,9 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL editors = new ArrayList(); identifiers = new ArrayList(); } - TreeMap> tree = new TreeMap>(); - for (int i = 0; i < infoColumns.length; i++) - { - if (infoColumns[i].isQueryCriteria()) { - List list = tree.get(infoColumns[i].getSeqNoSelection()); - if (list == null) { - list = new ArrayList(); - tree.put(infoColumns[i].getSeqNoSelection(), list); - } - list.add(new Object[]{infoColumns[i], gridFields.get(i)}); - } - } - - for (Integer i : tree.keySet()) { - List list = tree.get(i); + + for (Integer i : parameterTree.keySet()) { + List list = parameterTree.get(i); for(Object[] value : list) { if (update) { for (WEditor editor : editors) {