IDEMPIERE-4940 : Allow to set title and defaultvalue for FDialog.askForInput (#856)

This commit is contained in:
Nicolas Micoud 2021-09-03 07:35:11 +02:00 committed by GitHub
parent bb35dbd8ce
commit 3cf82cbd78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 5 deletions

View File

@ -37,7 +37,7 @@ import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Trace;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions;
@ -360,6 +360,11 @@ public class FDialog
}
public static void askForInput(final String message, MLookup lookup, int editorType, final Callback<Object> callback, Desktop desktop, int windowNo) {
askForInput(message, lookup, editorType, callback, desktop, windowNo, "", null);
}
public static void askForInput(final String message, MLookup lookup, int editorType, final Callback<Object> callback, Desktop desktop, int windowNo, String title, Object defaultValue) {
final WEditor weditor;
switch (editorType) {
@ -386,15 +391,24 @@ public class FDialog
weditor = null;
break;
}
if (weditor != null && defaultValue != null)
weditor.setValue(defaultValue);
Executions.schedule(desktop, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
FDialog.askForInput(windowNo, weditor, message, callback);
FDialog.askForInput(windowNo, weditor, message, title, callback);
}
}, new Event("onAskForInput"));
}
public static void askForInput(int windowNo, WEditor weditor, String adMessage, final Callback<Object> callback)
{
askForInput(windowNo, weditor, adMessage, "", callback);
}
public static void askForInput(int windowNo, WEditor weditor, String adMessage, String title, final Callback<Object> callback) // ok
{
Callback<Object> msgCallback = null;
if (callback != null)
@ -407,11 +421,15 @@ public class FDialog
};
}
String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo),
Messagebox.showDialog(s, Util.isEmpty(title) ? AEnv.getDialogHeader(Env.getCtx(), windowNo) : title,
Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, weditor, msgCallback, (msgCallback == null));
}
public static void askForInput(int windowNo, Component comp, String adMessage, final Callback<String> callback)
public static void askForInput(int windowNo, Component comp, String adMessage, final Callback<String> callback) {
askForInput(windowNo, comp, adMessage, "", callback);
}
public static void askForInput(int windowNo, Component comp, String adMessage, String title, final Callback<String> callback)
{
Callback<String> msgCallback = null;
if (callback != null)
@ -424,7 +442,7 @@ public class FDialog
};
}
String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "<br>");
Messagebox.showDialog(s, AEnv.getDialogHeader(Env.getCtx(), windowNo),
Messagebox.showDialog(s, Util.isEmpty(title) ? AEnv.getDialogHeader(Env.getCtx(), windowNo) : title,
Messagebox.OK | Messagebox.INPUT, Messagebox.QUESTION, msgCallback, (msgCallback == null));
}