From jbosstools-commits at lists.jboss.org Mon Mar 15 09:11:03 2010 Content-Type: multipart/mixed; boundary="===============8497551137933516216==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r20823 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5985 and 4 other directories. Date: Mon, 15 Mar 2010 09:11:03 -0400 Message-ID: <201003151311.o2FDB3SO032619@svn01.web.mwc.hst.phx2.redhat.com> --===============8497551137933516216== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: mareshkau Date: 2010-03-15 09:11:02 -0400 (Mon, 15 Mar 2010) New Revision: 20823 Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebC= ontent/pages/JBIDE/5985/ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebC= ontent/pages/JBIDE/5985/testFacesContextResolution.jsp trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebC= ontent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf= /vpe/jsf/test/jbide/TestContextPathResolution.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/tem= plate/expression/VpeFunctionHref.java trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/tem= plate/expression/VpeFunctionSrc.java trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/uti= l/ElService.java trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/uti= l/Jsf2ResourceUtil.java Log: https://jira.jboss.org/jira/browse/JBIDE-5985 Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/= WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/Web= Content/pages/JBIDE/5985/testFacesContextResolution.jsp = (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/Web= Content/pages/JBIDE/5985/testFacesContextResolution.jsp 2010-03-15 13:11:02= UTC (rev 20823) @@ -0,0 +1,16 @@ +<%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f" %> +<%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h" %> + + + + + + Input User Name Page + + + + + + + + Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/= WebContent/pages/JBIDE/5985/testFacesContextResolution.jsp.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/Web= Content/pages/JBIDE/5985/testFacesContextResolution.jsp.xml = (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/Web= Content/pages/JBIDE/5985/testFacesContextResolution.jsp.xml 2010-03-15 13:1= 1:02 UTC (rev 20823) @@ -0,0 +1,14 @@ + + + + + + +
+
+ + +
+
+
+
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/to= ols/jsf/vpe/jsf/test/JsfAllTests.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2010-03-15 04:46:19 UTC (rev 20822) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/JsfAllTests.java 2010-03-15 13:11:02 UTC (rev 20823) @@ -91,6 +91,7 @@ import org.jboss.tools.jsf.vpe.jsf.test.jbide.SelectAllAndCut_JBIDE4853; import org.jboss.tools.jsf.vpe.jsf.test.jbide.SelectWholeElement_JBIDE4713; import org.jboss.tools.jsf.vpe.jsf.test.jbide.TaglibXMLUnformatedDTD_JBIDE= 5642; +import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestContextPathResolution; import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestFViewLocaleAttribute_JBI= DE5218; import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestForUsingComponentsLibrar= iesWithDefaultNamespace; import org.jboss.tools.jsf.vpe.jsf.test.jbide.TestOpenOnForXhtmlFiles_JBID= E5577; @@ -121,6 +122,7 @@ = TestSuite suite =3D new TestSuite("Tests for Vpe Jsf components"); //$NO= N-NLS-1$ // $JUnit-BEGIN$ + suite.addTestSuite(TestContextPathResolution.class); suite.addTestSuite(JBIDE5920Test.class); suite.addTestSuite(RenderFacetAndInsertChildrenTest.class); suite.addTestSuite(EditFontFamilyTest_JBIDE5872.class); Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools= /jsf/vpe/jsf/test/jbide/TestContextPathResolution.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/TestContextPathResolution.java = (rev 0) +++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/js= f/vpe/jsf/test/jbide/TestContextPathResolution.java 2010-03-15 13:11:02 UTC= (rev 20823) @@ -0,0 +1,36 @@ +/*************************************************************************= ****** + * Copyright (c) 2007-2010 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 org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests; +import org.jboss.tools.vpe.ui.test.ComponentContentTest; + +/** + * https://jira.jboss.org/jira/browse/JBIDE-5985 = + * = + * @author mareshkau + * + */ +public class TestContextPathResolution extends ComponentContentTest{ + + public TestContextPathResolution(String name) { + super(name); + } + = + public void testContextPathResolution() throws Throwable{ + performContentTest("JBIDE/5985/testFacesContextResolution.jsp"); //$NON-= NLS-1$ + } + + @Override + protected String getTestProjectName() { + return JsfAllTests.IMPORT_JSF_20_PROJECT_NAME; + } +} Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/template/expression/VpeFunctionHref.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/te= mplate/expression/VpeFunctionHref.java 2010-03-15 04:46:19 UTC (rev 20822) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/te= mplate/expression/VpeFunctionHref.java 2010-03-15 13:11:02 UTC (rev 20823) @@ -36,7 +36,7 @@ public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws = VpeExpressionException { String tagValue =3D getParameter(0).exec(pageContext, sourceNode).stringV= alue(); = - tagValue =3D resolveEL(pageContext,tagValue); + //tagValue =3D resolveEL(pageContext,tagValue); = IPath tagPath =3D new Path(tagValue); if (tagPath.isEmpty()) { Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/template/expression/VpeFunctionSrc.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/te= mplate/expression/VpeFunctionSrc.java 2010-03-15 04:46:19 UTC (rev 20822) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/te= mplate/expression/VpeFunctionSrc.java 2010-03-15 13:11:02 UTC (rev 20823) @@ -52,7 +52,7 @@ public VpeValue exec(VpePageContext pageContext, Node sourceNode) thro= ws VpeExpressionException { String tagValue =3D getParameter(0).exec(pageContext, sourceNode) .stringValue(); - tagValue =3D resolveEL(pageContext,tagValue); +// tagValue =3D resolveEL(pageContext,tagValue); IFile iFile =3D VpeCreatorUtil.getFile(tagValue, pageContext); = if (iFile !=3D null) { @@ -251,24 +251,24 @@ * temporary solution to solve #{facesContext.externalContext.requestC= ontextPath} * JBIDE-1410 */ - protected String resolveEL(VpePageContext pageContext, String value) { - String resolvedValue =3D value.replaceFirst("^\\s*(\\#|\\$)\\{face= sContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-= NLS-2$ - = - //fix for JBIDE-2550, author Maksim Areshkau - if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){ - resolvedValue =3D Jsf2ResourceUtil.processCustomJSFAttributes(pag= eContext, resolvedValue); - } - - //Fix for JBIDE-3030 - if(pageContext.getVisualBuilder().getCurrentIncludeInfo()=3D=3Dnull - || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() inst= anceof IFile)){ - return resolvedValue; - } - final IFile file =3D (IFile) pageContext.getVisualBuilder().getCur= rentIncludeInfo().getStorage(); - - resolvedValue =3D ElService.getInstance().replaceEl(file, resolved= Value); - return resolvedValue; - } +// protected String resolveEL(VpePageContext pageContext, String value)= { +// String resolvedValue =3D value.replaceFirst("^\\s*(\\#|\\$)\\{fa= cesContext.externalContext.requestContextPath\\}", ""); //$NON-NLS-1$ //$NO= N-NLS-2$ +// = +// //fix for JBIDE-2550, author Maksim Areshkau +// if(Jsf2ResourceUtil.isJSF2ResourceString(resolvedValue)){ +// resolvedValue =3D Jsf2ResourceUtil.processCustomJSFAttributes(p= ageContext, resolvedValue); +// } +// +// //Fix for JBIDE-3030 +// if(pageContext.getVisualBuilder().getCurrentIncludeInfo()=3D=3Dn= ull +// || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() in= stanceof IFile)){ +// return resolvedValue; +// } +// final IFile file =3D (IFile) pageContext.getVisualBuilder().getC= urrentIncludeInfo().getStorage(); +// +// resolvedValue =3D ElService.getInstance().replaceEl(file, resolv= edValue); +// return resolvedValue; +// } = public static String getAbsoluteResourcePath(String resourcePathInPlug= in) { String pluginPath =3D VpePlugin.getPluginResourcePath(); Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/util/ElService.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/ElService.java 2010-03-15 04:46:19 UTC (rev 20822) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/ElService.java 2010-03-15 13:11:02 UTC (rev 20823) @@ -186,7 +186,9 @@ if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode= , file))) = || isInResourcesBundle(pageContext, sourceNode)){ rst =3D true; - }else if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNo= de)) { + }else if(Jsf2ResourceUtil.isContainJSFExternalContextPath(sourceNo= de)){ + rst =3D true; + }if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) { //added by Maksim Areshkau, see JBIDE-4812 rst =3D true; } @@ -386,6 +388,10 @@ //replace custom attributes rst =3D replaceCustomAttributes(pageContext,rst); = + if(Jsf2ResourceUtil.isExternalContextPathString(value)){ + rst =3D Jsf2ResourceUtil.processExternalContextPath(value); + } + = if(Jsf2ResourceUtil.isJSF2ResourceString(rst)){ rst =3D Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, = rst); } Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/edi= tor/util/Jsf2ResourceUtil.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/Jsf2ResourceUtil.java 2010-03-15 04:46:19 UTC (rev 20822) +++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/ut= il/Jsf2ResourceUtil.java 2010-03-15 13:11:02 UTC (rev 20823) @@ -29,12 +29,60 @@ .compile("[#\\$]\\{\\s*resource\\s*\\[\\s*'(.*)'\\s*\\]\\s*\\}"); //$NO= N-NLS-1$ private static final Pattern resourcePatternWithDoableCoat =3D Pattern .compile("[#\\$]\\{\\s*resource\\s*\\[\\s*\"(.*)\"\\s*\\]\\s*\\}"); //$= NON-NLS-1$ + private static final Pattern jsfExternalContextPath =3D Pattern + .compile("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextP= ath\\}"); //$NON-NLS-1$ + /** + * Check if node contains attributes like this src=3D"#{facesContext.exte= rnalContext.requestContextPath}/images/sample.gif" + * @param sourceNode + * @return true if node contains #{facesContext.externalContext.requestCo= ntextPath}/images/sample.gif + * @author mareshkau, fix for https://jira.jboss.org/jira/browse/JBIDE-59= 85 + */ + public static boolean isContainJSFExternalContextPath(Node sourceNode) { + boolean result =3D false; + if (sourceNode.getNodeType() =3D=3D Node.TEXT_NODE) { + String textValue =3D sourceNode.getNodeValue(); + if (textValue !=3D null) { + if (Jsf2ResourceUtil.isExternalContextPathString(textValue)) { + result =3D true; + } + } + } else { + final NamedNodeMap nodeMap =3D sourceNode.getAttributes(); + if ((nodeMap !=3D null) && (nodeMap.getLength() > 0)) { + for (int i =3D 0; i < nodeMap.getLength(); i++) { + if (Jsf2ResourceUtil + .isExternalContextPathString(((Attr) nodeMap + .item(i)).getValue())) { + result =3D true; = + } + } + } + } + return result; + } /** + * Checks string for jsf declaration + * @param attributeValue + * @return true is string contains #{facesContext.externalContext.request= ContextPath} + * @author mareshkau, fix for https://jira.jboss.org/jira/browse/JBIDE-59= 85 + */ + public static boolean isExternalContextPathString(String attributeValue) { + Matcher externalContextPathMatcher =3D jsfExternalContextPath + .matcher(attributeValue); + boolean result =3D false; + if (externalContextPathMatcher.find()) { + result =3D true; + } + return result; + } + + /** * Checks is node contained jsf attributes declaration + * = * @param sourceNode - * @return true if node has #{resource[...]} declarations - * false otherwise + * @return true if node has #{resource[...]} declarations false otherwise + * @author mareshkau */ public static boolean isContainJSF2ResourceAttributes(Node sourceNode) { boolean result =3D false; @@ -59,25 +107,31 @@ } return result; } + /** * Replaces custom jsf attribute with attribute from VPE + * = * @param pageContext * @param value * @return */ - public static final String processCustomJSFAttributes(VpePageContext p= ageContext, String value){ - String result =3Dnull; - //fix for JBIDE-2550, author Maksim Areshkau - Matcher singleCoatMatcher =3D resourcePatternWithSinglCoat.matcher= (value); - Matcher doubleCoatMatcher =3D resourcePatternWithDoableCoat.matche= r(value); - if(doubleCoatMatcher.find()) { - result =3D FileUtil.getJSF2ResourcePath(pageContext, doubleCoatMa= tcher.group(1)); = - }else if(singleCoatMatcher.find()){ - result =3D FileUtil.getJSF2ResourcePath(pageContext, singleCoatM= atcher.group(1)); - } + public static final String processCustomJSFAttributes( + VpePageContext pageContext, String value) { + String result =3D null; + // fix for JBIDE-2550, author Maksim Areshkau + Matcher singleCoatMatcher =3D resourcePatternWithSinglCoat.matcher(value= ); + Matcher doubleCoatMatcher =3D resourcePatternWithDoableCoat + .matcher(value); + if (doubleCoatMatcher.find()) { + result =3D FileUtil.getJSF2ResourcePath(pageContext, + doubleCoatMatcher.group(1)); + } else if (singleCoatMatcher.find()) { + result =3D FileUtil.getJSF2ResourcePath(pageContext, + singleCoatMatcher.group(1)); + } = - return result; - } + return result; + } = /** * Checks if string is jsf 2 resource @@ -96,4 +150,12 @@ } return result; } + /** + * Replaced "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContext= Path\\}" with "" + * @param value + * @return replaced "^\\s*(\\#|\\$)\\{facesContext.externalContext.reques= tContextPath\\}" with "" + */ + public static String processExternalContextPath(String value) { + return value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext= .requestContextPath\\}", ""); //$NON-NLS-1$ //$NON-NLS-2$ + } } --===============8497551137933516216==--