Author: nbelaevski
Date: 2008-01-08 12:18:23 -0500 (Tue, 08 Jan 2008)
New Revision: 5189
Added:
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
Removed:
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
trunk/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
Log:
http://jira.jboss.com/jira/browse/RF-1855
Copied: trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
(from rev 5174,
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -0,0 +1,150 @@
+/**
+ *
+ */
+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]);
+ }
+ }
+
+}
Copied: trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java (from
rev 5174, trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+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;
+ }
+}
Copied: trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
(from rev 5174,
trunk/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java)
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+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@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: trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
===================================================================
---
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-08
16:49:55 UTC (rev 5188)
+++
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -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: trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
---
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-08
16:49:55 UTC (rev 5188)
+++
trunk/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -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:
trunk/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
===================================================================
---
trunk/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-08
16:49:55 UTC (rev 5188)
+++
trunk/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-08
17:18:23 UTC (rev 5189)
@@ -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@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;
- }
-
-}