Author: dmaliarevich
Date: 2011-12-02 07:43:10 -0500 (Fri, 02 Dec 2011)
New Revision: 36876
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
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/mapping/VpeDomMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeNodeMapping.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateSafeWrapper.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/VpeTest.java
Log:
https://issues.jboss.org/browse/JBIDE-9932 - VpeDomMapping was updated to use HashMap
iteration, plus some code adjustments.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputTextTemplate.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -34,16 +34,10 @@
*
* @see #isSpanNeeding(Element)
*/
- private static final String[] spanMarkers = {
+ private static final String[] SPAN_MARKERS = {
JSF.ATTR_STYLE, JSF.ATTR_STYLE_CLASS, JSF.ATTR_ID,
JSF.ATTR_DIR, JSF.ATTR_TITLE, JSF.ATTR_LANG};
- /*
- * (non-Javadoc)
- *
- * @see
org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
- * org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
- */
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
@@ -74,10 +68,10 @@
* Returns {@code true} if given {@code element} should be
* rendered in {@code SPAN} tag, otherwise returns {@code false}.
*
- * @see #spanMarkers
+ * @see #SPAN_MARKERS
*/
private boolean isSpanNeeding(Element element) {
- for (String spanMarker : spanMarkers) {
+ for (String spanMarker : SPAN_MARKERS) {
if (element.hasAttribute(spanMarker)) {
return true;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeDomBuilder.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -44,11 +44,8 @@
if (sorceAdapter == null) {
return;
}
-
domMapping.mapNodes(nodeMapping);
Node sourceNode = nodeMapping.getSourceNode();
-
-
/* yradtsevich:
* checking for ((INodeNotifier) sourceNode).getExistingAdapter(sorceAdapter) == null
* is not used because of JBIDE-8049 (JBIDE-8051)
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -49,17 +49,9 @@
super(domMapping, sorceAdapter, visualEditor, pageContext);
}
- /**
- *
- * @param sourceNode
- * @param visualOldContainer
- * @return
- */
@Override
- public nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
-
+ public nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer, boolean
onlyOneIncludeStack) {
Set<?> ifDependencySet = new HashSet();
-
if(sourceNode==null||(
sourceNode.getNodeType()!=Node.TEXT_NODE
&&sourceNode.getNodeType()!=Node.ELEMENT_NODE
@@ -74,8 +66,8 @@
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
if (getPageContext().getElService().isELNode(sourceNode)) {
- final Node sourceNodeProxy =
VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
- sourceNode);
+ final Node sourceNodeProxy =
VpeProxyUtil.createProxyForELExpressionNode(
+ getPageContext(), sourceNode);
try {
creationData = template.create(getPageContext(),
sourceNodeProxy, getVisualDocument());
@@ -84,10 +76,9 @@
} catch(ClassCastException ex) {
VpePlugin.reportProblem(ex);
//then we create template without using proxy
- creationData = template.create(getPageContext(), sourceNode,
- getVisualDocument());
+ creationData = template.create(getPageContext(),
+ sourceNode, getVisualDocument());
}
-
} else {
creationData = template.create(getPageContext(), sourceNode,
getVisualDocument());
}
@@ -99,13 +90,10 @@
getPageContext().setCurrentVisualNode(null);
nsIDOMNode visualNewNode;
visualNewNode = creationData.getNode();
-
if(sourceNode instanceof Element && visualNewNode != null) {
setTooltip((Element)sourceNode, queryInterface(visualNewNode, nsIDOMElement.class));
correctVisualAttribute(queryInterface(visualNewNode, nsIDOMElement.class));
}
-
-
if (template.hasChildren()) {
List<?> childrenInfoList = creationData.getChildrenInfoList();
if (childrenInfoList == null) {
@@ -114,7 +102,6 @@
addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
}
}
-
/*
* Setting current visual node was added
* to fix h:dataTable content visibility on Preview tab.
@@ -126,5 +113,4 @@
return visualNewNode;
}
-
-}
+}
\ No newline at end of file
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-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -261,11 +261,16 @@
* @return {@code true} if and only if the visual representation is created and added
successfully
*/
private boolean addNode(Node sourceNode, nsIDOMNode visualNextNode, nsIDOMNode
visualContainer) {
+ /*
+ * Check includeStack size. During node creation it could be increased.
+ * !IMPORTANT! Thus the state should be check in the beginning
+ * and stored until the visual element is added into DOM.
+ * For each node there should be a separate variable.
+ * !IMPORTANT! It is used to register nodes in VpeDomMapping.
+ */
+ boolean onlyOneIncludeStack = isCurrentMainDocument();
try {
-
- nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer);
-
-
+ nsIDOMNode visualNewNode = createNode(sourceNode, visualContainer,
onlyOneIncludeStack);
// Commented as fix for JBIDE-3012.
// // Fix for JBIDE-1097
// try {
@@ -277,35 +282,40 @@
// } catch (XPCOMException ex) {
// // just ignore this exception
// }
-
- if (visualNewNode != null) {
- /*
- *
https://jira.jboss.org/jira/browse/JBIDE-3373
- * Do not add additional visual node for f:facet
- * when it is inserted into existing one.
- */
- nsIDOMElement element = null;
- try {
- element = queryInterface(visualNewNode, nsIDOMElement.class);
- } catch (org.mozilla.xpcom.XPCOMException e) {
- /*
- * Cannot parse node to element,
- * do nothing
- */
- }
- if (!((null != element) && element.hasAttribute(VPE_FACET))) {
- if (visualNextNode == null) {
- visualContainer.appendChild(visualNewNode);
- } else {
- visualContainer.insertBefore(visualNewNode, visualNextNode);
+ if (visualNewNode != null) {
+ /*
+ *
https://jira.jboss.org/jira/browse/JBIDE-3373
+ * Do not add additional visual node for f:facet
+ * when it is inserted into existing one.
+ */
+ nsIDOMElement element = null;
+ try {
+ element = queryInterface(visualNewNode, nsIDOMElement.class);
+ } catch (org.mozilla.xpcom.XPCOMException e) {
+ /*
+ * Cannot parse node to element, do nothing
+ */
+ }
+ if (!((null != element) && element.hasAttribute(VPE_FACET))) {
+ nsIDOMNode registeredVisualNewNode = null;
+ if (visualNextNode == null) {
+ registeredVisualNewNode = visualContainer.appendChild(visualNewNode);
+ } else {
+ registeredVisualNewNode = visualContainer.insertBefore(visualNewNode,
visualNextNode);
+ }
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-9932
+ * Update visual node in vpe mapping.
+ */
+ if (onlyOneIncludeStack) {
+ domMapping.remapVisualNode(visualNewNode, registeredVisualNewNode);
+ }
+ }
+ return true;
}
- }
- return true;
- }
- } catch(XPCOMException xpcomException) {
+ } catch (XPCOMException xpcomException) {
VpePlugin.reportProblem(xpcomException);
}
-
return false;
}
@@ -316,10 +326,8 @@
* @param visualOldContainer visual node, in which the caller plans to insert new visual
node
* @return new visual node
*/
- public nsIDOMNode createNode(Node sourceNode,
- nsIDOMNode visualOldContainer) throws VpeDisposeException {
-
- boolean registerFlag = isCurrentMainDocument();
+ public nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer,
+ boolean onlyOneIncludeStack) throws VpeDisposeException {
//it's check for initialization visualController,
//if we trying to process some event when controller
//hasn't been initialized, it's causes
@@ -359,7 +367,6 @@
pageContext.setCurrentVisualNode(visualOldContainer);
VpeTemplate template = getTemplateManager().getTemplate(pageContext,
sourceNode, ifDependencySet);
-
VpeCreationData creationData = null;
Node sourceNodeProxy = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
@@ -444,7 +451,8 @@
&& visualNewNode.getNodeType() == nsIDOMNode.ELEMENT_NODE) {
setTooltip((Element) sourceNode, queryInterface(visualNewNode, nsIDOMElement.class));
}
- if (registerFlag) {
+ VpeElementMapping elementMapping = null;
+ if (onlyOneIncludeStack) {
final VpeElementData data = creationData.getElementData();
if ((sourceNodeProxy != null) && (data != null)
&& (data.getNodesData() != null)
@@ -453,8 +461,8 @@
if (nodeData.getSourceNode() != null) {
Node attr = null;
if(sourceNode.getAttributes()!=null) {
- attr = sourceNode.getAttributes().getNamedItem(nodeData
- .getSourceNode().getNodeName());
+ attr = sourceNode.getAttributes().getNamedItem(
+ nodeData.getSourceNode().getNodeName());
} else {
//Text node haven't child nodes, but it's node.
attr = sourceNode;
@@ -463,9 +471,8 @@
nodeData.setEditable(false);
}
}
-
}
- VpeElementMapping elementMapping = new VpeElementMapping(
+ elementMapping = new VpeElementMapping(
sourceNode, visualNewNode, template,
ifDependencySet, creationData.getData(), data);
registerNodes(elementMapping);
@@ -552,14 +559,12 @@
for (int i = 0; i < len; i++) {
Node sourceNode = sourceNodes.item(i);
if (addNode(sourceNode, null, visualContainer)) {
- if (Node.ELEMENT_NODE == sourceNode.getNodeType()) {
- }
+// if (Node.ELEMENT_NODE == sourceNode.getNodeType()) { }
childrenCount++;
}
}
if (childrenCount == 0) {
- setPseudoContent(containerTemplate, sourceContainer,
- visualContainer);
+ setPseudoContent(containerTemplate, sourceContainer,visualContainer);
}
}
@@ -1430,8 +1435,7 @@
protected void setReadOnlyElement(nsIDOMElement node) {
String style = node.getAttribute(VpeStyleUtil.ATTRIBUTE_STYLE);
- style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
//$NON-NLS-1$
- "read-only"); //$NON-NLS-1$
+ style = VpeStyleUtil.setParameterInStyle(style, "-moz-user-modify",
"read-only"); //$NON-NLS-1$ //$NON-NLS-2$
node.setAttribute(VpeStyleUtil.ATTRIBUTE_STYLE, style);
}
@@ -1474,7 +1478,7 @@
}
return false;
}
-
+
public boolean isCurrentMainDocument() {
return includeStack.size() <= 1;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeDomMapping.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -40,6 +40,23 @@
}
}
+ /**
+ * Remap visual node in DOM Mapping and in the VisualMap.
+ *
+ * @param visualNode old visual node
+ * @param registeredVisualNewNode node, that've been actually registered in the DOM
+ */
+ public void remapVisualNode(nsIDOMNode visualNode, nsIDOMNode registeredVisualNewNode)
{
+ if ((visualNode != null) && (registeredVisualNewNode != null)) {
+ VpeNodeMapping nodeMapping = visualMap.get(visualNode);
+ if (nodeMapping != null) {
+ nodeMapping.setVisualNode(registeredVisualNewNode);
+ visualMap.remove(visualNode);
+ visualMap.put(registeredVisualNewNode, nodeMapping);
+ }
+ }
+ }
+
public void clear(nsIDOMNode except) {
Set<Map.Entry<nsIDOMNode, VpeNodeMapping>> entrySet =
visualMap.entrySet();
Iterator<Map.Entry<nsIDOMNode, VpeNodeMapping>> iter =
entrySet.iterator();
@@ -62,29 +79,21 @@
}
public VpeNodeMapping getNodeMappingAtSourceNode(Node sourceNode) {
+ VpeNodeMapping nodeMapping = null;
if (sourceNode != null) {
- return sourceMap.get(sourceNode);
+ nodeMapping = sourceMap.get(sourceNode);
}
-
- return null;
+ return nodeMapping;
}
public VpeNodeMapping getNodeMappingAtVisualNode(nsIDOMNode visualNode) {
VpeNodeMapping nodeMapping = null;
/*
- * See
https://issues.jboss.org/browse/JBIDE-9807
- * Method map.get(key) doesn't work correctly for this situation,
- * it happens because "visualMap.keySet().contains(visualNode)"
- * not always correctly determines the "visualNode".
+ *
https://issues.jboss.org/browse/JBIDE-9932
+ * Replaced with map.
*/
if (visualNode != null) {
- Iterator<Map.Entry<nsIDOMNode, VpeNodeMapping>> iter =
visualMap.entrySet().iterator();
- while(iter.hasNext()) {
- Map.Entry<nsIDOMNode,VpeNodeMapping> element = iter.next();
- if (visualNode.equals(element.getKey())) {
- nodeMapping = element.getValue();
- }
- }
+ nodeMapping = visualMap.get(visualNode);
}
return nodeMapping;
}
@@ -102,7 +111,6 @@
if (nodeMapping != null) {
return nodeMapping.getSourceNode();
}
-
return null;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeNodeMapping.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeNodeMapping.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeNodeMapping.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -33,4 +33,12 @@
public nsIDOMNode getVisualNode() {
return visualNode;
}
+
+ /**
+ * Fix for
https://issues.jboss.org/browse/JBIDE-9932
+ * @param visualNode the visual node
+ */
+ public void setVisualNode(nsIDOMNode visualNode) {
+ this.visualNode = visualNode;
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -41,14 +41,11 @@
return new VpeCreationData(null);
}
- /* (non-Javadoc)
- * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getNodeForUpdate(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode, java.lang.Object)
- */
@Override
public Node getNodeForUpdate(VpePageContext pageContext, Node sourceNode,
nsIDOMNode visualNode, Object data) {
//if rendered=false, template hasn't visual presentations
- //so we should upadte parent node
+ //so we should update parent node
return sourceNode.getParentNode();
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateSafeWrapper.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateSafeWrapper.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateSafeWrapper.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -645,5 +645,11 @@
}
return result;
}
+
+ @Override
+ public String toString() {
+ return "VpeTemplateSafeWrapper@" + this.hashCode() //$NON-NLS-1$
+ + " [delegate=" + delegate + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -25,12 +25,12 @@
import org.w3c.dom.NodeList;
public class SourceDomUtil {
- private static final Set<String> templatesNamespacesWithRendered=new
HashSet<String>();
+ private static final Set<String> TEMPLATES_NAMESPACES_WITH_RENDERED=new
HashSet<String>();
static {
- templatesNamespacesWithRendered.add("h:"); //$NON-NLS-1$
- templatesNamespacesWithRendered.add("a4j:"); //$NON-NLS-1$
- templatesNamespacesWithRendered.add("rich:"); //$NON-NLS-1$
- templatesNamespacesWithRendered.add("seam:"); //$NON-NLS-1$
+ TEMPLATES_NAMESPACES_WITH_RENDERED.add("h:"); //$NON-NLS-1$
+ TEMPLATES_NAMESPACES_WITH_RENDERED.add("a4j:"); //$NON-NLS-1$
+ TEMPLATES_NAMESPACES_WITH_RENDERED.add("rich:"); //$NON-NLS-1$
+ TEMPLATES_NAMESPACES_WITH_RENDERED.add("seam:"); //$NON-NLS-1$
}
static public Node getAncestorNode(Node sourceNode, String tagName) {
@@ -77,17 +77,17 @@
public static boolean isRenderedAttrEqFalse(VpePageContext pageContext,
Element sourceNode) {
boolean result = false;
- final String attrName = "rendered"; //$NON-NLS-1$
+ final String ATTR_RENDERED = "rendered"; //$NON-NLS-1$
Element tempElement = sourceNode;
- if (sourceNode.hasAttribute(attrName)) {
+ if (sourceNode.hasAttribute(ATTR_RENDERED)) {
if (pageContext.getElService().isELNode(sourceNode)) {
tempElement = (Element) VpeProxyUtil
.createProxyForELExpressionNode(pageContext, sourceNode);
}
- if ("false".equals(tempElement.getAttribute(attrName))) { //$NON-NLS-1$
+ if ("false".equals(tempElement.getAttribute(ATTR_RENDERED))) {
//$NON-NLS-1$
String templateName = VpeTemplateManager.getInstance().getTemplateName(pageContext,
sourceNode);
String [] templatePrefix = templateName.split(":"); //$NON-NLS-1$
- if(templatePrefix.length>1 &&
templatesNamespacesWithRendered.contains(templatePrefix[0]+":")) {
//$NON-NLS-1$
+ if(templatePrefix.length>1 &&
TEMPLATES_NAMESPACES_WITH_RENDERED.contains(templatePrefix[0]+":")) {
//$NON-NLS-1$
result = true;
}
}
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/ComponentContentTest.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -133,7 +133,7 @@
throws DOMComparisonException {
// get element by id
nsIDOMElement vpeElement = findElementById(controller, elementId);
- assertNotNull("Cann't find element with id="+elementId,vpeElement);
//$NON-NLS-1$
+ assertNotNull("Cannot find element with id="+elementId,vpeElement);
//$NON-NLS-1$
// DOMTreeDumper dumper = new DOMTreeDumper(
// VpeDebug.VISUAL_DUMP_PRINT_HASH);
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/VpeTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/VpeTest.java 2011-12-02
12:04:51 UTC (rev 36875)
+++
trunk/vpe/tests/org.jboss.tools.vpe.base.test/src/org/jboss/tools/vpe/base/test/VpeTest.java 2011-12-02
12:43:10 UTC (rev 36876)
@@ -11,6 +11,8 @@
package org.jboss.tools.vpe.base.test;
+import static org.jboss.tools.vpe.xulrunner.util.XPCOM.queryInterface;
+
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
@@ -428,18 +430,24 @@
* @param elementId
* @return
*/
- protected nsIDOMElement findElementById(VpeController controller,
- String elementId) {
-
+ protected nsIDOMElement findElementById(VpeController controller,String elementId) {
Element sourceElement = findSourceElementById(controller, elementId);
-
- VpeNodeMapping nodeMapping = controller.getDomMapping().getNodeMapping(
- sourceElement);
-
- if (nodeMapping == null)
- return null;
-
- return (nsIDOMElement) nodeMapping.getVisualNode();
+ nsIDOMElement element = null;
+ VpeNodeMapping nodeMapping = controller
+ .getDomMapping().getNodeMapping(sourceElement);
+ if (nodeMapping != null) {
+ nsIDOMNode node = nodeMapping.getVisualNode();
+ if (node != null) {
+ try {
+ element = queryInterface(node, nsIDOMElement.class);
+ } catch (org.mozilla.xpcom.XPCOMException e) {
+ //Do nothing
+ } catch (NullPointerException e) {
+ //Do nothing
+ }
+ }
+ }
+ return element;
}
protected String getEditorID(){