Author: tchemit Date: 2008-01-20 12:21:05 +0000 (Sun, 20 Jan 2008) New Revision: 246 Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/beans/ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/beans/PaginationBean.java Log: le bean de pagination (peut-?\195?\170tre il va s'appeler QueryBean ?) avec en plus les informations de recherche ... Added: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/beans/PaginationBean.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/beans/PaginationBean.java (rev 0) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/beans/PaginationBean.java 2008-01-20 12:21:05 UTC (rev 246) @@ -0,0 +1,84 @@ +/* +* \#\#% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* \#\#% */ +package fr.cemagref.simexplorer.is.ui.swing.beans; + +/** + * Le modèle de pagination d'une liste + * + * @author tony + */ +public class PaginationBean { + + /** the index */ + long firstIndex; + + /** size of the total flow */ + long size; + + /** size of a page */ + int width; + + public long getFirstIndex() { + return firstIndex; + } + + public long getSize() { + return size; + } + + public int getWidth() { + return width; + } + + public boolean hasNext() { + return size - firstIndex > width; + } + + public boolean hasPrevious() { + return firstIndex >= width; + } + + public int getCurrentPage() { + int page = (int) (firstIndex / width); + if (page > 0 && firstIndex % width > 0) { + page++; + } + return page; + } + + public int getNbPages() { + return (int) (size % width); + } + + public void increment() { + if (firstIndex + width > size) { + firstIndex = size - width; + return; + } + firstIndex += width; + } + + public void decrement() { + if (firstIndex < width) { + firstIndex = 0; + } else { + firstIndex -= width; + } + } +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org