* NPE bug.

[ 2164573 ] InfoPanel zoom doesn't work when not open by field editor
This commit is contained in:
Heng Sin Low 2008-10-13 21:34:24 +00:00
parent 403efcc93d
commit 784d20d001
5 changed files with 54 additions and 36 deletions

View File

@ -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;
}
/**

View File

@ -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())
{

View File

@ -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

View File

@ -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
{

View File

@ -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)