IDEMPIERE-4702 Messagebox enhancement: Esc key closes Dialog with cancel (#586)

action

Co-authored-by: Andreas <sumerauer@kanzlei-wmv.de>
This commit is contained in:
Andreas Sumerauer 2021-02-16 01:41:41 +01:00 committed by GitHub
parent ff88459dc9
commit 6acc8e235d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 5 deletions

View File

@ -38,6 +38,7 @@ import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
import org.zkoss.zul.Image; import org.zkoss.zul.Image;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
@ -47,6 +48,7 @@ import org.zkoss.zul.Vbox;
* *
* @author Niraj Sohun * @author Niraj Sohun
* @date Jul 31, 2007 * @date Jul 31, 2007
* @contributor Andreas Sumerauer IDEMPIERE-4702
*/ */
public class Messagebox extends Window implements EventListener<Event> public class Messagebox extends Window implements EventListener<Event>
@ -55,7 +57,7 @@ public class Messagebox extends Window implements EventListener<Event>
* *
*/ */
private static final long serialVersionUID = 8928526331932742124L; private static final long serialVersionUID = 8928526331932742124L;
private static final String MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 350pt; min-width: 230pt; max-width: 450pt;"; private static final String MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 350pt; min-width: 230pt; max-width: 450pt;";
private static final String SMALLER_MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 350pt; min-width: 180pt; "; private static final String SMALLER_MESSAGE_PANEL_STYLE = "text-align:left; word-break: break-all; overflow: auto; max-height: 350pt; min-width: 180pt; ";
private String msg = new String(""); private String msg = new String("");
@ -107,7 +109,7 @@ public class Messagebox extends Window implements EventListener<Event>
public static final String QUESTION = "~./zul/img/msgbox/question-btn.png"; public static final String QUESTION = "~./zul/img/msgbox/question-btn.png";
/** A symbol consisting of an exclamation point in a triangle with a yellow background. */ /** A symbol consisting of an exclamation point in a triangle with a yellow background. */
public static final String EXCLAMATION = "~./zul/img/msgbox/warning-btn.png"; public static final String EXCLAMATION = "~./zul/img/msgbox/warning-btn.png";
/** A symbol of a lowercase letter i in a circle. */ /** A symbol of a lowercase letter i in a circle. */
public static final String INFORMATION = "~./zul/img/msgbox/info-btn.png"; public static final String INFORMATION = "~./zul/img/msgbox/info-btn.png";
@ -353,6 +355,15 @@ public class Messagebox extends Window implements EventListener<Event>
Messagebox msg = new Messagebox(); Messagebox msg = new Messagebox();
return msg.show(message, title, buttons, icon, editor, callback, modal); return msg.show(message, title, buttons, icon, editor, callback, modal);
} }
// Andreas Sumerauer IDEMPIERE 4702
@Listen("onCancel")
public void onCancel() throws Exception
{
returnValue = CANCEL;
close();
}
public void onEvent(Event event) throws Exception public void onEvent(Event event) throws Exception
{ {
@ -387,15 +398,18 @@ public class Messagebox extends Window implements EventListener<Event>
{ {
returnValue = IGNORE; returnValue = IGNORE;
} }
close();
}
private void close() {
try { try {
this.detach(); this.detach();
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
if (! (SessionManager.getSessionApplication() == null)) // IDEMPIERE-1937 - ignore when session was closed if (! (SessionManager.getSessionApplication() == null)) // IDEMPIERE-1937 - ignore when session was closed
throw npe; throw npe;
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void onPageDetached(Page page) { public void onPageDetached(Page page) {