IDEMPIERE-980 Address window is closing on error.
This commit is contained in:
parent
bd7d732f87
commit
da131cc538
|
@ -201,7 +201,7 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
|||
ld.addEventListener(Events.ON_OPEN, new EventListener<OpenEvent>() {
|
||||
@Override
|
||||
public void onEvent(OpenEvent event) throws Exception {
|
||||
if (!event.isOpen()) {
|
||||
if (!event.isOpen() && !ld.isOnSaveError()) {
|
||||
ld.detach();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Integer>)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<Integer> 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", "<br>");
|
||||
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR);
|
||||
Messagebox.showDialog(s, AEnv.getDialogHeader(ctx, windowNo), Messagebox.OK, Messagebox.ERROR, callback);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -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<Event>
|
|||
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<Event>
|
|||
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<Event>
|
|||
{
|
||||
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<Event>
|
|||
|
||||
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<Integer>() {
|
||||
@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<Event>
|
|||
}
|
||||
else
|
||||
{
|
||||
FDialog.error(0, this, "CityNotFound");
|
||||
onSaveError = true;
|
||||
FDialog.error(0, this, "CityNotFound", (String)null, new Callback<Integer>() {
|
||||
@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<Event>
|
|||
initLocation();
|
||||
lstRegion.focus();
|
||||
}
|
||||
else if ("onSaveError".equals(event.getName())) {
|
||||
onSaveError = false;
|
||||
doPopup();
|
||||
focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -730,6 +753,10 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
|||
return success;
|
||||
} // actionOK
|
||||
|
||||
public boolean isOnSaveError() {
|
||||
return onSaveError;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue