IDEMPIERE-5195 SEARCH FAILURE FOR SAVED QUERIES + IDEMPIERE-4658 #resolve (#1191)

- Fix issue reported in IDEMPIERE-5195 saving wrongly Yes/No values as true/false
- Fix also wrong recover of timestamps just as dates (ignoring the time part)
- Fix also IDEMPIERE-4568 reopened, adding wrongly operators
This commit is contained in:
Carlos Ruiz 2022-02-18 06:35:44 +01:00 committed by GitHub
parent bedf226a21
commit f7f554627c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 16 deletions

View File

@ -43,6 +43,7 @@ import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.AbstractADWindowContent; import org.adempiere.webui.adwindow.AbstractADWindowContent;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox;
import org.adempiere.webui.component.Column; import org.adempiere.webui.component.Column;
import org.adempiere.webui.component.Columns; import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.ComboItem; import org.adempiere.webui.component.ComboItem;
@ -1420,19 +1421,29 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
} }
if(!selected) listColumn.setSelectedIndex(0); if(!selected) listColumn.setSelectedIndex(0);
if (liCol != null)
addOperators(liCol, listOperator);
selected = false; selected = false;
for (int i = 0; i < op.length; i++) if (liCol != null) {
{ addOperators(liCol, listOperator);
ValueNamePair item = op[i]; for (Component listitem : listOperator.getChildren()) {
ComboItem li = new ComboItem(Msg.getMsg(Env.getCtx(), item.getName()), item.getValue()); if (listitem instanceof ComboItem) {
listOperator.appendChild(li); if (((ComboItem)listitem).getValue().equals(operator)) {
if(item.getValue().equals(operator)) listOperator.setSelectedItem((ComboItem)listitem);
selected = true;
break;
}
}
}
} else {
for (int i = 0; i < op.length; i++)
{ {
listOperator.setSelectedItem(li); ValueNamePair item = op[i];
selected = true; ComboItem li = new ComboItem(Msg.getMsg(Env.getCtx(), item.getName()), item.getValue());
listOperator.appendChild(li);
if(item.getValue().equals(operator))
{
listOperator.setSelectedItem(li);
selected = true;
}
} }
} }
if(!selected) listOperator.setSelectedIndex(0); if(!selected) listOperator.setSelectedIndex(0);
@ -2015,7 +2026,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
long time = 0; long time = 0;
try try
{ {
time = DisplayType.getDateFormat_JDBC().parse(in).getTime(); time = DisplayType.getTimestampFormat_Default().parse(in).getTime();
editor.setValue(new Timestamp(time)); editor.setValue(new Timestamp(time));
} }
catch (Exception e) catch (Exception e)
@ -2028,9 +2039,14 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
editor.setValue(new Timestamp(time)); editor.setValue(new Timestamp(time));
} }
else if (dt == DisplayType.YesNo) else if (dt == DisplayType.YesNo)
editor.setValue(Boolean.valueOf(in)); {
boolean val = ("Y".equalsIgnoreCase(in) || "true".equalsIgnoreCase(in));
editor.setValue(val);
}
else else
{
editor.setValue(in); editor.setValue(in);
}
editor.addValueChangeListener(this); editor.addValueChangeListener(this);
@ -2184,6 +2200,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
if(dtbox.getValue() != null) if(dtbox.getValue() != null)
value = new Timestamp(((Date)dtbox.getValue()).getTime()); value = new Timestamp(((Date)dtbox.getValue()).getTime());
} }
else if(compo instanceof Checkbox && cellQueryFrom.getAttribute("value") instanceof Boolean) {
value = ((boolean) cellQueryFrom.getAttribute("value") ? "Y" : "N");
}
else { else {
value = cellQueryFrom.getAttribute("value"); value = cellQueryFrom.getAttribute("value");
} }
@ -2250,12 +2269,13 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
if(dtbox.getValue() != null) if(dtbox.getValue() != null)
value2 = new Timestamp(((Date)dtbox.getValue()).getTime()); value2 = new Timestamp(((Date)dtbox.getValue()).getTime());
} }
else if(compo instanceof Checkbox && cellQueryTo.getAttribute("value") instanceof Boolean) {
value2 = ((boolean) cellQueryTo.getAttribute("value") ? "Y" : "N");
}
else { else {
value2 = cellQueryFrom.getAttribute("value"); value2 = cellQueryTo.getAttribute("value");
} }
value2 = cellQueryTo.getAttribute("value");
if (value2 == null) if (value2 == null)
continue; continue;
Object parsedValue2 = null; Object parsedValue2 = null;