empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1378527 - /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java
Date Wed, 29 Aug 2012 12:49:46 GMT
Author: doebele
Date: Wed Aug 29 12:49:46 2012
New Revision: 1378527

URL: http://svn.apache.org/viewvc?rev=1378527&view=rev
Log:
EMPIREDB-157 
JSF2 provide simple access to static list page items

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java?rev=1378527&r1=1378526&r2=1378527&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/StaticListPageElement.java
Wed Aug 29 12:49:46 2012
@@ -58,7 +58,59 @@ public class StaticListPageElement<T> ex
     {
         clearItems();
         this.items = items;
-        getTableInfo().init(items.size(), 0);
+        update();
+    }
+    
+    public int size()
+    {
+        return (items!=null ? items.size() : 0);
+    }
+    
+    public boolean contains(T item)
+    {
+        return (items!=null ? items.contains(item) : false);
+    }
+    
+    public boolean add(T item)
+    {
+        if (items==null || items.contains(item))
+            return false;
+        // remove
+        boolean added = items.add(item);
+        if (added)
+            update();
+        return added;
+    }
+    
+    public boolean add(T item, int index)
+    {
+        if (items==null || items.contains(item))
+            return false;
+        // remove
+        items.add(index, item);
+        update();
+        return true;
+    }
+    
+    public boolean move(T item, int index)
+    {
+        if (items==null || !items.contains(item))
+            return false;
+        // remove
+        items.add(index, item);
+        update();
+        return true;
+    }
+    
+    public boolean remove(T item)
+    {
+        if (items==null)
+            return false;
+        // remove
+        boolean removed = items.remove(item);
+        if (removed)
+            update();
+        return removed;
     }
     
     public void update()



Mime
View raw message