Author: dmaliarevich
Date: 2011-11-02 05:40:49 -0400 (Wed, 02 Nov 2011)
New Revision: 36131
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/VpeHtmlTemplate.java
Log:
https://issues.jboss.org/browse/JBIDE-9569 - VpeVisualDomBuilder.getNodeForUpdate was
removed.
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 2011-11-02
09:24:58 UTC (rev 36130)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-11-02
09:40:49 UTC (rev 36131)
@@ -318,7 +318,7 @@
*/
public nsIDOMNode createNode(Node sourceNode,
nsIDOMNode visualOldContainer) throws VpeDisposeException {
-
+
boolean registerFlag = isCurrentMainDocument();
//it's check for initialization visualController,
//if we trying to process some event when controller
@@ -775,33 +775,14 @@
rebuildDom((Document) sourceNode);
break;
default:
- updateElement(getNodeForUpdate(sourceNode));
+ updateElement(sourceNode);
}
}
- // TODO Ssergey 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 updateElement(Node sourceNode) {
VpeElementMapping elementMapping = null;
VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
if (nodeMapping instanceof VpeElementMapping) {
-
elementMapping = (VpeElementMapping) nodeMapping;
if (elementMapping != null && elementMapping.getTemplate() != null) {
Node updateNode = elementMapping.getTemplate()
@@ -809,7 +790,6 @@
elementMapping.getSourceNode(),
elementMapping.getVisualNode(),
elementMapping.getData());
-
/*
* special processing of "style" element
*
@@ -822,19 +802,23 @@
VpeStyleUtil.refreshStyleElement(this, elementMapping);
return;
}
- if (updateNode != null && updateNode != sourceNode) {
+ if ((updateNode != null) && (updateNode != sourceNode)) {
updateNode(updateNode);
return;
}
}
}
-
+ /*
+ * 1) Remove source node from mappings and lists.
+ */
nsIDOMNode visualOldNode = domMapping.remove(sourceNode);
getSourceNodes().remove(sourceNode);
-
if (sourceNode instanceof INodeNotifier) {
((INodeNotifier) sourceNode).removeAdapter(getSorceAdapter());
}
+ /*
+ * 2) Add new visual node for this source node.
+ */
if (visualOldNode != null) {
nsIDOMNode visualContainer = visualOldNode.getParentNode();
nsIDOMNode visualNextNode = visualOldNode.getNextSibling();
@@ -866,27 +850,6 @@
}
}
- private Node getParentTable(Node sourceNode, int depth) {
- Node parentNode = sourceNode.getParentNode();
- for (int i = 0; parentNode != null && i < depth; parentNode = parentNode
- .getParentNode(), i++) {
- if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
- }
-
- private Node getParentSelect(Node sourceNode) {
- if (HTML.TAG_OPTION.equalsIgnoreCase(sourceNode.getNodeName())) {
- Node parentNode = sourceNode.getParentNode();
- if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
- return parentNode;
- }
- }
- return null;
- }
-
public void setCdataText(Node sourceNode) {
Node sourceParent = sourceNode.getParentNode();
if (sourceParent != null && sourceParent.getLocalName() != null) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2011-11-02
09:24:58 UTC (rev 36130)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2011-11-02
09:40:49 UTC (rev 36131)
@@ -526,17 +526,33 @@
}
return false;
}
+
@Override
- public Node getNodeForUpdate(VpePageContext pageContext, Node sourceNode, nsIDOMNode
visualNode, Object data) {
+ public Node getNodeForUpdate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMNode visualNode, Object data) {
+ Node nodeForUpdate = null;
+ String templateName = VpeTemplateManager.getInstance().getTemplateName(pageContext,
sourceNode);
// TODO Sergey Vasilyev redevelop JSF's facet template
if (sourceNode.getNodeName().endsWith(":facet")) { //$NON-NLS-1$
- return sourceNode.getParentNode();
+ nodeForUpdate = sourceNode.getParentNode();
+ } else if ((HTML.TAG_TD.equalsIgnoreCase(templateName))
+ || (HTML.TAG_TR.equalsIgnoreCase(templateName))) {
+ Node parentNode = sourceNode.getParentNode();
+ for (int i = 0; parentNode != null && i < 2; parentNode =
parentNode.getParentNode(), i++) {
+ if (HTML.TAG_TABLE.equalsIgnoreCase(parentNode.getNodeName())) {
+ nodeForUpdate = parentNode;
+ break;
+ }
+ }
+ } else if(HTML.TAG_OPTION.equalsIgnoreCase(templateName)) {
+ Node parentNode = sourceNode.getParentNode();
+ if (HTML.TAG_SELECT.equalsIgnoreCase(parentNode.getNodeName())) {
+ nodeForUpdate = parentNode;
+ }
+ } else if (creator != null) {
+ nodeForUpdate = creator.getNodeForUpdate(pageContext, sourceNode, visualNode,
(Map<VpeTemplate,?>)data);
}
-
- if (creator != null) {
- return creator.getNodeForUpdate(pageContext, sourceNode, visualNode,
(Map<VpeTemplate,?>)data);
- }
- return null;
+ return nodeForUpdate;
}
/* (non-Javadoc)
@@ -570,5 +586,5 @@
}
}
return null;
- }
+ }
}
\ No newline at end of file