Author: sdzmitrovich
Date: 2009-01-08 08:42:00 -0500 (Thu, 08 Jan 2009)
New Revision: 12928
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.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/template/VpeStyleCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3464
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 2009-01-08
13:00:11 UTC (rev 12927)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-01-08
13:42:00 UTC (rev 12928)
@@ -589,7 +589,7 @@
if (styleValue != null) {
styleValue = VpeStyleUtil.addFullPathIntoURLValue(styleValue,
- pageContext.getEditPart().getEditorInput());
+ pageContext);
element.setAttribute(HTML.TAG_STYLE, styleValue);
}
if (backgroundValue != null) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2009-01-08
13:00:11 UTC (rev 12927)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeStyleCreator.java 2009-01-08
13:42:00 UTC (rev 12928)
@@ -35,7 +35,7 @@
String text = null;
if (textNode != null) {
text = textNode.getNodeValue();
- text = VpeStyleUtil.addFullPathIntoURLValue(text,
pageContext.getEditPart().getEditorInput());
+ text = VpeStyleUtil.addFullPathIntoURLValue(text, pageContext);
}
nsIDOMNode newStyle = pageContext.getVisualBuilder()
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 2009-01-08
13:00:11 UTC (rev 12927)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-08
13:42:00 UTC (rev 12928)
@@ -12,6 +12,8 @@
import java.io.File;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
@@ -337,7 +339,7 @@
* @return format style string
*/
public static String addFullPathIntoURLValue(String value,
- IEditorInput input) {
+ VpePageContext pageContext) {
String urls[] = value.split(ATTR_URL);
@@ -363,23 +365,25 @@
String filePath = urls[i].substring(startPathIndex + 1,
endPathIndex);
- if (filePath.indexOf(FILE_PROTOCOL) != -1) {
- continue;
- }
+// if (filePath.indexOf(FILE_PROTOCOL) != -1) {
+// continue;
+// }
+//
+// if (!new File(filePath).isAbsolute()) {
+// filePath = getFilePath(input, filePath);
+// }
+//
+// filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\',
'/');
+// URL url = null;
+// try {
+// url = new URL(filePath);
+// } catch (MalformedURLException e) {
+// continue;
+// }
+// filePath = url.toString();
+
+ filePath = getAbsoluteWorkspacePath(filePath, pageContext);
- if (!new File(filePath).isAbsolute()) {
- filePath = getFilePath(input, filePath);
- }
-
- filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\',
'/');
- URL url = null;
- try {
- url = new URL(filePath);
- } catch (MalformedURLException e) {
- continue;
- }
- filePath = url.toString();
-
String firstPartValue = urls[i].substring(0, startPathIndex + 1);
String secondPartValue = urls[i].substring(endPathIndex, urls[i]
.length());
@@ -743,4 +747,43 @@
return size;
}
+
+ /**
+ * Gets the absolute workspace path.
+ *
+ * @param resourcePathInWorkspace the relative path in workspace
+ *
+ * @return the absolute workspace path
+ */
+ public static String getAbsoluteWorkspacePath(
+ String resourcePathInWorkspace, VpePageContext pageContext) {
+
+ String resolvedValue = resourcePathInWorkspace
+ .replaceFirst(
+ "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
Constants.EMPTY); //$NON-NLS-1$
+
+ IFile file = null;
+ if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
+ file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getFile();
+
+ if (file == null)
+ return resolvedValue;
+
+ resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+
+ URI uri = null;
+ try {
+ uri = new URI(resolvedValue);
+ } catch (URISyntaxException e) {
+ }
+
+ if ((uri != null)
+ && (uri.isAbsolute() || (new File(resolvedValue)).exists()))
+ return resolvedValue;
+
+ return Constants.FILE_PREFIX
+ + FileUtil.getFile(resolvedValue, file).getLocation()
+ .toOSString();
+ }
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2009-01-08
13:00:11 UTC (rev 12927)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2009-01-08
13:42:00 UTC (rev 12928)
@@ -57,8 +57,8 @@
} else {
// all full path for 'url'
if (VpeStyleUtil.ATTRIBUTE_STYLE.equalsIgnoreCase(name))
- value = VpeStyleUtil.addFullPathIntoURLValue(value, pageContext
- .getEditPart().getEditorInput());
+ value = VpeStyleUtil.addFullPathIntoURLValue(value,
+ pageContext);
if (VpeStyleUtil.PARAMETR_BACKGROND.equalsIgnoreCase(name))
value = VpeStyleUtil.addFullPathIntoBackgroundValue(value,
pageContext.getEditPart().getEditorInput());