/** * Sets the mode to overlapped, popup, modal, embedded or highlighted. * * <p>Notice: {@link Events#ON_MODAL} is posted if you specify "modal" to this method. Unlike * {@link #doModal}, {@link Events#ON_MODAL} is posted, so the window will become modal later * (since 3.0.4). In other words, setMode("modal") never suspends the execution of the current * thread. On the other hand, {@link #doModal} will suspends the execution if executed in an event * listener, or throws an exception if <em>not</em> executed in an event listener. * * <p>Refer to <a * href="http://books.zkoss.org/wiki/ZK_Component_Reference/Containers/Window">Overlapped, Popup, * Modal, Highlighted and Embedded</a> for more information. * * <p>If the event processing thread is disabled (it is the default), InterruptedException won't * be thrown. * * @param name the mode which could be one of "embedded", "overlapped", "popup", "modal", * "highlighted". Note: it cannot be "modal". Use {@link #doModal} instead. * @exception InterruptedException thrown if "modal" is specified the event thread is enabled * (disabled by default), and one of the following conditions occurs: 1) the desktop or the * Web application is being destroyed, or 2) {@link * org.zkoss.zk.ui.sys.DesktopCtrl#ceaseSuspendedThread}. To tell the difference, check the * getMessage method of InterruptedException. */ public void setMode(String name) throws InterruptedException { if ("popup".equals(name)) doPopup(); else if ("overlapped".equals(name)) doOverlapped(); else if ("embedded".equals(name)) doEmbedded(); else if ("modal".equals(name)) { if (isEventThreadEnabled(false)) Events.postEvent(Events.ON_MODAL, this, null); else doModal(); } else if ("highlighted".equals(name)) doHighlighted(); else throw new WrongValueException("Unknown mode: " + name); }
/** * Sets the mode to overlapped, popup, modal, embedded or highlighted. * * @see #setMode(String) */ public void setMode(int mode) throws InterruptedException { switch (mode) { case POPUP: doPopup(); break; case OVERLAPPED: doOverlapped(); break; case EMBEDDED: doEmbedded(); break; case MODAL: if (isEventThreadEnabled(false)) Events.postEvent(Events.ON_MODAL, this, null); else doModal(); break; case HIGHLIGHTED: doHighlighted(); break; default: throw new WrongValueException("Unknown mode: " + mode); } }