[richfaces-svn-commits] JBoss Rich Faces SVN: r5402 - in branches/3.1.x: ui/listShuttle/src/main/java/org/richfaces/model and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jan 15 19:45:18 EST 2008


Author: nbelaevski
Date: 2008-01-15 19:45:18 -0500 (Tue, 15 Jan 2008)
New Revision: 5402

Added:
   branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
   branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
   branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
Removed:
   branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
   branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
   branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
Log:
http://jira.jboss.com/jira/browse/RF-1855
http://jira.jboss.com/jira/browse/RF-1856

Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java	                        (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,151 @@
+/**
+ * 
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceDataModel;
+
+/**
+ * Dual map-based extended data model for model-translating components like list shuttle
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleDataModel extends ExtendedDataModel {
+
+	private ListShuttleRowKey rowKey;
+
+	private SequenceDataModel sourceModel;
+	private SequenceDataModel targetModel;
+
+	private Map data;
+
+	private Object wrappedData;
+	
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+	 */
+	public Object getRowKey() {
+		return rowKey;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+	 */
+	public void setRowKey(Object key) {
+		this.rowKey = (ListShuttleRowKey) key;
+	}
+
+	public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
+			final Object argument) throws IOException {
+		if (data != null) {
+			Iterator iterator = data.entrySet().iterator();
+			
+			while (iterator.hasNext()) {
+				Entry entry =(Map.Entry) iterator.next();
+				
+				visitor.process(context, entry.getKey(), argument);
+			}
+			
+		} else {
+			sourceModel.walk(context, new DataVisitor() {
+
+				public void process(FacesContext context, Object rowKey,
+						Object argument) throws IOException {
+
+					ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
+					visitor.process(context, key, argument);
+				}
+			}, range, argument);
+
+			targetModel.walk(context, new DataVisitor() {
+
+				public void process(FacesContext context, Object rowKey,
+						Object argument) throws IOException {
+
+					ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
+					visitor.process(context, key, argument);
+				}
+				
+			}, range, argument);
+		}
+	}
+
+	public int getRowCount() {
+		if (data != null) {
+			return data.size();
+		} else {
+			return sourceModel.getRowCount() + targetModel.getRowCount();
+		}
+	}
+
+	public Object getRowData() {
+		if (data != null) {
+			return data.get(rowKey);
+		} else {
+			if (this.rowKey != null) {
+				if (this.rowKey.isSource()) {
+					return sourceModel.getRowData();
+				} else {
+					return targetModel.getRowData();
+				}
+			} else {
+				return null;
+			}
+		}
+	}
+
+	public int getRowIndex() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public Object getWrappedData() {
+		return wrappedData;
+	}
+
+	public boolean isRowAvailable() {
+		if (data != null) {
+			return data.containsKey(rowKey);
+		} else {
+			if (rowKey != null) {
+				if (rowKey.isSource()) {
+					return sourceModel.isRowAvailable();
+				} else {
+					return targetModel.isRowAvailable();
+				}
+			} else {
+				return false;
+			}
+		}
+	}
+
+	public void setRowIndex(int rowIndex) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void setWrappedData(Object data) {
+		this.rowKey = null;
+		this.wrappedData = data;
+		
+		if (data instanceof Map) {
+			this.data = (Map) data;
+		} else {
+			DataModel[] models = (DataModel[]) data;
+			this.sourceModel = new SequenceDataModel(models[0]);
+			this.targetModel = new SequenceDataModel(models[1]);
+		}
+	}
+
+}

Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java	                        (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,82 @@
+/**
+ * 
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * Special type of row key containing information on item origin and new placement
+ * 
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleRowKey implements Serializable {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3308741255288495879L;
+	
+	private boolean source;
+	
+	private boolean facadeSource;
+	
+	private Object rowKey;
+
+	public boolean isSource() {
+		return source;
+	}
+	
+	public boolean isFacadeSource() {
+		return facadeSource;
+	}
+	
+	public Object getRowKey() {
+		return rowKey;
+	}
+
+	public int hashCode() {
+		final int prime = 31;
+		int result = 1;
+		result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
+		result = prime * result + (source ? 1231 : 1237);
+		return result;
+	}
+
+	public boolean equals(Object obj) {
+		if (this == obj)
+			return true;
+		if (obj == null)
+			return false;
+		if (getClass() != obj.getClass())
+			return false;
+		ListShuttleRowKey other = (ListShuttleRowKey) obj;
+		if (rowKey == null) {
+			if (other.rowKey != null)
+				return false;
+		} else if (!rowKey.equals(other.rowKey))
+			return false;
+		if (source != other.source)
+			return false;
+		return true;
+	}
+	
+	public String toString() {
+		return (source ? "" : "t") + rowKey.toString();
+	}
+
+	public ListShuttleRowKey(Object rowKey, boolean source) {
+		super();
+		this.rowKey = rowKey;
+		this.source = source;
+		this.facadeSource = source;
+	}
+
+	public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
+		super();
+		this.rowKey = rowKey;
+		this.source = source;
+		this.facadeSource = facadeSource;
+	}
+}

Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java	                        (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,83 @@
+/**
+ * 
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+/**
+ * Map-based extended data model for model-translating components like ordering list
+ * 
+ * @author Nick Belaevski
+ *         mailto:nbelaevski at exadel.com
+ *         created 07.11.2007
+ *
+ */
+public class OrderingListDataModel extends ExtendedDataModel {
+
+	private Map data;
+	
+	private Object rowKey;
+	
+	public Object getRowKey() {
+		return rowKey;
+	}
+
+	public void setRowKey(Object rowKey) {
+		this.rowKey = rowKey;
+	}
+
+	public void walk(FacesContext context, DataVisitor visitor, Range range,
+			Object argument) throws IOException {
+
+		Set entrySet = data.entrySet();
+		Iterator iterator = entrySet.iterator();
+		
+		while (iterator.hasNext()) {
+			Map.Entry entry = (Map.Entry) iterator.next();
+			
+			visitor.process(context, entry.getKey(), argument);
+		}
+	}
+
+	public int getRowCount() {
+		return data.size();
+	}
+
+	public Object getRowData() {
+		return data.get(rowKey);
+	}
+
+	public int getRowIndex() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	public Object getWrappedData() {
+		return data;
+	}
+
+	public boolean isRowAvailable() {
+		return data.containsKey(rowKey);
+	}
+
+	public void setRowIndex(int rowIndex) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	public void setWrappedData(Object data) {
+		this.rowKey = null;
+		this.data = (Map) data;
+	}
+
+}

Deleted: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java	2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,150 +0,0 @@
-/**
- * 
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModel;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceDataModel;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ListShuttleDataModel extends ExtendedDataModel {
-
-	private ListShuttleRowKey rowKey;
-
-	private SequenceDataModel sourceModel;
-	private SequenceDataModel targetModel;
-
-	private Map data;
-
-	private Object wrappedData;
-	
-	/* (non-Javadoc)
-	 * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
-	 */
-	public Object getRowKey() {
-		return rowKey;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
-	 */
-	public void setRowKey(Object key) {
-		this.rowKey = (ListShuttleRowKey) key;
-	}
-
-	public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
-			final Object argument) throws IOException {
-		if (data != null) {
-			Iterator iterator = data.entrySet().iterator();
-			
-			while (iterator.hasNext()) {
-				Entry entry =(Map.Entry) iterator.next();
-				
-				visitor.process(context, entry.getKey(), argument);
-			}
-			
-		} else {
-			sourceModel.walk(context, new DataVisitor() {
-
-				public void process(FacesContext context, Object rowKey,
-						Object argument) throws IOException {
-
-					ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
-					visitor.process(context, key, argument);
-				}
-			}, range, argument);
-
-			targetModel.walk(context, new DataVisitor() {
-
-				public void process(FacesContext context, Object rowKey,
-						Object argument) throws IOException {
-
-					ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
-					visitor.process(context, key, argument);
-				}
-				
-			}, range, argument);
-		}
-	}
-
-	public int getRowCount() {
-		if (data != null) {
-			return data.size();
-		} else {
-			return sourceModel.getRowCount() + targetModel.getRowCount();
-		}
-	}
-
-	public Object getRowData() {
-		if (data != null) {
-			return data.get(rowKey);
-		} else {
-			if (this.rowKey != null) {
-				if (this.rowKey.isSource()) {
-					return sourceModel.getRowData();
-				} else {
-					return targetModel.getRowData();
-				}
-			} else {
-				return null;
-			}
-		}
-	}
-
-	public int getRowIndex() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	public Object getWrappedData() {
-		return wrappedData;
-	}
-
-	public boolean isRowAvailable() {
-		if (data != null) {
-			return data.containsKey(rowKey);
-		} else {
-			if (rowKey != null) {
-				if (rowKey.isSource()) {
-					return sourceModel.isRowAvailable();
-				} else {
-					return targetModel.isRowAvailable();
-				}
-			} else {
-				return false;
-			}
-		}
-	}
-
-	public void setRowIndex(int rowIndex) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	public void setWrappedData(Object data) {
-		this.rowKey = null;
-		this.wrappedData = data;
-		
-		if (data instanceof Map) {
-			this.data = (Map) data;
-		} else {
-			DataModel[] models = (DataModel[]) data;
-			this.sourceModel = new SequenceDataModel(models[0]);
-			this.targetModel = new SequenceDataModel(models[1]);
-		}
-	}
-
-}

