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

📄 rows.java

📁 非常接近C/S操作方式的Java Ajax框架-ZK 用ZK框架使你的B/S应用程序更漂亮更易操作。 官网:www.zkoss.org
💻 JAVA
字号:
/* Rows.java{{IS_NOTE	Purpose:			Description:			History:		Tue Oct 25 16:02:39     2005, Created by tomyeh}}IS_NOTECopyright (C) 2005 Potix Corporation. All Rights Reserved.{{IS_RIGHT	This program is distributed under GPL Version 2.0 in the hope that	it will be useful, but WITHOUT ANY WARRANTY.}}IS_RIGHT*/package org.zkoss.zul;import java.util.Set;import java.util.HashSet;import java.util.Iterator;import org.zkoss.zk.ui.Component;import org.zkoss.zk.ui.UiException;import org.zkoss.zk.ui.ext.render.Cropper;import org.zkoss.zul.impl.XulElement;import org.zkoss.zul.ext.Paginal;/** * Defines the rows of a grid. * Each child of a rows element should be a {@link Row} element. * * @author tomyeh */public class Rows extends XulElement {	/** Returns the grid that contains this rows. */	public Grid getGrid() {		return (Grid)getParent();	}	//Paging//	/** Returns the index of the first visible child.	 * <p>Used only for component development, not for application developers.	 */	public int getVisibleBegin() {		final Grid grid = getGrid();		if (grid == null || !grid.inPagingMold())			return 0;		final Paginal pgi = grid.getPaginal();		return pgi.getActivePage() * pgi.getPageSize();	}	/** Returns the index of the last visible child.	 * <p>Used only for component development, not for application developers.	 */	public int getVisibleEnd() {		final Grid grid = getGrid();		if (grid == null || !grid.inPagingMold())			return Integer.MAX_VALUE;		final Paginal pgi = grid.getPaginal();		return (pgi.getActivePage() + 1) * pgi.getPageSize() - 1; //inclusive	}	//-- Component --//	public void setParent(Component parent) {		if (parent != null && !(parent instanceof Grid))			throw new UiException("Unsupported parent for rows: "+parent);		final boolean changed = getParent() != parent;		super.setParent(parent);		if (changed && parent != null) ((Grid)parent).initAtClient();	}	public boolean insertBefore(Component child, Component insertBefore) {		if (!(child instanceof Row))			throw new UiException("Unsupported child for rows: "+child);		return super.insertBefore(child, insertBefore);	}	public void onChildAdded(Component child) {		super.onChildAdded(child);		final Grid grid = getGrid();		if (grid != null) {			grid.initAtClient();			if (grid.inPagingMold())				grid.getPaginal().setTotalSize(getChildren().size());		}	}	public void onChildRemoved(Component child) {		super.onChildRemoved(child);		final Grid grid = getGrid();		if (grid != null) {			grid.initAtClient();			if (grid.inPagingMold())				grid.getPaginal().setTotalSize(getChildren().size());		}    }	//-- 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 Cropper {		//--Cropper--//		public boolean isCropper() {			final Grid grid = getGrid();			return grid != null && grid.inPagingMold();		}		public Set getAvailableAtClient() {			final Grid grid = getGrid();			if (grid == null || !grid.inPagingMold())				return null;			final Set avail = new HashSet(37);			final Paginal pgi = grid.getPaginal();			int pgsz = pgi.getPageSize();			final int ofs = pgi.getActivePage() * pgsz;			for (final Iterator it = getChildren().listIterator(ofs);			--pgsz >= 0 && it.hasNext();)				avail.add(it.next());			return avail;		}	}}

⌨️ 快捷键说明

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