diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java index 3209087950..e315831f51 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java @@ -201,7 +201,7 @@ public class WLocationEditor extends WEditor implements EventListener, Pr ld.addEventListener(Events.ON_OPEN, new EventListener() { @Override public void onEvent(OpenEvent event) throws Exception { - if (!event.isOpen()) { + if (!event.isOpen() && !ld.isOnSaveError()) { ld.detach(); } } 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 ed49be70a5..cadf38fcd9 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 @@ -199,6 +199,11 @@ public class FDialog error(windowNo, null, adMessage, msg); } + public static void error(int windowNo, Component comp, String adMessage, String message) + { + error(windowNo, comp, adMessage, message, (Callback)null); + } + /** * Display error with error icon. * @@ -206,13 +211,14 @@ public class FDialog * @param comp Component (unused) * @param adMessage Message to be translated * @param message Additional message + * @param callback * * @see #error(int, String) * @see #error(int, Component, String) * @see #error(int, String, String) */ - public static void error(int windowNo, Component comp, String adMessage, String message) + public static void error(int windowNo, Component comp, String adMessage, String message, Callback callback) { Properties ctx = Env.getCtx(); StringBuffer out = new StringBuffer(); @@ -227,7 +233,7 @@ public class FDialog out = constructMessage(adMessage, message); String s = out.toString().replace("\n", "
"); - Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR); + Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR, callback); return; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index c3e237353e..4e6a735ac9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.StringTokenizer; import java.util.logging.Level; +import org.adempiere.util.Callback; import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Column; @@ -137,6 +138,7 @@ public class WLocationDialog extends Window implements EventListener private Button toLink; private Button toRoute; private GridField m_GridField = null; + private boolean onSaveError = false; //END public WLocationDialog(String title, MLocation location) @@ -353,6 +355,8 @@ public class WLocationDialog extends Window implements EventListener southPane.setSclass("dialog-footer"); borderlayout.appendChild(southPane); southPane.appendChild(confirmPanel); + + addEventListener("onSaveError", this); } /** * Dynamically add fields to the Location dialog box @@ -542,6 +546,8 @@ public class WLocationDialog extends Window implements EventListener { if (event.getTarget() == confirmPanel.getButton(ConfirmPanel.A_OK)) { + onSaveError = false; + inOKAction = true; if (m_location.getCountry().isHasRegion() && lstRegion.getSelectedItem() == null) { @@ -553,7 +559,13 @@ public class WLocationDialog extends Window implements EventListener String msg = validate_OK(); if (msg != null) { - FDialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg)); + onSaveError = true; + FDialog.error(0, this, "FillMandatory", Msg.parseTranslation(Env.getCtx(), msg), new Callback() { + @Override + public void onCallback(Integer result) { + Events.echoEvent("onSaveError", WLocationDialog.this, null); + } + }); inOKAction = false; return; } @@ -566,7 +578,13 @@ public class WLocationDialog extends Window implements EventListener } else { - FDialog.error(0, this, "CityNotFound"); + onSaveError = true; + FDialog.error(0, this, "CityNotFound", (String)null, new Callback() { + @Override + public void onCallback(Integer result) { + Events.echoEvent("onSaveError", WLocationDialog.this, null); + } + }); } inOKAction = false; } @@ -633,6 +651,11 @@ public class WLocationDialog extends Window implements EventListener initLocation(); lstRegion.focus(); } + else if ("onSaveError".equals(event.getName())) { + onSaveError = false; + doPopup(); + focus(); + } } @@ -730,6 +753,10 @@ public class WLocationDialog extends Window implements EventListener return success; } // actionOK + public boolean isOnSaveError() { + return onSaveError; + } + @Override public void dispose() { @@ -759,5 +786,5 @@ public class WLocationDialog extends Window implements EventListener address = address + (c.getName() != null ? c.getName() : ""); return address.replace(" ", "+"); - } + } }