Deleted: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java	2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,80 +0,0 @@
-/**
- * 
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ListShuttleRowKey implements Serializable {
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 3308741255288495879L;
-	
-	private boolean source;
-	
-	private boolean facadeSource;
-	
-	private Object rowKey;
-
-	public boolean isSource() {
-		return source;
-	}
-	
-	public boolean isFacadeSource() {
-		return facadeSource;
-	}
-	
-	public Object getRowKey() {
-		return rowKey;
-	}
-
-	public int hashCode() {
-		final int prime = 31;
-		int result = 1;
-		result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
-		result = prime * result + (source ? 1231 : 1237);
-		return result;
-	}
-
-	public boolean equals(Object obj) {
-		if (this == obj)
-			return true;
-		if (obj == null)
-			return false;
-		if (getClass() != obj.getClass())
-			return false;
-		ListShuttleRowKey other = (ListShuttleRowKey) obj;
-		if (rowKey == null) {
-			if (other.rowKey != null)
-				return false;
-		} else if (!rowKey.equals(other.rowKey))
-			return false;
-		if (source != other.source)
-			return false;
-		return true;
-	}
-	
-	public String toString() {
-		return (source ? "" : "t") + rowKey.toString();
-	}
-
-	public ListShuttleRowKey(Object rowKey, boolean source) {
-		super();
-		this.rowKey = rowKey;
-		this.source = source;
-		this.facadeSource = source;
-	}
-
-	public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
-		super();
-		this.rowKey = rowKey;
-		this.source = source;
-		this.facadeSource = facadeSource;
-	}
-}

Deleted: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java	2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java	2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,81 +0,0 @@
-/**
- * 
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-
-/**
- * @author Nick Belaevski
- *         mailto:nbelaevski at exadel.com
- *         created 07.11.2007
- *
- */
-public class OrderingListDataModel extends ExtendedDataModel {
-
-	private Map data;
-	
-	private Object rowKey;
-	
-	public Object getRowKey() {
-		return rowKey;
-	}
-
-	public void setRowKey(Object rowKey) {
-		this.rowKey = rowKey;
-	}
-
-	public void walk(FacesContext context, DataVisitor visitor, Range range,
-			Object argument) throws IOException {
-
-		Set entrySet = data.entrySet();
-		Iterator iterator = entrySet.iterator();
-		
-		while (iterator.hasNext()) {
-			Map.Entry entry = (Map.Entry) iterator.next();
-			
-			visitor.process(context, entry.getKey(), argument);
-		}
-	}
-
-	public int getRowCount() {
-		return data.size();
-	}
-
-	public Object getRowData() {
-		return data.get(rowKey);
-	}
-
-	public int getRowIndex() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	public Object getWrappedData() {
-		return data;
-	}
-
-	public boolean isRowAvailable() {
-		return data.containsKey(rowKey);
-	}
-
-	public void setRowIndex(int rowIndex) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	public void setWrappedData(Object data) {
-		this.rowKey = null;
-		this.data = (Map) data;
-	}
-
-}




More information about the richfaces-svn-commits mailing list