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>() {
|
ld.addEventListener(Events.ON_OPEN, new EventListener<OpenEvent>() {
|
||||||
@Override
|
@Override
|
||||||
public void onEvent(OpenEvent event) throws Exception {
|
public void onEvent(OpenEvent event) throws Exception {
|
||||||
if (!event.isOpen()) {
|
if (!event.isOpen() && !ld.isOnSaveError()) {
|
||||||
ld.detach();
|
ld.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,11 @@ public class FDialog
|
||||||
error(windowNo, null, adMessage, msg);
|
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.
|
* Display error with error icon.
|
||||||
*
|
*
|
||||||
|
@ -206,13 +211,14 @@ public class FDialog
|
||||||
* @param comp Component (unused)
|
* @param comp Component (unused)
|
||||||
* @param adMessage Message to be translated
|
* @param adMessage Message to be translated
|
||||||
* @param message Additional message
|
* @param message Additional message
|
||||||
|
* @param callback
|
||||||
*
|
*
|
||||||
* @see #error(int, String)
|
* @see #error(int, String)
|
||||||
* @see #error(int, Component, String)
|
* @see #error(int, Component, String)
|
||||||
* @see #error(int, String, 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();
|
Properties ctx = Env.getCtx();
|
||||||
StringBuffer out = new StringBuffer();
|
StringBuffer out = new StringBuffer();
|
||||||
|
@ -227,7 +233,7 @@ public class FDialog
|
||||||
out = constructMessage(adMessage, message);
|
out = constructMessage(adMessage, message);
|
||||||
|
|
||||||
String s = out.toString().replace("\n", "<br>");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.util.Callback;
|
||||||
import org.adempiere.webui.LayoutUtils;
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
import org.adempiere.webui.component.Column;
|
import org.adempiere.webui.component.Column;
|
||||||
|
@ -137,6 +138,7 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
private Button toLink;
|
private Button toLink;
|
||||||
private Button toRoute;
|
private Button toRoute;
|
||||||
private GridField m_GridField = null;
|
private GridField m_GridField = null;
|
||||||
|
private boolean onSaveError = false;
|
||||||
//END
|
//END
|
||||||
|
|
||||||
public WLocationDialog(String title, MLocation location)
|
public WLocationDialog(String title, MLocation location)
|
||||||
|
@ -353,6 +355,8 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
southPane.setSclass("dialog-footer");
|
southPane.setSclass("dialog-footer");
|
||||||
borderlayout.appendChild(southPane);
|
borderlayout.appendChild(southPane);
|
||||||
southPane.appendChild(confirmPanel);
|
southPane.appendChild(confirmPanel);
|
||||||
|
|
||||||
|
addEventListener("onSaveError", this);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Dynamically add fields to the Location dialog box
|
* 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))
|
if (event.getTarget() == confirmPanel.getButton(ConfirmPanel.A_OK))
|
||||||
{
|
{
|
||||||
|
onSaveError = false;
|
||||||
|
|
||||||
inOKAction = true;
|
inOKAction = true;
|
||||||
|
|
||||||
if (m_location.getCountry().isHasRegion() && lstRegion.getSelectedItem() == null) {
|
if (m_location.getCountry().isHasRegion() && lstRegion.getSelectedItem() == null) {
|
||||||
|
@ -553,7 +559,13 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
|
|
||||||
String msg = validate_OK();
|
String msg = validate_OK();
|
||||||
if (msg != null) {
|
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;
|
inOKAction = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -566,7 +578,13 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
}
|
}
|
||||||
else
|
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;
|
inOKAction = false;
|
||||||
}
|
}
|
||||||
|
@ -633,6 +651,11 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
initLocation();
|
initLocation();
|
||||||
lstRegion.focus();
|
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;
|
return success;
|
||||||
} // actionOK
|
} // actionOK
|
||||||
|
|
||||||
|
public boolean isOnSaveError() {
|
||||||
|
return onSaveError;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
|
@ -759,5 +786,5 @@ public class WLocationDialog extends Window implements EventListener<Event>
|
||||||
|
|
||||||
address = address + (c.getName() != null ? c.getName() : "");
|
address = address + (c.getName() != null ? c.getName() : "");
|
||||||
return address.replace(" ", "+");
|
return address.replace(" ", "+");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue