Author: svasilyev
Date: 2007-07-06 11:03:39 -0400 (Fri, 06 Jul 2007)
New Revision: 2345
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeChildrenInfo.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
Log:
http://jira.jboss.org/jira/browse/EXIN-231
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-07-06
14:37:50 UTC (rev 2344)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2007-07-06
15:03:39 UTC (rev 2345)
@@ -623,28 +623,39 @@
// ==========================================================
public void updateNode(Node sourceNode) {
- if (sourceNode != null) {
- if (sourceNode.getNodeType() == Node.DOCUMENT_NODE) {
- rebuildDom((Document)sourceNode);
- } else if (sourceNode.getNodeType() == Node.COMMENT_NODE) {
- updateComment(sourceNode);
- } else {
- Node sourceTable = getParentTable(sourceNode, 2);
- if (sourceTable != null) {
- updateElement(sourceTable);
- return;
- } else {
- Node sourceSelect = getParentSelect(sourceNode);
- if (sourceSelect != null) {
- updateElement(sourceSelect);
- return;
- }
- }
- updateElement(sourceNode);
- }
+ if (sourceNode == null)
+ return;
+
+ switch (sourceNode.getNodeType()) {
+ case Node.DOCUMENT_NODE :
+ rebuildDom((Document)sourceNode);
+ break;
+ case Node.COMMENT_NODE :
+ updateComment(sourceNode);
+ break;
+ default :
+ updateElement(getNodeForUpdate(sourceNode));
}
}
+ // TODO S.Vasilyev make a common code for figuring out
+ // if it is need to update parent node or not
+ private Node getNodeForUpdate(Node sourceNode) {
+ /* Changing of <tr> or <td> tags can affect whole the table */
+ Node sourceTable = getParentTable(sourceNode, 2);
+ if (sourceTable != null) {
+ return sourceTable;
+ }
+
+ /* Changing of an <option> tag can affect the parent select */
+ Node sourceSelect = getParentSelect(sourceNode);
+ if (sourceSelect != null) {
+ return sourceSelect;
+ }
+
+ return sourceNode;
+ }
+
private void updateComment(Node sourceNode) {
VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
if (mapping != null && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
@@ -726,7 +737,7 @@
public void setText(Node sourceText) {
Node sourceParent = sourceText.getParentNode();
if (sourceParent != null && sourceParent.getLocalName() != null) {
- String sourceParentName = sourceParent.getLocalName().toLowerCase();
+ String sourceParentName = sourceParent.getLocalName();
if ("textarea".equalsIgnoreCase(sourceParentName) ||
"option".equalsIgnoreCase(sourceParentName)) {
updateNode(sourceText.getParentNode());
return;
@@ -918,7 +929,7 @@
private Element createLinkNode(String href_val, String rel_val, String ext_val) {
Element linkNode = null;
- if ((ATTR_REL_STYLESHEET_VALUE.compareToIgnoreCase(rel_val) == 0)
+ if ((ATTR_REL_STYLESHEET_VALUE.equalsIgnoreCase(rel_val))
&& href_val.startsWith("file:")) {
/* Because of the Mozilla caches the linked css files we replace
* tag <link rel="styleseet" href="file://..."> with tag
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeChildrenInfo.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeChildrenInfo.java 2007-07-06
14:37:50 UTC (rev 2344)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeChildrenInfo.java 2007-07-06
15:03:39 UTC (rev 2345)
@@ -22,7 +22,7 @@
public class VpeChildrenInfo {
private Element visualParent;
- private List sourceChildren;
+ private List<Node> sourceChildren;
public VpeChildrenInfo(Element visualParent) {
this.visualParent = visualParent;
@@ -40,7 +40,7 @@
* Returs <code>List</code> of nodes of the source tree for creating new
visual nodes.
* @return <code>List</code> of nodes of the source tree for creating new
visual nodes.
*/
- public List getSourceChildren() {
+ public List<Node> getSourceChildren() {
return sourceChildren;
}
@@ -49,13 +49,13 @@
* @param child The node of the source tree.
*/
public void addSourceChild(Node child) {
- List children = getChildren();
+ List<Node> children = getChildren();
children.add(child);
}
- private List getChildren() {
+ private List<Node> getChildren() {
if (sourceChildren == null) {
- sourceChildren = new ArrayList();
+ sourceChildren = new ArrayList<Node> ();
}
return sourceChildren;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2007-07-06
14:37:50 UTC (rev 2344)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreationData.java 2007-07-06
15:03:39 UTC (rev 2345)
@@ -17,8 +17,8 @@
public class VpeCreationData {
private Node node;
- private List childrenInfoList;
- private List illegalChildren;
+ private List<VpeChildrenInfo> childrenInfoList;
+ private List<Node> illegalChildren;
private Object data;
public VpeCreationData(Node node) {
@@ -31,23 +31,23 @@
public void addChildrenInfo(VpeChildrenInfo info) {
if (childrenInfoList == null) {
- childrenInfoList = new ArrayList();
+ childrenInfoList = new ArrayList<VpeChildrenInfo>();
}
childrenInfoList.add(info);
}
- public List getChildrenInfoList() {
+ public List<VpeChildrenInfo> getChildrenInfoList() {
return childrenInfoList;
}
public void addIllegalChild(Node child) {
if (illegalChildren == null) {
- illegalChildren = new ArrayList();
+ illegalChildren = new ArrayList<Node>();
}
illegalChildren.add(child);
}
- public List getIllegalChildren() {
+ public List<Node> getIllegalChildren() {
return illegalChildren;
}