From 3cf82cbd7874946f293d5b2ba269ff96219f308f Mon Sep 17 00:00:00 2001 From: Nicolas Micoud <58596990+nmicoud@users.noreply.github.com> Date: Fri, 3 Sep 2021 07:35:11 +0200 Subject: [PATCH] IDEMPIERE-4940 : Allow to set title and defaultvalue for FDialog.askForInput (#856) --- .../org/adempiere/webui/window/FDialog.java | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FDialog.java index b89f4fad6f..bec4d5c869 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FDialog.java @@ -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 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 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() { @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 callback) + { + askForInput(windowNo, weditor, adMessage, "", callback); + } + + public static void askForInput(int windowNo, WEditor weditor, String adMessage, String title, final Callback callback) // ok { Callback msgCallback = null; if (callback != null) @@ -407,11 +421,15 @@ public class FDialog }; } String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "
"); - 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 callback) + public static void askForInput(int windowNo, Component comp, String adMessage, final Callback callback) { + askForInput(windowNo, comp, adMessage, "", callback); + } + + public static void askForInput(int windowNo, Component comp, String adMessage, String title, final Callback callback) { Callback msgCallback = null; if (callback != null) @@ -424,7 +442,7 @@ public class FDialog }; } String s = Msg.getMsg(Env.getCtx(), adMessage).replace("\n", "
"); - 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)); }