001: /* PagingEvent.java
002:
003: {{IS_NOTE
004: Purpose:
005:
006: Description:
007:
008: History:
009: Thu Aug 17 16:18:13 2006, Created by tomyeh
010: }}IS_NOTE
011:
012: Copyright (C) 2006 Potix Corporation. All Rights Reserved.
013:
014: {{IS_RIGHT
015: }}IS_RIGHT
016: */
017: package org.zkoss.zul.event;
018:
019: import org.zkoss.zk.ui.Component;
020: import org.zkoss.zk.ui.event.Event;
021:
022: import org.zkoss.zul.ext.Pageable;
023: import org.zkoss.zul.ext.Paginal;
024:
025: /**
026: * Used to notify that a new page is selected by the user, or by
027: * {@link Paginal} (such as {@link org.zkoss.zul.Paging}).
028: * It is used for paging long content.
029: *
030: * @author tomyeh
031: */
032: public class PagingEvent extends Event {
033: private final Pageable _pgi;
034: private final int _actpg;
035:
036: /** Construct a paging event.
037: *
038: * @param target the target must be a paginal component, i.e.,
039: * implements {@link Pageable}.
040: * @param actpg the active page
041: */
042: public PagingEvent(String name, Component target, int actpg) {
043: super (name, target);
044: _pgi = (Pageable) target;
045: _actpg = actpg;
046: }
047:
048: /** Construct a paging event that the target is different
049: * from the page controller.
050: *
051: * @param target the event target
052: * @param pageable the paging controller. In other words,
053: * it is usually {@link Paginal}.
054: */
055: public PagingEvent(String name, Component target,
056: Pageable pageable, int actpg) {
057: super (name, target);
058: _pgi = pageable;
059: _actpg = actpg;
060: }
061:
062: /** Construct a paging event that the target is different
063: * from the page controller.
064: *
065: * @param target the event target
066: * @param paginal the paging controller.
067: * @deprecated As of release 2.4.1, replaced by {@link #PagingEvent(String,Component,Paginal,int)}
068: */
069: public PagingEvent(String name, Component target, Paginal paginal,
070: int actpg) {
071: super (name, target);
072: _pgi = paginal;
073: _actpg = actpg;
074: }
075:
076: /** Returns the pageable controller.
077: * @since 2.4.1
078: */
079: public Pageable getPageable() {
080: return _pgi;
081: }
082:
083: /** Returns the paginal controller.
084: *
085: * @deprecated As of release 2.4.1, replaced by {@link #getPageable}
086: */
087: public Paginal getPaginal() {
088: return _pgi instanceof Paginal ? (Paginal) _pgi : null;
089: }
090:
091: /** Returns the active page (starting from 0).
092: * <p>It is the same as {@link #getPageable}'s {@link Pageable#getActivePage}.
093: *
094: * <p>To get the index of the first visible item, use<br/>
095: * <code>{@link #getActivePage} * {@link Pageable#getPageSize}</code>.
096: */
097: public int getActivePage() {
098: return _actpg;
099: }
100: }
|