Author: heiko.braun(a)jboss.com
Date: 2009-09-18 06:14:03 -0400 (Fri, 18 Sep 2009)
New Revision: 841
Added:
bpm-console/branches/hbraun/gui/war/src/main/java/org/jboss/bpm/console/client/common/PageFilter.java
Log:
Missing class
Added:
bpm-console/branches/hbraun/gui/war/src/main/java/org/jboss/bpm/console/client/common/PageFilter.java
===================================================================
---
bpm-console/branches/hbraun/gui/war/src/main/java/org/jboss/bpm/console/client/common/PageFilter.java
(rev 0)
+++
bpm-console/branches/hbraun/gui/war/src/main/java/org/jboss/bpm/console/client/common/PageFilter.java 2009-09-18
10:14:03 UTC (rev 841)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.bpm.console.client.common;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public final class PageFilter
+{
+ public final static int DEFAULT_PAGE_SIZE = 20;
+
+ public final static String SUSPENDED = "suspended";
+
+ private int fromIndex = 0;
+ private int pageSize = DEFAULT_PAGE_SIZE;
+
+ private boolean outOfBounds;
+
+ private List<String> appliedFilter = new ArrayList<String>();
+
+ public boolean applies(String filter)
+ {
+ return appliedFilter.contains(filter);
+ }
+
+ public void remove(String filter)
+ {
+ appliedFilter.remove(filter);
+ }
+
+ public void add(String filter)
+ {
+ appliedFilter.add(filter);
+ }
+
+ public void clear()
+ {
+ appliedFilter.clear();
+ }
+
+ public boolean isEmpty()
+ {
+ return appliedFilter.isEmpty();
+ }
+
+ public void rev()
+ {
+ int nextIndex = (fromIndex-pageSize)>0 ? fromIndex-pageSize : 0;
+ fromIndex = nextIndex;
+ outOfBounds = false;
+ }
+
+ public void ffw()
+ {
+ int nextIndex = outOfBounds ? fromIndex : fromIndex+pageSize;
+ fromIndex = nextIndex;
+ }
+
+ public void records(int currentNumRecords)
+ {
+ if(currentNumRecords<pageSize)
+ outOfBounds = true;
+ }
+
+ public int getFromIndex()
+ {
+ return fromIndex;
+ }
+
+ public int getPageSize()
+ {
+ return pageSize;
+ }
+}