Author: mareshkau
Date: 2009-06-08 09:58:18 -0400 (Mon, 08 Jun 2009)
New Revision: 15774
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4179Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLinkCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4179
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml 2009-06-08
13:58:18 UTC (rev 15774)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core">
+<head></head>
+<body>
+ <div id="jbide4179">
+ <h:outputText value="False" rendered="false" />
+ <h:outputText value="FalseEL" rendered="#{false}" />
+ <h:outputText value="TrueEL" rendered="#{true}" />
+ <h:outputText value="True" />
+ <h:outputText value="FalseEL2" rendered="#{false}" />
+ </div>
+</body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4179/jbide4179.xhtml.xml 2009-06-08
13:58:18 UTC (rev 15774)
@@ -0,0 +1,15 @@
+<tests>
+ <test id="jbide4179">
+ <DIV ID="jbide4179" STYLE="-moz-user-modify: read-write;">
+ <SPAN CLASS="vpe-text">
+ TrueEL
+</SPAN>
+ <SPAN CLASS="vpe-text">
+ True
+</SPAN>
+ <SPAN CLASS="vpe-text">
+ FalseEL2
+</SPAN>
+ </DIV>
+ </test>
+</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-06-08
13:42:28 UTC (rev 15773)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -57,6 +57,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3734Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3969Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4037Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4179Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4337Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4373Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
@@ -144,6 +145,7 @@
suite.addTestSuite(JBIDE675Test.class);
suite.addTestSuite(JBIDE3969Test.class);
suite.addTestSuite(JBIDE4337Test.class);
+ suite.addTestSuite(JBIDE4179Test.class);
// $JUnit-END$
// added by Max Areshkau
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4179Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4179Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4179Test.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.custom.StyledText;
+import org.jboss.tools.common.el.core.ELReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+import org.jboss.tools.vpe.ui.test.TestDomUtil;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.w3c.dom.Document;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class JBIDE4179Test extends ComponentContentTest{
+
+ private static final String testName = "JBIDE/4179/jbide4179.xhtml";
//$NON-NLS-1$
+
+ private IFile file;
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.ui.test.VpeTest#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.file = (IFile)
TestUtil.getComponentPath(JBIDE4179Test.testName,JsfAllTests.IMPORT_PROJECT_NAME);
+ ResourceReference[] entries = new ResourceReference[1];
+ entries[0] = new ResourceReference("false", ResourceReference.FILE_SCOPE);
//$NON-NLS-1$
+ entries[0].setProperties("false"); //$NON-NLS-1$
+ ELReferenceList.getInstance().setAllResources(this.file,entries);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.vpe.ui.test.VpeTest#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ ELReferenceList.getInstance().setAllResources(this.file, new ResourceReference[0]);
+ super.tearDown();
+ }
+
+ public JBIDE4179Test(String name) {
+ super(name);
+ }
+
+ public void testJBIDE4179Test() throws Throwable {
+ VpeController vpeController =openInVpe(JsfAllTests.IMPORT_PROJECT_NAME,
"JBIDE/4179/jbide4179.xhtml"); //$NON-NLS-1$
+ StyledText styledText = vpeController.getSourceEditor().getTextViewer()
+ .getTextWidget();
+ styledText.setCaretOffset(TestUtil.getLinePositionOffcet(
vpeController.getSourceEditor().getTextViewer(),
+ 13, 51));
+ styledText.insert("b"); //$NON-NLS-1$
+ //wait when update job finished
+ TestUtil.delay(500);
+ File xmlTestFile = TestUtil.getComponentPath(
+ JBIDE4179Test.testName + XML_FILE_EXTENSION, getTestProjectName())
+ .getLocation().toFile();
+
+ // get document
+ Document xmlTestDocument = TestDomUtil.getDocument(xmlTestFile);
+ assertNotNull("Can't get test file, possibly file not exists
"+xmlTestFile,xmlTestDocument); //$NON-NLS-1$
+
+ List<String> ids = TestDomUtil.getTestIds(xmlTestDocument);
+
+ for (String id : ids) {
+
+ compareElements(vpeController, xmlTestDocument, id, id);
+ }
+
+ if (getException() != null) {
+ throw getException();
+ }
+ }
+
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_PROJECT_NAME;
+ }
+
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLinkCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLinkCreator.java 2009-06-08
13:42:28 UTC (rev 15773)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeLinkCreator.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -67,7 +67,7 @@
}
}
}
-
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
String href_value = getExprValue(pageContext, hrefExpr, sourceNode);
String rel_value = getExprValue(pageContext, relExpr, sourceNode);
Added:
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
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeRenderingTemplate.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * Used for processing templates with renderd="false" attribute.
+ *
+ * @author mareshkau
+ *
+ */
+public class VpeRenderingTemplate extends VpeAbstractTemplate{
+
+ private static VpeRenderingTemplate instance;
+
+ private VpeRenderingTemplate(){
+
+ }
+
+ public static synchronized VpeRenderingTemplate getInstance(){
+ if(instance==null) {
+ instance = new VpeRenderingTemplate();
+ }
+ return instance;
+ }
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ 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
+ return sourceNode.getParentNode();
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-06-08
13:42:28 UTC (rev 15773)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -28,6 +28,7 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.dom.ThisExpression;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jst.web.tld.TaglibData;
@@ -36,6 +37,7 @@
import org.jboss.tools.vpe.editor.template.custom.CustomTLDReference;
import org.jboss.tools.vpe.editor.template.textformating.TextFormatingData;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.SourceDomUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.osgi.framework.Bundle;
import org.w3c.dom.Document;
@@ -315,12 +317,17 @@
VpeTemplate template = getTemplateImpl(pageContext, sourceNode, dependencySet);
if (template != null) {
return template;
- } else {
- return defTemplate;
}
+ return this.defTemplate;
}
private VpeTemplate getTemplateImpl(VpePageContext pageContext, Node sourceNode,
Set<?> dependencySet) {
+ //Fix for JBIDE-4179, mareshkau
+ if((sourceNode instanceof Element) &&
+ SourceDomUtil.isRenderedAttrEqFalse(pageContext,(Element) sourceNode)){
+ return VpeRenderingTemplate.getInstance();
+ }
+
String name = getTemplateName(pageContext, sourceNode);
if (name == null) {
return null;
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 2009-06-08
13:42:28 UTC (rev 15773)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2009-06-08
13:58:18 UTC (rev 15774)
@@ -7,35 +7,55 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.util;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.proxy.VpeProxyUtil;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class SourceDomUtil {
- static public Node getAncestorNode(Node sourceNode, String tagName){
- if(tagName == null)return null;
+ private static final Set<String> templatesNamespacesWithRendered=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$
+ }
+
+ static public Node getAncestorNode(Node sourceNode, String tagName) {
+ if (tagName == null)
+ return null;
Node element = sourceNode;
- while(true){
- if(tagName.equalsIgnoreCase(element.getNodeName())) return element;
+ while (true) {
+ if (tagName.equalsIgnoreCase(element.getNodeName()))
+ return element;
element = element.getParentNode();
- if(element == null) break;
+ if (element == null)
+ break;
}
return null;
}
-
-
- /** Finds first n-th parent of <code>sourceNode</code> that has
- * a linked non-null nodeMaping in <code>domMapping</code>.
+
+ /**
+ * Finds first n-th parent of <code>sourceNode</code> that has a linked
+ * non-null nodeMaping in <code>domMapping</code>.
*
- * @param domMapping
+ * @param domMapping
* @param sourceNode
- * @return first n-th parent of <code>sourceNode</code> that has
- * a linked non-null nodeMaping in <code>domMapping</code>
- * or <code>null</code> if there is not any. */
- public static Node getParentHavingDomMapping(final Node sourceNode, final VpeDomMapping
domMapping) {
+ * @return first n-th parent of <code>sourceNode</code> that has a linked
+ * non-null nodeMaping in <code>domMapping</code> or
+ * <code>null</code> if there is not any.
+ */
+ public static Node getParentHavingDomMapping(final Node sourceNode,
+ final VpeDomMapping domMapping) {
VpeNodeMapping nodeMapping = null;
Node parent = sourceNode;
do {
@@ -45,4 +65,30 @@
return parent;
}
+
+ /**
+ * @author mareshkau FIX for JBIDE-4179 check if node have rendered=false
+ * attribute, checks el expresion to
+ * @return true if rendered="false"
+ */
+ public static boolean isRenderedAttrEqFalse(VpePageContext pageContext,
+ Element sourceNode) {
+ boolean result = false;
+ final String attrName = "rendered"; //$NON-NLS-1$
+ Element tempElement = sourceNode;
+ if (sourceNode.hasAttribute(attrName)) {
+ if (ElService.getInstance().isELNode(pageContext, sourceNode)) {
+ tempElement = (Element) VpeProxyUtil
+ .createProxyForELExpressionNode(pageContext, sourceNode);
+ }
+ if ("false".equals(tempElement.getAttribute(attrName))) { //$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$
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
}