001: /* Messagebox.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Thu Nov 24 15:09:25 2005, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: This program is distributed under GPL Version 2.0 in the hope that
016: it will be useful, but WITHOUT ANY WARRANTY.
017: }}IS_RIGHT
018: */
019: package org.zkoss.zhtml;
020:
021: import org.zkoss.mesg.Messages;
022: import org.zkoss.zk.ui.WebApp;
023: import org.zkoss.zk.ui.UiException;
024:
025: /**
026: * Represents the message box.
027: *
028: * <p>You don't create {@link Messagebox} directly. Rather, use {@link #show}.
029: *
030: * <p>A non-XHTML extension.
031: *
032: * @author tomyeh
033: */
034: public class Messagebox {
035: /** A symbol consisting of a question mark in a circle. */
036: public static final String QUESTION = org.zkoss.zul.Messagebox.QUESTION;
037: /** A symbol consisting of an exclamation point in a triangle with
038: * a yellow background.
039: */
040: public static final String EXCLAMATION = org.zkoss.zul.Messagebox.EXCLAMATION;
041: /** The same as {@link #EXCLAMATION}.
042: */
043: public static final String INFORMATION = EXCLAMATION;
044: /** A symbol consisting of a white X in a circle with a red background. */
045: public static final String ERROR = org.zkoss.zul.Messagebox.ERROR;
046: /** Contains no symbols. */
047: public static final String NONE = null;
048:
049: /** A OK button. */
050: public static final int OK = org.zkoss.zul.Messagebox.OK;
051: /** A Cancel button. */
052: public static final int CANCEL = org.zkoss.zul.Messagebox.CANCEL;
053: /** A Yes button. */
054: public static final int YES = org.zkoss.zul.Messagebox.YES;
055: /** A No button. */
056: public static final int NO = org.zkoss.zul.Messagebox.NO;
057: /** A Abort button. */
058: public static final int ABORT = org.zkoss.zul.Messagebox.ABORT;
059: /** A Retry button. */
060: public static final int RETRY = org.zkoss.zul.Messagebox.RETRY;
061: /** A IGNORE button. */
062: public static final int IGNORE = org.zkoss.zul.Messagebox.IGNORE;
063:
064: /** Shows a message box and returns what button is pressed.
065: *
066: * @param title the title. If null, {@link WebApp#getAppName} is used.
067: * @param buttons a combination of {@link #OK}, {@link #CANCEL},
068: * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
069: * and {@link #IGNORE}. If zero, {@link #OK} is assumed
070: * @param icon one of predefined images: {@link #QUESTION},
071: * {@link #EXCLAMATION}, {@link #ERROR}, {@link #NONE}, or any URI of
072: * an image.
073: * @return the button being pressed (one of {@link #OK}, {@link #CANCEL},
074: * {@link #YES}, {@link #NO}, {@link #ABORT}, {@link #RETRY},
075: * and {@link #IGNORE}).
076: */
077: public static final int show(String message, String title,
078: int buttons, String icon) throws InterruptedException {
079: return org.zkoss.zul.Messagebox.show(message, title, buttons,
080: icon);
081: }
082:
083: /** Shows a message box and returns what button is pressed.
084: * A shortcut to show(message, null, OK, INFORMATION).
085: */
086: public static final int show(String message)
087: throws InterruptedException {
088: return show(message, null, OK, INFORMATION);
089: }
090:
091: /** Shows a message box by specifying a message code, and returns what
092: * button is pressed.
093: *
094: * @param titleCode the message code for the title. If non-positive,
095: * the default title is used.
096: */
097: public static final int show(int messageCode, Object[] args,
098: int titleCode, int button, String icon)
099: throws InterruptedException {
100: return show(Messages.get(messageCode, args),
101: titleCode > 0 ? Messages.get(titleCode) : null, button,
102: icon);
103: }
104:
105: /** Shows a message box by specifying a message code, and returns what
106: * button is pressed.
107: *
108: * @param titleCode the message code for the title. If non-positive,
109: * the default title is used.
110: */
111: public static final int show(int messageCode, Object arg,
112: int titleCode, int button, String icon)
113: throws InterruptedException {
114: return show(Messages.get(messageCode, arg),
115: titleCode > 0 ? Messages.get(titleCode) : null, button,
116: icon);
117: }
118:
119: /** Shows a message box by specifying a message code, and returns what
120: * button is pressed.
121: *
122: * @param titleCode the message code for the title. If non-positive,
123: * the default title is used.
124: */
125: public static final int show(int messageCode, int titleCode,
126: int button, String icon) throws InterruptedException {
127: return show(Messages.get(messageCode), titleCode > 0 ? Messages
128: .get(titleCode) : null, button, icon);
129: }
130: }
|