sventon subversion web client - http://www.sventon.org
[show recent changes]
 
  Help
HEAD
Rev: 24508 - http://anonsvn.icesoft.org/repo / icefaces2 / scratchpads / ICE-6565 / icefaces / core / src / main / java / org / icefaces / impl / util / DOMUtils.java
Unified Diff View - DOMUtils.java
/icefaces2/scratchpads/ICE-6565/icefaces/core/src/main/java/org/icefaces/impl/util/DOMUtils.java @ revision 24507
/icefaces2/scratchpads/ICE-6565/icefaces/core/src/main/java/org/icefaces/impl/util/DOMUtils.java @ revision 24508
@@ -73,6 +73,10 @@         public String id;         //will be Element once pruning is integrated         public Node element; + +        public String toString() { +            return this.getClass().getName() + ":" + id + ":" + element; +        }     }     public static class InsertOperation extends EditOperation { @@ -83,12 +87,9 @@     }     public static class DeleteOperation extends EditOperation { -        public DeleteOperation(String id, Node element) { -            this.id = id; -            this.element = element; -        }         public DeleteOperation(String id) { -            this(id, null); +            this.id = id; +            this.element = null;         }     } @@ -359,6 +360,7 @@         List<Node> justNodes = new ArrayList<Node>();         for (EditOperation op : nodeDiffs) {             if (op instanceof ReplaceOperation) { +                op.element = ascendToNodeWithID(op.element);                 justNodes.add(op.element);             }         } @@ -370,10 +372,8 @@             e.printStackTrace();         } -        for (EditOperation op : nodeDiffs) { -            if (op instanceof ReplaceOperation) { -                justNodes.add(op.element); -            } +        if (null == prunedDiff) { +            prunedDiff = new Node[0];         }         List<Node> prunedList = Arrays.asList(prunedDiff); @@ -522,13 +522,21 @@                     if (newIndex > 0) {                         insertAnchor = paddedGet(newList, newIndex - 1);                     } else { +//TODO Implement InsertBefore                         //this case is properly handled by an insert "before"                         nodeDiffs.add(new ReplaceOperation(newNode));                         ops = null;                         break;                     } -                    operation = new InsertOperation(insertAnchor, -                            newChildNodes.item(newIndex) ); +                    if (insertAnchor.startsWith("?")) { +                        //anchor is not valid so we must replace parent +                        nodeDiffs.add(new ReplaceOperation(newNode)); +                        ops = null; +                        break; +                    } else { +                        operation = new InsertOperation(insertAnchor, +                                newChildNodes.item(newIndex) ); +                    }                     newIndex++;                 }                 if (!newInOld && !oldInNew) { @@ -545,8 +553,15 @@                             ops = null;                             break;                         } -                        operation = new InsertOperation(insertAnchor, -                                newChildNodes.item(newIndex) ); +                        if (insertAnchor.startsWith("?")) { +                            //anchor is not valid so we must replace parent +                            nodeDiffs.add(new ReplaceOperation(newNode)); +                            ops = null; +                            break; +                        } else { +                            operation = new InsertOperation(insertAnchor, +                                    newChildNodes.item(newIndex) ); +                        }                     } else {                         //two completely different IDs at this location                         //cancel and let parent handle @@ -618,7 +633,7 @@         List<String> listOfIds = new ArrayList<String>(length);         for (int i = 0; i < length; i++) {             Node node = nodeList.item(i); -            String id = "undefined" + i; +            String id = "?" + i;             if (node instanceof Element) {                 String tempId = ((Element) node).getAttribute("id");                 if ((null != tempId) && (!"".equals(tempId))) {


feed icon

sventon 2.5.1