Author: sdzmitrovich
Date: 2009-01-13 13:00:51 -0500 (Tue, 13 Jan 2009)
New Revision: 13017
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.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-3523
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2009-01-13
14:55:24 UTC (rev 13016)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2009-01-13
18:00:51 UTC (rev 13017)
@@ -295,7 +295,7 @@
return Constants.FILE_PREFIX
+ FileUtil.getFile(resolvedValue, file).getLocation()
- .toOSString();
+ .toPortableString();
}
/**
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-13
14:55:24 UTC (rev 13016)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-01-13
18:00:51 UTC (rev 13017)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IEditorInput;
@@ -382,7 +383,12 @@
// }
// filePath = url.toString();
- filePath = getAbsoluteWorkspacePath(filePath, pageContext);
+ IFile file = null;
+ if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
+ file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getFile();
+ if (file != null)
+ filePath = processUrl(filePath, file);
String firstPartValue = urls[i].substring(0, startPathIndex + 1);
String secondPartValue = urls[i].substring(endPathIndex, urls[i]
@@ -488,31 +494,51 @@
String filePath = urls[i].substring(startPathIndex + 1,
endPathIndex);
+ IFile sourceFile = null;
try {
- URL url = new URL(filePath);
- //with url all ok
- continue;
- } catch (MalformedURLException e) {
- //ignore, continue work with url
+ URL url1 = new URL(href_val);
+
+ sourceFile = ResourcesPlugin.getWorkspace().getRoot()
+ .getFileForLocation(new Path( url1.getPath()));
+ } catch (MalformedURLException e1) {
+ // ignore
}
- if (filePath.indexOf(FILE_PROTOCOL) != -1) {
- continue;
- }
+ if (sourceFile != null) {
+
+ filePath = processUrl(filePath, sourceFile);
- if (!new File(filePath).isAbsolute()) {
- filePath = getFilePath(href_val, filePath);
} else {
- filePath = FILE_PROTOCOL + SLASH + SLASH + filePath.replace('\\',
'/');
- }
+
+ //TODO to redesign next code
+ try {
+ URL url = new URL(filePath);
+ // with url all ok
+ continue;
+ } catch (MalformedURLException e) {
+ // ignore, continue work with url
+ }
- URL url = null;
- try {
- url = new URL(filePath);
- } catch (MalformedURLException e) {
- continue;
+ if (filePath.indexOf(FILE_PROTOCOL) != -1) {
+ continue;
+ }
+
+ if (!new File(filePath).isAbsolute()) {
+ filePath = getFilePath(href_val, filePath);
+ } else {
+ filePath = FILE_PROTOCOL + SLASH + SLASH
+ + filePath.replace('\\', '/');
+ }
+
+ URL url = null;
+ try {
+ url = new URL(filePath);
+ } catch (MalformedURLException e) {
+ continue;
+ }
+ filePath = url.toString();
}
- filePath = url.toString();
+
String firstPartValue = urls[i].substring(0, startPathIndex + 1);
String secondPartValue = urls[i].substring(endPathIndex, urls[i]
@@ -748,6 +774,39 @@
return size;
}
+ public static String processUrl(String url, IFile file) {
+
+ String resolvedValue = url
+ .replaceFirst(
+ "^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
Constants.EMPTY); //$NON-NLS-1$
+
+
+
+ resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
+
+ URI uri = null;
+ try {
+ uri = new URI(resolvedValue);
+ } catch (URISyntaxException e) {
+ }
+
+ if ((uri != null) && (uri.isAbsolute()))
+ return resolvedValue;
+
+ Path path = new Path(resolvedValue);
+
+ if (resolvedValue.startsWith("/")
+ && path.segment(0).equals(file.getProject().getName())) {
+ resolvedValue = "/"
+ + path.removeFirstSegments(1).toPortableString();
+
+ }
+
+ return Constants.FILE_PREFIX
+ + FileUtil.getFile(resolvedValue, file).getLocation()
+ .toPortableString();
+ }
+
/**
* Gets the absolute workspace path.
*
@@ -784,6 +843,6 @@
return Constants.FILE_PREFIX
+ FileUtil.getFile(resolvedValue, file).getLocation()
- .toOSString();
+ .toPortableString();
}
}
\ No newline at end of file