IDEMPIERE-2311:bad behavior of info window when after select a record and push enter key
This commit is contained in:
parent
39c73c6eb7
commit
53a3a38fb8
|
@ -23,6 +23,7 @@ import org.adempiere.webui.component.Column;
|
|||
import org.adempiere.webui.component.Columns;
|
||||
import org.adempiere.webui.component.Combobox;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.EditorBox;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.GridFactory;
|
||||
import org.adempiere.webui.component.Label;
|
||||
|
@ -84,6 +85,7 @@ import org.zkoss.zul.North;
|
|||
import org.zkoss.zul.Separator;
|
||||
import org.zkoss.zul.South;
|
||||
import org.zkoss.zul.Space;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
/**
|
||||
|
@ -810,6 +812,42 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check has new parameter is change or new input
|
||||
* in case first time search, return true
|
||||
* @return
|
||||
*/
|
||||
protected boolean isParameteChangeValue (){
|
||||
if (prevParameterValues == null){
|
||||
// never process query, because consider as changed value to process current search
|
||||
return true;
|
||||
}
|
||||
|
||||
// compare old and new value of parameter input at prev time
|
||||
for (int parameterIndex = 0; parameterIndex < prevParameterValues.size(); parameterIndex++){
|
||||
Object newValue = prevRefParmeterEditor.get(parameterIndex).getValue();
|
||||
if (!prevParameterValues.get(parameterIndex).equals(newValue)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// in case new field is entered value
|
||||
for(WEditor editor : editors) {
|
||||
if (!editor.isVisible() || prevRefParmeterEditor.contains(editor))
|
||||
continue;
|
||||
|
||||
if (editor.getGridField() != null && editor.getValue() != null && editor.getValue().toString().trim().length() > 0) {
|
||||
MInfoColumn mInfoColumn = findInfoColumn(editor.getGridField());
|
||||
if (mInfoColumn == null || mInfoColumn.getSelectClause().equals("0")) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.panel.InfoPanel#setParameters(java.sql.PreparedStatement, boolean)
|
||||
*/
|
||||
|
@ -828,9 +866,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
if (prevParameterValues == null){
|
||||
prevParameterValues = new ArrayList<Object> ();
|
||||
prevQueryOperators = new ArrayList<String> ();
|
||||
prevRefParmeterEditor = new ArrayList<WEditor>();
|
||||
}else{
|
||||
prevParameterValues.clear();
|
||||
prevQueryOperators.clear();
|
||||
prevRefParmeterEditor.clear();
|
||||
}
|
||||
|
||||
int parameterIndex = 0;
|
||||
|
@ -847,6 +887,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
parameterIndex++;
|
||||
prevParameterValues.add(value);
|
||||
prevQueryOperators.add(mInfoColumn.getQueryOperator());
|
||||
prevRefParmeterEditor.add(editor);
|
||||
setParameter (pstmt, parameterIndex, value, mInfoColumn.getQueryOperator());
|
||||
}
|
||||
}
|
||||
|
@ -1439,6 +1480,35 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
SessionManager.getAppDesktop().updateHelpTooltip(selectedValue.get_Translation(MProcess.COLUMNNAME_Name), selectedValue.get_Translation(MProcess.COLUMNNAME_Description), selectedValue.get_Translation(MProcess.COLUMNNAME_Help), null);
|
||||
}
|
||||
|
||||
}else if (event.getName().equals(Events.ON_OK) && event.getTarget() != null){ // event when push enter at parameter
|
||||
Component tagetComponent = event.getTarget();
|
||||
boolean isCacheEvent = false;// when event from parameter component, catch it and process at there
|
||||
for(WEditor editor : editors) {
|
||||
Component editorComponent = editor.getComponent();
|
||||
if (editorComponent instanceof EditorBox){
|
||||
editorComponent = ((EditorBox)editorComponent).getTextbox();
|
||||
}
|
||||
if (editorComponent.equals(tagetComponent)){
|
||||
isCacheEvent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCacheEvent){
|
||||
boolean isParameterChange = isParameteChangeValue();
|
||||
// when change parameter, also requery
|
||||
if (isParameterChange){
|
||||
onUserQuery();
|
||||
}else if (m_lookup && contentPanel.getSelectedIndex() >= 0){
|
||||
// do nothing when parameter not change and at window mode, or at dialog mode but select non record
|
||||
onOk();
|
||||
}else {
|
||||
// parameter not change. do nothing.
|
||||
}
|
||||
}else{
|
||||
super.onEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1510,7 +1580,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
|
||||
if (dynWhere.length() > 0)
|
||||
sql.append(dynWhere); // includes first AND
|
||||
|
||||
|
||||
String countSql = Msg.parseTranslation(Env.getCtx(), sql.toString()); // Variables
|
||||
if (countSql.trim().endsWith("WHERE")) {
|
||||
countSql = countSql.trim();
|
||||
|
|
|
@ -325,6 +325,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
*/
|
||||
protected List<Object> prevParameterValues = null;
|
||||
protected List<String> prevQueryOperators = null;
|
||||
protected List<WEditor> prevRefParmeterEditor = null;
|
||||
private static final String[] lISTENER_EVENTS = {};
|
||||
|
||||
/**
|
||||
|
@ -1368,6 +1369,11 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
if (LayoutUtils.isReallyVisible(this)) {
|
||||
this.onCtrlKeyEvent(keyEvent);
|
||||
}
|
||||
}else if (event.getName().equals(Events.ON_OK)){// on ok when focus at non parameter component. example grid result
|
||||
if (m_lookup && contentPanel.getSelectedIndex() >= 0){
|
||||
// do nothing when parameter not change and at window mode, or at dialog mode but select non record
|
||||
onOk();
|
||||
}
|
||||
}
|
||||
//when user push enter keyboard at input parameter field
|
||||
else
|
||||
|
@ -1388,13 +1394,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
}
|
||||
}
|
||||
} else if (keyEvent.getKeyCode() == VK_ENTER) { // Enter
|
||||
// enter in contentpanel to select
|
||||
//when user push enter keyboard at input parameter field
|
||||
if (m_lookup && contentPanel.getSelectedIndex() >= 0) {
|
||||
onOk();
|
||||
} else {
|
||||
onUserQuery();
|
||||
}
|
||||
// do nothing, let on_ok at infoWindo do, at this is too soon to get value from control, it's not bind
|
||||
} else if (keyEvent.getKeyCode() == VK_ESCAPE) { // Escape
|
||||
// Escape for cancel
|
||||
m_cancel = true;
|
||||
|
@ -1573,7 +1573,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
|||
*/
|
||||
protected void bindInfoProcess (){}
|
||||
|
||||
private void onOk()
|
||||
protected void onOk()
|
||||
{
|
||||
if (!contentPanel.getChildren().isEmpty() && contentPanel.getSelectedRowKey()!=null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue