From bdbed7806e1d50d92dfa4b53fb0a47f5268feb29 Mon Sep 17 00:00:00 2001 From: hieplq Date: Tue, 4 Aug 2015 02:42:56 +0800 Subject: [PATCH] IDEMPIERE-2751:potential wrong status of info window --- .../org/adempiere/webui/info/InfoWindow.java | 37 ++++++++++--------- .../org/adempiere/webui/panel/InfoPanel.java | 24 +++++++++--- 2 files changed, 38 insertions(+), 23 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 fff45ce8c1..828a1d2823 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 @@ -118,13 +118,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL public static final int FIELDLENGTH = 20; protected ColumnInfo[] columnInfos; - protected MInfoWindow infoWindow; protected TableInfo[] tableInfos; protected MInfoColumn[] infoColumns; protected String queryValue; private List gridFields; - private int AD_InfoWindow_ID; private Checkbox checkAND; /** * Menu contail process menu item @@ -170,7 +168,6 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL lookup); this.m_gridfield = field; this.queryValue = queryValue; - this.AD_InfoWindow_ID = AD_InfoWindow_ID; //Xolali IDEMPIERE-1045 contentPanel.addActionListener(new EventListener() { @@ -471,32 +468,38 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL isQueryByUser = false; } - protected boolean loadInfoDefinition() { - String tableName = null; + @Override + protected MInfoWindow loadInfoWindowData (int ADInfoWindowID){ + MInfoWindow infoWindow = null; if (AD_InfoWindow_ID > 0) { infoWindow = new MInfoWindow(Env.getCtx(), AD_InfoWindow_ID, null); - if (!infoWindow.isValid()) { - infoWindow = null; - } else { - tableName = MTable.getTableName(Env.getCtx(), infoWindow.getAD_Table_ID()); - if (!tableName.equalsIgnoreCase(p_tableName)) { - throw new IllegalArgumentException("AD_InfoWindow.TableName <> TableName argument. ("+tableName + " <> " + p_tableName+")"); - } - } - } else { + }else { infoWindow = MInfoWindow.get(p_tableName, (String)null); } + if (!infoWindow.isValid()) { + infoWindow = null; + } else { + String tableName = MTable.getTableName(Env.getCtx(), infoWindow.getAD_Table_ID()); + if (!tableName.equalsIgnoreCase(p_tableName)) { + throw new IllegalArgumentException("AD_InfoWindow.TableName <> TableName argument. ("+tableName + " <> " + p_tableName+")"); + } + } + + return infoWindow; + } + + protected boolean loadInfoDefinition() { if (infoWindow != null) { - if (tableName == null) - tableName = MTable.getTableName(Env.getCtx(), infoWindow.getAD_Table_ID()); + if (p_tableName == null) + p_tableName = MTable.getTableName(Env.getCtx(), infoWindow.getAD_Table_ID()); AccessSqlParser sqlParser = new AccessSqlParser("SELECT * FROM " + infoWindow.getFromClause()); tableInfos = sqlParser.getTableInfo(0); if (tableInfos[0].getSynonym() != null && tableInfos[0].getSynonym().trim().length() > 0) { p_tableName = tableInfos[0].getSynonym().trim(); if (p_whereClause != null && p_whereClause.trim().length() > 0) { - p_whereClause = p_whereClause.replace(tableName+".", p_tableName+"."); + p_whereClause = p_whereClause.replace(p_tableName+".", p_tableName+"."); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 94b4eda7be..a320aa4207 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -148,7 +148,8 @@ public abstract class InfoPanel extends Window implements EventListener, /** Window Width */ static final int INFO_WIDTH = 800; protected boolean m_lookup; - + protected int AD_InfoWindow_ID; + /************************************************** * Detail Constructor * @param WindowNo WindowNo @@ -163,6 +164,13 @@ public abstract class InfoPanel extends Window implements EventListener, this(WindowNo, tableName, keyColumn, multipleSelection, whereClause, true); } + protected InfoPanel (int WindowNo, + String tableName, String keyColumn,boolean multipleSelection, + String whereClause, boolean lookup){ + this(WindowNo, tableName, keyColumn, multipleSelection, whereClause, + lookup, 0); + } + /************************************************** * Detail Constructor * @param WindowNo WindowNo @@ -172,7 +180,7 @@ public abstract class InfoPanel extends Window implements EventListener, */ protected InfoPanel (int WindowNo, String tableName, String keyColumn,boolean multipleSelection, - String whereClause, boolean lookup) + String whereClause, boolean lookup, int ADInfoWindowID) { if (WindowNo <= 0) { p_WindowNo = SessionManager.getAppDesktop().registerWindow(this); @@ -182,11 +190,12 @@ public abstract class InfoPanel extends Window implements EventListener, if (log.isLoggable(Level.INFO)) log.info("WinNo=" + WindowNo + " " + whereClause); p_tableName = tableName; + this.AD_InfoWindow_ID = ADInfoWindowID; p_keyColumn = keyColumn; p_multipleSelection = multipleSelection; m_lookup = lookup; - + infoWindow = loadInfoWindowData(this.AD_InfoWindow_ID); if (whereClause == null || whereClause.indexOf('@') == -1) p_whereClause = whereClause == null ? "" : whereClause; else @@ -208,7 +217,6 @@ public abstract class InfoPanel extends Window implements EventListener, setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "infopanel"); - infoWindow = MInfoWindow.get(p_keyColumn.replace("_ID", ""), null); addEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, this); addEventListener(ON_RUN_PROCESS, this); addEventListener(Events.ON_CLOSE, this); @@ -304,7 +312,7 @@ public abstract class InfoPanel extends Window implements EventListener, /** PO Zoom Window */ private int m_PO_Window_ID = -1; - private MInfoWindow infoWindow; + protected MInfoWindow infoWindow; /** Logger */ protected CLogger log = CLogger.getCLogger(getClass()); @@ -1126,7 +1134,11 @@ public abstract class InfoPanel extends Window implements EventListener, return sb.toString(); } // getSelectedSQL; - + /** + * query ADInfoWindow from ADInfoWindowID + * @param ADInfoWindowID + */ + protected MInfoWindow loadInfoWindowData (int ADInfoWindowID){return null;} /** * Get Table name Synonym