Author: dvinnichek
Date: 2011-01-31 06:38:23 -0500 (Mon, 31 Jan 2011)
New Revision: 28748
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
Log:
added replacement of #{request.contextPath} el expression
(
https://issues.jboss.org/browse/JBIDE-8257)
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2011-01-31
11:07:31 UTC (rev 28747)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2011-01-31
11:38:23 UTC (rev 28748)
@@ -186,7 +186,7 @@
if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file)))
|| isInResourcesBundle(pageContext, sourceNode)){
rst = true;
- }else if(Jsf2ResourceUtil.isContainJSFExternalContextPath(sourceNode)){
+ }else if(Jsf2ResourceUtil.isContainJSFContextPath(sourceNode)){
rst = true;
}if(Jsf2ResourceUtil.isContainJSF2ResourceAttributes(sourceNode)) {
//added by Maksim Areshkau, see JBIDE-4812
@@ -392,6 +392,10 @@
rst = Jsf2ResourceUtil.processExternalContextPath(value);
}
+ if(Jsf2ResourceUtil.isRequestContextPathString(value)){
+ rst = Jsf2ResourceUtil.processRequestContextPath(value);
+ }
+
if(Jsf2ResourceUtil.isJSF2ResourceString(rst)){
rst = Jsf2ResourceUtil.processCustomJSFAttributes(pageContext, rst);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2011-01-31
11:07:31 UTC (rev 28747)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/Jsf2ResourceUtil.java 2011-01-31
11:38:23 UTC (rev 28748)
@@ -25,24 +25,34 @@
* @author mareshkau
*/
public class Jsf2ResourceUtil {
+
private static final Pattern resourcePatternWithSinglCoat = Pattern
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*'(.*)'\\s*\\]\\s*\\}");
//$NON-NLS-1$
private static final Pattern resourcePatternWithDoableCoat = Pattern
.compile("[#\\$]\\{\\s*resource\\s*\\[\\s*\"(.*)\"\\s*\\]\\s*\\}");
//$NON-NLS-1$
private static final Pattern jsfExternalContextPath = Pattern
.compile("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}");
//$NON-NLS-1$
+ private static final Pattern jsfRequestContextPath = Pattern
+ .compile("^\\s*(\\#|\\$)\\{request.contextPath\\}"); //$NON-NLS-1$
+
/**
- * Check if node contains attributes like this
src="#{facesContext.externalContext.requestContextPath}/images/sample.gif"
+ * Check if node contains attributes like this src=
+ * "#{facesContext.externalContext.requestContextPath}/images/sample.gif"
+ * or like #{request.contextPath}/css/style.css
+ *
* @param sourceNode
- * @return true if node contains
#{facesContext.externalContext.requestContextPath}/images/sample.gif
+ * @return true if node contains
+ * #{facesContext.externalContext.requestContextPath}/images/sample.gif
+ * or #{request.contextPath}/css/style.css
* @author mareshkau, fix for
https://jira.jboss.org/jira/browse/JBIDE-5985
*/
- public static boolean isContainJSFExternalContextPath(Node sourceNode) {
+ public static boolean isContainJSFContextPath(Node sourceNode) {
boolean result = false;
if (sourceNode.getNodeType() == Node.TEXT_NODE) {
String textValue = sourceNode.getNodeValue();
if (textValue != null) {
- if (Jsf2ResourceUtil.isExternalContextPathString(textValue)) {
+ if (Jsf2ResourceUtil.isExternalContextPathString(textValue) ||
+ Jsf2ResourceUtil.isRequestContextPathString(textValue)) {
result = true;
}
}
@@ -50,17 +60,19 @@
final NamedNodeMap nodeMap = sourceNode.getAttributes();
if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
for (int i = 0; i < nodeMap.getLength(); i++) {
- if (Jsf2ResourceUtil
- .isExternalContextPathString(((Attr) nodeMap
- .item(i)).getValue())) {
+ Attr nodeAttr = (Attr) nodeMap.item(i);
+ String attrValue = nodeAttr.getValue();
+ if (Jsf2ResourceUtil.isExternalContextPathString(attrValue)
+ || Jsf2ResourceUtil
+ .isRequestContextPathString(attrValue)) {
result = true;
-
}
}
}
}
return result;
}
+
/**
* Checks string for jsf declaration
* @param attributeValue
@@ -76,6 +88,17 @@
}
return result;
}
+
+ /**
+ * Checks string for request.contextPath declaration
+ * @param attributeValue
+ * @return true if string contains #{request.contextPath}
+ */
+ public static boolean isRequestContextPathString(String attributeValue) {
+ Matcher requestContextPathMatcher = jsfRequestContextPath
+ .matcher(attributeValue);
+ return requestContextPathMatcher.find();
+ }
/**
* Checks is node contained jsf attributes declaration
@@ -150,6 +173,7 @@
}
return result;
}
+
/**
* Replaced
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}" with
""
* @param value
@@ -158,4 +182,13 @@
public static String processExternalContextPath(String value) {
return
value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ /**
+ * Replaced "^\\s*(\\#|\\$)\\{request.contextPath\\}" with ""
+ * @param value
+ * @return value with replaced "^\\s*(\\#|\\$)\\{request.contextPath\\}"
+ */
+ public static String processRequestContextPath(String value) {
+ return value.replaceFirst(jsfRequestContextPath.pattern(), "");
//$NON-NLS-1$
+ }
}