[215555] EMF2DOMAdapter IndexOutOfBounds when inserting dom child
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
index 66337bb..cd6a7a2 100644
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
+++ b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
@@ -330,7 +330,10 @@
 					continue;
 				// A node has been reordered in the list
 				Node reorderNode = adapter.getNode();
-				Node insertBeforeNode = (Node) domChildren.get(i);
+				Node insertBeforeNode = reorderNode;
+				if (i < domChildren.size() && domChildren.get(i) != reorderNode) {
+					insertBeforeNode = (Node) domChildren.get(i);
+				}
 				domChildren.remove(reorderNode);
 				domChildren.add(i, reorderNode);
 				if (reorderNode != insertBeforeNode) {