From 784d20d0019d4c597e32f30f175c2bb82650b0a3 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 13 Oct 2008 21:34:24 +0000 Subject: [PATCH] * NPE bug. [ 2164573 ] InfoPanel zoom doesn't work when not open by field editor --- .../webui/panel/InfoAssignmentPanel.java | 23 ++++++++++++++---- .../webui/panel/InfoCashLinePanel.java | 16 ++++++++----- .../adempiere/webui/panel/InfoInOutPanel.java | 19 --------------- .../adempiere/webui/panel/InfoOrderPanel.java | 8 +++---- .../org/adempiere/webui/panel/InfoPanel.java | 24 ++++++++++++++++--- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java index 62d8134397..0ae794435b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java @@ -23,6 +23,7 @@ import java.sql.Timestamp; import java.util.Date; import java.util.logging.Level; +import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Datebox; import org.adempiere.webui.component.Label; @@ -35,6 +36,7 @@ import org.adempiere.webui.event.WTableModelEvent; import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.IDColumn; import org.compiere.model.MLookupFactory; +import org.compiere.model.MQuery; import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; @@ -99,7 +101,7 @@ public class InfoAssignmentPanel extends InfoPanel implements EventListener, Val public InfoAssignmentPanel (int WindowNo, String value, boolean multiSelection, String whereClause) { - super (WindowNo, "ra", "S_ResourceAssigment_ID", + super (WindowNo, "ra", "S_ResourceAssignment_ID", multiSelection, whereClause); log.info(value); setTitle(Msg.getMsg(Env.getCtx(), "InfoAssignment")); @@ -269,13 +271,13 @@ public class InfoAssignmentPanel extends InfoPanel implements EventListener, Val sql.append(" AND r.S_Resource_ID=").append(S_Resource_ID.intValue()); Date f = fieldFrom.getValue(); - Timestamp ts = new Timestamp(f.getTime()); + Timestamp ts = f != null ? new Timestamp(f.getTime()) : null; if (ts != null) sql.append(" AND TRUNC(ra.AssignDateFrom)>=").append(DB.TO_DATE(ts,false)); Date t = fieldTo.getValue(); - ts = new Timestamp(t.getTime()); + ts = t != null ? new Timestamp(t.getTime()) : null; if (ts != null) sql.append(" AND TRUNC(ra.AssignDateTo)<=").append(DB.TO_DATE(ts,false)); @@ -342,6 +344,19 @@ public class InfoAssignmentPanel extends InfoPanel implements EventListener, Val public void zoom() { + if (getSelectedRowKey() != null && getSelectedRowKey() > 0) + { + MQuery zoomQuery = new MQuery(); // ColumnName might be changed in MTab.validateQuery + String column = getKeyColumn(); + //strip off table name, fully qualify name doesn't work when zoom into detail tab + if (column.indexOf(".") > 0) + column = column.substring(column.indexOf(".")+1); + zoomQuery.addRestriction(column, MQuery.EQUAL, getSelectedRowKey()); + zoomQuery.setRecordCount(1); + zoomQuery.setTableName(column.substring(0, column.length() - 3)); + + AEnv.zoom(236, zoomQuery); + } } /** @@ -352,7 +367,7 @@ public class InfoAssignmentPanel extends InfoPanel implements EventListener, Val boolean hasZoom() { - return false; + return true; } /** diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java index a3ed44b4ea..019a8164c4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java @@ -343,10 +343,10 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, sql.append(" AND TRUNC(c.StatementDate) BETWEEN ? AND ?"); } - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) + if (!isEmpty(fAmtFrom.getValue()) || !isEmpty(fAmtTo.getValue())) { - BigDecimal from = new BigDecimal(fAmtFrom.getValue()); - BigDecimal to = new BigDecimal(fAmtTo.getValue()); + BigDecimal from = isEmpty(fAmtFrom.getValue()) ? null : new BigDecimal(fAmtFrom.getValue()); + BigDecimal to = isEmpty(fAmtTo.getValue()) ? null : new BigDecimal(fAmtTo.getValue()); if (cbAbsolute .isChecked()) sql.append(" AND ABS(cl.Amount)"); @@ -370,6 +370,10 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, return sql.toString(); } // getSQLWhere + private boolean isEmpty(String value) { + return value == null || value.trim().length() == 0; + } + /** * Set Parameters for Query. * (as defined in getSQLWhere) @@ -419,10 +423,10 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, } } - if (fAmtFrom.getValue() != null || fAmtTo.getValue() != null) + if (!isEmpty(fAmtFrom.getValue()) || !isEmpty(fAmtTo.getValue())) { - BigDecimal from = new BigDecimal(fAmtFrom.getValue()); - BigDecimal to = new BigDecimal(fAmtTo.getValue()); + BigDecimal from = isEmpty(fAmtFrom.getValue()) ? null : new BigDecimal(fAmtFrom.getValue()); + BigDecimal to = isEmpty(fAmtTo.getValue()) ? null : new BigDecimal(fAmtTo.getValue()); if (cbAbsolute.isChecked()) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java index 7e11ca6bed..412cca31dc 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java @@ -382,25 +382,6 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev return s; } // getSQLText - /** - * Zoom - */ - - public void zoom() - { -/* log.info( "InfoInOut.zoom"); - Integer M_InOut_ID = getSelectedRowKey(); - - if (M_InOut_ID == null) - return; - - MQuery query = new MQuery("M_InOut"); - query.addRestriction("M_InOut_ID", MQuery.EQUAL, M_InOut_ID); - query.setRecordCount(1); - int AD_WindowNo = getAD_Window_ID("M_InOut", fIsSOTrx.isSelected()); - zoom (AD_WindowNo, query);*/ - } // zoom - /** * Has Zoom * @return true diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java index 5eb68ae4b7..20a97e09ea 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java @@ -315,7 +315,7 @@ public class InfoOrderPanel extends InfoPanel implements ValueChangeListener // Double fromAmount = null; Double toAmount = null; - if (!amountFrom.getText().equals("")) + if (amountFrom.getText() != null && amountFrom.getText().trim().length() > 0) { try { @@ -326,7 +326,7 @@ public class InfoOrderPanel extends InfoPanel implements ValueChangeListener } } - if (!amountTo.getText().equals("")) + if (amountTo.getText() != null && amountTo.getText().trim().length() > 0) { try { @@ -424,7 +424,7 @@ public class InfoOrderPanel extends InfoPanel implements ValueChangeListener Double fromAmt = null; Double toAmt = null; - if (!amountFrom.getText().equals("")) + if (amountFrom.getText() != null && amountFrom.getText().trim().length() > 0) { try { @@ -437,7 +437,7 @@ public class InfoOrderPanel extends InfoPanel implements ValueChangeListener } } - if (!amountTo.getText().equals("")) + if (amountTo.getText() != null && amountTo.getText().trim().length() > 0) { try { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 5c06cb3e1c..c11028997b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -38,6 +38,7 @@ import org.adempiere.webui.event.WTableModelListener; import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.IDColumn; import org.compiere.model.MRole; +import org.compiere.model.MTable; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -862,9 +863,26 @@ public abstract class InfoPanel extends Window implements EventListener, WTableM public void zoom() { - ValueChangeEvent event = new ValueChangeEvent(this,"zoom", - contentPanel.getSelectedRowKey(),contentPanel.getSelectedRowKey()); - fireValueChange(event); + if (listeners != null && listeners.size() > 0) + { + ValueChangeEvent event = new ValueChangeEvent(this,"zoom", + contentPanel.getSelectedRowKey(),contentPanel.getSelectedRowKey()); + fireValueChange(event); + } + else + { + int recordId = contentPanel.getSelectedRowKey(); + int AD_Table_ID = MTable.getTable_ID(p_tableName); + if (AD_Table_ID <= 0) + { + if (p_keyColumn.endsWith("_ID")) + { + AD_Table_ID = MTable.getTable_ID(p_keyColumn.substring(0, p_keyColumn.length() - 3)); + } + } + if (AD_Table_ID > 0) + AEnv.zoom(AD_Table_ID, recordId); + } } public void addValueChangeListener(ValueChangeListener listener)