⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.java

📁 非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应用程序更漂亮更易操作。 官网:www.zkoss.org
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 * Note: it cannot be "modal". Use {@link #doModal} instead.	 */	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)) 	doModal();		else throw new WrongValueException("Uknown mode: "+name);	}	/** Returns whether this is a modal dialog.	 */	public boolean inModal() {		return _mode == MODAL;	}	/** Returns whether this is embedded with other components (Default).	 * @see #doEmbedded	 */	public boolean inEmbedded() {		return _mode == EMBEDDED;	}	/** Returns whether this is a overlapped window.	 */	public boolean inOverlapped() {		return _mode == OVERLAPPED;	}	/** Returns whether this is a popup window.	 */	public boolean inPopup() {		return _mode == POPUP;	}	/** Makes this window as a modal dialog.	 * It will automatically center the window (ignoring {@link #getLeft} and	 * {@link #getTop}).	 *	 * <p>Notice that this method can be called only in an event listener	 * ({@link Events#inEventListener}).	 * Rather, you shall use {@link org.zkoss.zk.ui.event.Events#postEvent} to	 * post the onModal event.	 * Refer to {@link #setMode} for more description.	 */	public void doModal() throws InterruptedException {		checkOverlappable();		if (!Events.inEventListener())			throw new WrongValueException("doModal() and setMode(\"modal\") can only be called in an event listener, not in page loading");		if (_mode != MODAL || !_moding) {			endModing();			if (_mode != MODAL) {				_mode = MODAL;				invalidate();			}			response("doModal", new AuDoModal(this));			_moding = true;			setVisible(true); //after _molding = true to avoid dead-loop			//no need to synchronized (_mutex) because no racing is possible			Executions.wait(_mutex);		}	}	/** Makes this window as overlapped with other components.	 */	public void doOverlapped() {		checkOverlappable();		if (_mode != OVERLAPPED || !_moding) {			endModing();			if (_mode != OVERLAPPED) {				_mode = OVERLAPPED;				invalidate();			}			response("doOverlapped", new AuDoOverlapped(this));			_moding = true;			setVisible(true); //after _molding = true to avoid dead-loop		}	}	/** Makes this window as popup, which is overlapped with other component	 * and auto-hiden when user clicks outside of the window.	 */	public void doPopup() {		checkOverlappable();		if (_mode != POPUP || !_moding) {			endModing();			if (_mode != POPUP) {				_mode = POPUP;				invalidate();			}			response("doPopup", new AuDoPopup(this));			_moding = true;			setVisible(true); //after _molding = true to avoid dead-loop		}	}	/** Makes this window as embeded with other components (Default).	 */	public void doEmbedded() {		if (_mode != EMBEDDED) {			endModing();			_mode = EMBEDDED;			invalidate();		}		setVisible(true);	}	/** Makes sure it is not draggable. */	private void checkOverlappable() {		if (!"false".equals(getDraggable()))			throw new UiException("Draggable window cannot be modal, overlapped or popup: "+this);		for (Component comp = this; (comp = comp.getParent()) != null;)			if (!comp.isVisible())				throw new UiException("One of its ancestors, "+comp+", is not visible, so unable to be modal, overlapped or popup");	}	/** Returns whether to show a close button on the title bar.	 */	public boolean isClosable() {		return _closable;	}	/** Sets whether to show a close button on the title bar.	 * If closable, a button is displayed and the onClose event is sent	 * if an user clicks the button.	 *	 * <p>Default: false.	 *	 * <p>You can intercept the default behavior by either overriding	 * {@link #onClose}, or listening the onClose event.	 *	 * <p>Note: the close button won't be displayed if no title or caption at all.	 */	public void setClosable(boolean closable) {		if (_closable != closable) {			_closable = closable;			invalidate(); //re-init is required		}	}	/** Returns whether the width of the child column is sizable.	 */	public boolean isSizable() {		return _sizable;	}	/** Sets whether the width of the child column is sizable.	 * If true, an user can drag the border between two columns (e.g., {@link org.zkoss.zul.Column})	 * to change the widths of adjacent columns.	 * <p>Default: false.	 */	public void setSizable(boolean sizable) {		if (_sizable != sizable) {			_sizable = sizable;			smartUpdate("z.sizable", sizable);		}	}	/** Process the onClose event sent when the close button is pressed.	 * <p>Default: detach itself.	 */	public void onClose() {		detach();	}	/** Process the onModal event by making itself a modal window.	 */	public void onModal() throws InterruptedException {		doModal();	}	/** Ends the modal mode. */	private void endModing() {		if (_moding) {			assert D.OFF || _mode != EMBEDDED;			if (_mode == MODAL)				Executions.notifyAll(_mutex);			if (_mode == MODAL)				response(null, new AuEndModal(this));			else if (_mode == POPUP)				response(null, new AuEndPopup(this));			else				response(null, new AuEndOverlapped(this));			_moding = false;		}	}	//-- super --//	/** Returns the style class.	 * If the style class is not defined ({@link #setSclass} is not called	 * or called with null or empty), it returns the style class based	 * on {@link #getMode} and {@link #getBorder}.	 */	public String getSclass() {		final String scls = super.getSclass();		if (scls != null) return scls;		return "normal".equals(getBorder()) ?			getMode(): getMode() + '-' + getBorder();	}	//-- Component --//	public boolean insertBefore(Component child, Component insertBefore) {		if (child instanceof Caption) {			if (_caption != null && _caption != child)				throw new UiException("Only one caption is allowed: "+this);			if (!getChildren().isEmpty())				insertBefore = (Component)getChildren().get(0);				//always makes caption as the first child			_caption = (Caption)child;			invalidate();		} else if (insertBefore instanceof Caption) {			throw new UiException("caption must be the first child");		}		return super.insertBefore(child, insertBefore);	}	public void onChildRemoved(Component child) {		if (child instanceof Caption) {			_caption = null;			invalidate();		}		super.onChildRemoved(child);	}	public void setPage(Page page) {		final Page old = getPage();		super.setPage(page);		if (old != page && (old == null || page == null))			fixMode(page != null);	}	public void setParent(Component parent) {		final Component old = getParent();		super.setParent(parent);		if (old != parent && (old == null || parent == null))			fixMode(parent != null);	}	private void fixMode(boolean attached) {		if (attached) {			switch (_mode) {			case OVERLAPPED: doOverlapped();			case POPUP: doPopup();			}		} else {			endModing();			if (_mode == MODAL) _mode = EMBEDDED;		}	}	/** If it becomes invisible, the modal mode ends automatically.	 */	public boolean setVisible(boolean visible) {		if (!visible) endModing();		final boolean ret = super.setVisible(visible);		if (!ret && visible && !_moding)			switch (_mode) {			case MODAL:				try {					doModal(); return false;				} catch (InterruptedException ex) {					throw UiException.Aide.wrap(ex);				}			case POPUP:				doPopup();				return false;			case OVERLAPPED:				doOverlapped();				return false;			}		return ret;	}	//-- super --//	public void setDraggable(String draggable) {		if (_mode != EMBEDDED) {			if (draggable != null			&& (draggable.length() > 0 && !"false".equals(draggable)))				throw new UiException("Only embedded window could be draggable: "+this);		}		super.setDraggable(draggable);	}	public String getOuterAttrs() {		final StringBuffer sb =			new StringBuffer(64).append(super.getOuterAttrs());		appendAsapAttr(sb, Events.ON_MOVE);		appendAsapAttr(sb, Events.ON_SIZE);		appendAsapAttr(sb, Events.ON_Z_INDEX);		appendAsapAttr(sb, Events.ON_OK);		appendAsapAttr(sb, Events.ON_CANCEL);		appendAsapAttr(sb, Events.ON_CTRL_KEY);		final String clkattrs = getAllOnClickAttrs(false);		if (clkattrs != null) sb.append(clkattrs);			//though widget.js handles onclick (if 3d), it is useful			//to support onClick for groupbox		if (_closable)			sb.append(" z.closable=\"true\"");		if (_sizable)			sb.append(" z.sizable=\"true\"");		HTMLs.appendAttribute(sb, "z.ctkeys", _ctkeys);		return sb.toString();	}	//Cloneable//	public Object clone() {		final Window clone = (Window)super.clone();		clone.init();		if (clone._caption != null) clone.afterUnmarshal();		return clone;	}	private void afterUnmarshal() {		for (Iterator it = getChildren().iterator(); it.hasNext();) {			final Object child = it.next();			if (child instanceof Caption) {				_caption = (Caption)child;				break;			}		}	}	//Serializable//	private synchronized void readObject(java.io.ObjectInputStream s)	throws java.io.IOException, ClassNotFoundException {		s.defaultReadObject();		init();		afterUnmarshal();	}	//-- ComponentCtrl --//	protected Object newExtraCtrl() {		return new ExtraCtrl();	}	/** A utility class to implement {@link #getExtraCtrl}.	 * It is used only by component developers.	 */	protected class ExtraCtrl extends XulElement.ExtraCtrl implements MultiBranch {		//-- MultiBranch --//		public boolean inDifferentBranch(Component child) {			return child instanceof Caption; //in different branch		}	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -