Author: nbelaevski
Date: 2007-03-22 19:59:20 -0400 (Thu, 22 Mar 2007)
New Revision: 122
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/ListRowKey.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeRowKey.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
Log:
Tree changes:
1. Escapement for RowKey parts implemented
2. TreeNode revealed - getTreeNode() method added to UITree, proper correction to data
model
3. Drag/drop values now are aliases to rowData
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
===================================================================
---
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-03-22
17:39:15 UTC (rev 121)
+++
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -134,4 +134,6 @@
dataVisitor.process(context, treeRowKey, argument);
}
}
+
+ public abstract TreeNode getTreeNode();
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/ListRowKey.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/ListRowKey.java 2007-03-22
17:39:15 UTC (rev 121)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/ListRowKey.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -75,29 +75,39 @@
String trimmedPath = path.trim();
- int idx = -1;
- int oldIdx = 0;
+ StringBuffer sb = new StringBuffer();
+ boolean escapedState = false;
+ int pathLength = trimmedPath.length();
- do {
- idx = trimmedPath.indexOf(ESCAPED_SEPARATOR_CHAR_STRING, oldIdx);
-
- String subData;
-
- if (idx != -1) {
- subData = trimmedPath.substring(oldIdx, idx);
+ //unescape
+ for (int i = 0; i < pathLength; i++) {
+ char c = trimmedPath.charAt(i);
+
+ if (SEPARATOR_ESCAPE_CHAR == c) {
+ if (escapedState) {
+ sb.append(c);
+ }
+ escapedState = !escapedState;
} else {
- subData = trimmedPath.substring(oldIdx);
- }
+ if (c == AbstractTreeDataModel.SEPARATOR) {
+ if (escapedState) {
+ sb.append(c);
+ } else {
+ result.add(sb.toString());
+ sb = new StringBuffer();
+ }
+ } else {
+ sb.append(c);
+ }
- subData = subData.trim();
- if (subData.length() != 0) {
- //unescape
- result.add(subData.replace(ESCAPED_ESCAPE_CHAR_STRING, ESCAPE_CHAR_STRING));
+ escapedState = false;
}
+ }
- oldIdx = idx + ESCAPED_SEPARATOR_CHAR_STRING.length();
- } while (idx != -1);
-
+ if (sb.length() != 0) {
+ result.add(sb.toString());
+ }
+
return result;
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java
===================================================================
---
trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-03-22
17:39:15 UTC (rev 121)
+++
trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -216,4 +216,8 @@
public void walkModel(FacesContext context, DataVisitor visitor, TreeRange range,
TreeRowKey key, Object argument, boolean last) throws IOException {
walk(context, visitor, range, key, argument, last);
}
+
+ public TreeNode getTreeNode() {
+ return locateTreeNode(this.currentRowKey);
+ }
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeRowKey.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeRowKey.java 2007-03-22
17:39:15 UTC (rev 121)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeRowKey.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -31,16 +31,8 @@
*/
public abstract class TreeRowKey implements Serializable {
- public static final char SEPARATOR_ESCAPE_CHAR = '-';
+ public static final char SEPARATOR_ESCAPE_CHAR = '_';
- //that is to escape colons in path by preceding with "-"
- //colon is SEPARATOR_CHAR
- protected static final String ESCAPE_CHAR_STRING =
String.valueOf(SEPARATOR_ESCAPE_CHAR);
- protected static final String ESCAPED_ESCAPE_CHAR_STRING = ESCAPE_CHAR_STRING +
ESCAPE_CHAR_STRING;
-
- protected static final String SEPARATOR_CHAR_STRING =
String.valueOf(AbstractTreeDataModel.SEPARATOR);
- protected static final String ESCAPED_SEPARATOR_CHAR_STRING = ESCAPE_CHAR_STRING +
SEPARATOR_CHAR_STRING;
-
/**
* getter for key depth
* @return key depth
@@ -74,7 +66,7 @@
return false;
}
- return (rowKey.getPath() + ESCAPED_SEPARATOR_CHAR_STRING).startsWith(getPath());
+ return (rowKey.getPath() + AbstractTreeDataModel.SEPARATOR).startsWith(getPath());
}
/**
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-03-22
17:39:15 UTC (rev 121)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -113,7 +113,6 @@
.registerListenerInstance(getFacesContext());
}
-
public boolean getRendersChildren() {
return true;
}
@@ -141,6 +140,10 @@
return defaultFacet;
}
+ public TreeNode getTreeNode() {
+ return ((AbstractTreeDataModel) getExtendedDataModel()).getTreeNode();
+ }
+
public abstract boolean isImmediate();
public abstract void setImmediate(boolean immediate);
@@ -582,8 +585,7 @@
}
public Object getDragValue() {
- // TODO Auto-generated method stub
- return null;
+ return getRowData();
}
public UIComponent getComponent() {
@@ -591,8 +593,7 @@
}
public Object getDropValue() {
- // TODO Auto-generated method stub
- return null;
+ return getRowData();
}
public void addDropListener(DropListener listener) {
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-03-22
17:39:15 UTC (rev 121)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITreeNode.java 2007-03-22
23:59:20 UTC (rev 122)
@@ -171,6 +171,24 @@
return map;
}
+ public Object getDragValue() {
+ return getUITree().getDragValue();
+ }
+
+ public void setDragValue(Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object getDropValue() {
+ return getUITree().getDropValue();
+ }
+
+ public void setDropValue(Object o) {
+ // TODO Auto-generated method stub
+
+ }
+
/*
* Key of a drag object. It's used to define a necessity of processing the current
dragged element on the drop zone side
* Getter for dragType
Show replies by date