Author: dmaliarevich
Date: 2010-07-01 10:17:52 -0400 (Thu, 01 Jul 2010)
New Revision: 23147
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java
Log:
https://jira.jboss.org/browse/JBIDE-6539 , URI parsing for background's
"url" value was corrected, regular expressions were added to test quotes in the
"url".
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2010-07-01
13:02:10 UTC (rev 23146)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2010-07-01
14:17:52 UTC (rev 23147)
@@ -67,6 +67,7 @@
public static final String SPACE_STRING = " "; //$NON-NLS-1$
public static final String EMPTY_STRING = ""; //$NON-NLS-1$
public static final String SINGLE_QUOTE_STRING = "\'"; //$NON-NLS-1$
+ public static final String QUOTE_STRING = "\""; //$NON-NLS-1$
public static String ATTR_URL = "url"; //$NON-NLS-1$
public static String OPEN_BRACKET = "("; //$NON-NLS-1$
@@ -377,6 +378,7 @@
for (int i = 1; i < urls.length; i++) {
urls[i] = urls[i].replace(SINGLE_QUOTE_STRING, EMPTY_STRING);
+ urls[i] = urls[i].replace(QUOTE_STRING, EMPTY_STRING);
urls[i] = ATTR_URL + urls[i];
int startAttr = urls[i].indexOf(ATTR_URL);
@@ -498,6 +500,7 @@
String finalStr = EMPTY_STRING;
for (int i = 1; i < urls.length; i++) {
urls[i] = urls[i].replace(SINGLE_QUOTE_STRING, EMPTY_STRING);
+ urls[i] = urls[i].replace(QUOTE_STRING, EMPTY_STRING);
urls[i] = ATTR_URL + urls[i];
int startAttr = urls[i].indexOf(ATTR_URL);
int startPathIndex = urls[i].indexOf(OPEN_BRACKET, startAttr);
@@ -826,6 +829,7 @@
try {
uri = new URI(resolvedValue);
} catch (URISyntaxException e) {
+ VpePlugin.getDefault().logWarning("Error in parsiong URI string", e);
//$NON-NLS-1$
}
if ((uri != null) && (uri.isAbsolute()))
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java 2010-07-01
13:02:10 UTC (rev 23146)
+++
trunk/vpe/tests/org.jboss.tools.vpe.ui.test/src/org/jboss/tools/vpe/ui/test/TestDomUtil.java 2010-07-01
14:17:52 UTC (rev 23147)
@@ -18,6 +18,7 @@
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -29,7 +30,10 @@
import org.jboss.tools.jst.css.common.CSSStyleManager;
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMAttr;
+import org.mozilla.interfaces.nsIDOMCSSStyleDeclaration;
+import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNamedNodeMap;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
@@ -39,6 +43,8 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.ElementCSSInlineStyle;
/**
* @author Sergey Dzmitrovich
@@ -326,7 +332,23 @@
&& modelString.endsWith(END_REGEX)) {
String regex = modelString.substring(START_REGEX.length(),
modelString.length() - END_REGEX.length());
-
+ int firstPos = regex.indexOf("url\\("); //$NON-NLS-1$
+ if (firstPos > -1) {
+ String subString = regex.substring(firstPos + 5, firstPos + 5 + 2);
+ if (!"\"?".equalsIgnoreCase(subString)) { //$NON-NLS-1$
+ String firstPart = regex.substring(0, firstPos + 5);
+ String secondPart = regex.substring(firstPos + 5, regex.length());
+ int lastPos = secondPart.indexOf("\\)"); //$NON-NLS-1$
+ if (lastPos > -1) {
+ String subs = secondPart.substring(lastPos - 2, lastPos);
+ if (!"\"?".equalsIgnoreCase(subs)) { //$NON-NLS-1$
+ String fpart = secondPart.substring(0, lastPos);
+ String spart = secondPart.substring(lastPos, secondPart.length());
+ regex = firstPart + "\"?" + fpart + "\"?" + spart;
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
Matcher matcher = Pattern.compile(regex).matcher(vpeString);
if (!matcher.find()) {
throw new DOMComparisonException("string is\"" + vpeString
//$NON-NLS-1$