IDEMPIERE-1979:auto requery with new value in parameter in info window after a action can make a Straggle
This commit is contained in:
parent
1effd5918b
commit
0a2d49f857
|
@ -116,6 +116,14 @@ public class InfoProductWindow extends InfoWindow {
|
|||
|
||||
@Override
|
||||
protected String getSQLWhere() {
|
||||
/**
|
||||
* when query not by click requery button, reuse prev where clause
|
||||
* IDEMPIERE-1979
|
||||
*/
|
||||
if (!isQueryByUser){
|
||||
return prevWhereClause;
|
||||
}
|
||||
|
||||
StringBuilder where = new StringBuilder(super.getSQLWhere());
|
||||
if (getSelectedWarehouseId() > 0) {
|
||||
if (where.length() > 0) {
|
||||
|
@ -123,7 +131,9 @@ public class InfoProductWindow extends InfoWindow {
|
|||
}
|
||||
where.append("p.IsSummary='N' ");
|
||||
}
|
||||
return where.toString();
|
||||
// IDEMPIERE-1979
|
||||
prevWhereClause = where.toString();
|
||||
return prevWhereClause;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -590,6 +590,14 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
*/
|
||||
@Override
|
||||
protected String getSQLWhere() {
|
||||
/**
|
||||
* when query not by click requery button, reuse prev where clause
|
||||
* IDEMPIERE-1979
|
||||
*/
|
||||
if (!isQueryByUser){
|
||||
return prevWhereClause;
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
MTable table = MTable.get(Env.getCtx(), infoWindow.getAD_Table_ID());
|
||||
if (!hasIsActiveEditor() && table.get_ColumnIndex("IsActive") >=0 ) {
|
||||
|
@ -678,6 +686,10 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
if (sql.indexOf("@") >= 0) {
|
||||
sql = Env.parseContext(infoContext, p_WindowNo, sql, true, true);
|
||||
}
|
||||
|
||||
// IDEMPIERE-1979
|
||||
prevWhereClause = sql;
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
@ -696,6 +708,23 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
@Override
|
||||
protected void setParameters(PreparedStatement pstmt, boolean forCount)
|
||||
throws SQLException {
|
||||
// when query not by click requery button, reuse parameter value
|
||||
if (!isQueryByUser){
|
||||
for (int parameterIndex = 0; parameterIndex < prevParameterValues.size(); parameterIndex++){
|
||||
setParameter (pstmt, parameterIndex + 1, prevParameterValues.get(parameterIndex), prevQueryOperators.get(parameterIndex));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// init collection to save current parameter value
|
||||
if (prevParameterValues == null){
|
||||
prevParameterValues = new ArrayList<Object> ();
|
||||
prevQueryOperators = new ArrayList<String> ();
|
||||
}else{
|
||||
prevParameterValues.clear();
|
||||
prevQueryOperators.clear();
|
||||
}
|
||||
|
||||
int parameterIndex = 0;
|
||||
for(WEditor editor : editors) {
|
||||
if (!editor.isVisible())
|
||||
|
@ -708,10 +737,28 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
}
|
||||
Object value = editor.getValue();
|
||||
parameterIndex++;
|
||||
prevParameterValues.add(value);
|
||||
prevQueryOperators.add(mInfoColumn.getQueryOperator());
|
||||
setParameter (pstmt, parameterIndex, value, mInfoColumn.getQueryOperator());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* set parameter for statement.
|
||||
* not need check null for value
|
||||
* @param pstmt
|
||||
* @param parameterIndex
|
||||
* @param value
|
||||
* @param queryOperator
|
||||
* @throws SQLException
|
||||
*/
|
||||
protected void setParameter (PreparedStatement pstmt, int parameterIndex, Object value, String queryOperator) throws SQLException{
|
||||
if (value instanceof Boolean) {
|
||||
pstmt.setString(parameterIndex, ((Boolean) value).booleanValue() ? "Y" : "N");
|
||||
} else if (value instanceof String) {
|
||||
if (mInfoColumn.getQueryOperator().equals(X_AD_InfoColumn.QUERYOPERATOR_Like)) {
|
||||
if (queryOperator.equals(X_AD_InfoColumn.QUERYOPERATOR_Like)) {
|
||||
StringBuilder valueStr = new StringBuilder(value.toString().toUpperCase());
|
||||
if (!valueStr.toString().endsWith("%"))
|
||||
valueStr.append("%");
|
||||
|
@ -722,10 +769,6 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
} else {
|
||||
pstmt.setObject(parameterIndex, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -300,7 +300,20 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
private boolean m_useDatabasePaging = false;
|
||||
private BusyDialog progressWindow;
|
||||
private Listitem m_lastOnSelectItem;
|
||||
|
||||
/**
|
||||
* false, use saved where clause
|
||||
* IDEMPIERE-1979
|
||||
*/
|
||||
protected boolean isQueryByUser = false;
|
||||
/**
|
||||
* save where clause of prev requery
|
||||
*/
|
||||
protected String prevWhereClause = null;
|
||||
/**
|
||||
* save value of parameter to set info query paramenter
|
||||
*/
|
||||
protected List<Object> prevParameterValues = null;
|
||||
protected List<String> prevQueryOperators = null;
|
||||
private static final String[] lISTENER_EVENTS = {};
|
||||
|
||||
/**
|
||||
|
@ -987,6 +1000,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
/**************************************************************************
|
||||
* Get dynamic WHERE part of SQL
|
||||
* To be overwritten by concrete classes
|
||||
* When override this method, please consider isQueryByUser and prevWhereClause
|
||||
* @return WHERE clause
|
||||
*/
|
||||
protected abstract String getSQLWhere();
|
||||
|
@ -994,6 +1008,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
/**
|
||||
* Set Parameters for Query
|
||||
* To be overwritten by concrete classes
|
||||
* When override this method, please consider isQueryByUser and prevWhereClause
|
||||
* @param pstmt statement
|
||||
* @param forCount for counting records
|
||||
* @throws SQLException
|
||||
|
@ -1114,8 +1129,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
}
|
||||
else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_REFRESH)))
|
||||
{
|
||||
showBusyDialog();
|
||||
Clients.response(new AuEcho(this, "onQueryCallback", null));
|
||||
onUserQuery();
|
||||
}
|
||||
else if (event.getTarget().equals(confirmPanel.getButton(ConfirmPanel.A_CANCEL)))
|
||||
{
|
||||
|
@ -1210,14 +1224,22 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
else
|
||||
SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0);
|
||||
}
|
||||
//default
|
||||
//when user push enter keyboard at input parameter field
|
||||
else
|
||||
{
|
||||
showBusyDialog();
|
||||
Clients.response(new AuEcho(this, "onQueryCallback", null));
|
||||
onUserQuery();
|
||||
}
|
||||
} // onEvent
|
||||
|
||||
/**
|
||||
* Call query when user click to query button enter in parameter field
|
||||
*/
|
||||
public void onUserQuery (){
|
||||
showBusyDialog();
|
||||
isQueryByUser = true;
|
||||
Clients.response(new AuEcho(this, "onQueryCallback", null));
|
||||
}
|
||||
|
||||
void preRunProcess (Integer processId){
|
||||
// disable all control button when run process
|
||||
enableButtons(false);
|
||||
|
@ -1269,7 +1291,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
}else if (!m_pi.isError() && m_pi.getSummary() != null && m_pi.getSummary().trim().length() > 0){
|
||||
// when success, show summary if exists
|
||||
FDialog.info(p_WindowNo, null, m_pi.getSummary());
|
||||
//showBusyDialog();
|
||||
isQueryByUser = false;
|
||||
Clients.response(new AuEcho(InfoPanel.this, "onQueryCallback", m_results));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue