# HG changeset patch # User Eugene Ostroukhov # Date 1282263513 25200 # Node ID 4d198a32ac7dc8ceb711781794869a806ebcd095 # Parent a05c6e5cc7d9abe6ede68dbb457666e05331c233 Debug is now compiling diff -r a05c6e5cc7d9 -r 4d198a32ac7d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WebApplicationSourceLocator.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WebApplicationSourceLocator.java Thu Aug 19 16:13:44 2010 -0700 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WebApplicationSourceLocator.java Thu Aug 19 17:18:33 2010 -0700 @@ -129,7 +129,7 @@ return resource; } else { File file = PreviewerPlugin.getDefault().getHttpPreviewer().getLocalFile(script.getName()); - if (file != null) { + if (file != null) { try { return EFS.getStore(file.toURI()); } catch (CoreException e) { diff -r a05c6e5cc7d9 -r 4d198a32ac7d org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Thu Aug 19 16:13:44 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Thu Aug 19 17:18:33 2010 -0700 @@ -18,6 +18,7 @@ Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.symbian.tools.tmw.previewer.core, + org.symbian.tools.tmw.previewer.internal, org.symbian.tools.wrttools.previewer, org.symbian.tools.wrttools.previewer.http Import-Package: javax.servlet;version="2.5.0", diff -r a05c6e5cc7d9 -r 4d198a32ac7d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java Thu Aug 19 16:13:44 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/HttpPreviewer.java Thu Aug 19 17:18:33 2010 -0700 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.symbian.tools.wrttools.previewer.http; +import java.io.File; import java.net.URI; import org.eclipse.core.resources.IFile; @@ -43,4 +44,8 @@ return WebAppInterface.getInstance().prepareDebugger(project, listener); } } + + public File getLocalFile(String name) { + return WorkspaceResourcesServlet.getPreviewerResource(name); + } } diff -r a05c6e5cc7d9 -r 4d198a32ac7d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Thu Aug 19 16:13:44 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Thu Aug 19 17:18:33 2010 -0700 @@ -18,6 +18,7 @@ *******************************************************************************/ package org.symbian.tools.wrttools.previewer.http; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -43,6 +44,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.json.simple.JSONObject; @@ -52,6 +54,7 @@ import org.symbian.tools.wrttools.previewer.PreviewerException; import org.symbian.tools.wrttools.previewer.PreviewerPlugin; import org.symbian.tools.wrttools.previewer.http.handlers.DebuggerResourceProvider; +import org.symbian.tools.wrttools.previewer.http.handlers.PreviewerStaticResourceProvider; import org.symbian.tools.wrttools.previewer.http.handlers.Providers; public class WorkspaceResourcesServlet extends HttpServlet { @@ -97,26 +100,37 @@ } public static IFile getFileFromUrl(String name) { + final IPath path = getResourcePath(name); + if (path != null) { + final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); + final IApplicationLayoutProvider provider = PreviewerPlugin.getExtensionsManager().getLayoutProvider( + project); + if (provider != null) { + try { + return provider.getWorkspaceFile(project, path.removeFirstSegments(1)); + } catch (CoreException e) { + PreviewerPlugin.log(e); + } + } + } + return null; + } + + private static IPath getResourcePath(String name) { + IPath p = null; try { String root = getHttpUrl(null); if (name != null && name.startsWith(root)) { final String fileName = URLDecoder.decode(name.substring(root.length()), "UTF-8"); final IPath path = new Path(fileName); if (path.segmentCount() > 1) { - final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); - final IApplicationLayoutProvider provider = PreviewerPlugin.getExtensionsManager() - .getLayoutProvider(project); - if (provider != null) { - return provider.getWorkspaceFile(project, path.removeFirstSegments(1)); - } + p = path; } } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); - } catch (CoreException e) { - PreviewerPlugin.log(e); } - return null; + return p; } public static String getHttpUrl(IFile file) { @@ -144,6 +158,32 @@ } } + public static File getPreviewerResource(String name) { + try { + IPath path = getResourcePath(name); + if (path != null && path.segmentCount() > 1) { + if (path.segmentCount() == 2 && HttpPreviewer.PREVIEW_STARTING_PAGE.equals(path.segment(1))) { + path = new Path(PreviewerStaticResourceProvider.PREVIEW_START); + } else if (path.segmentCount() > 2 + && PreviewerStaticResourceProvider.PREVIEW_PATH.equals(path.segment(1))) { + path = path.removeFirstSegments(1); + } else { + return null; + } + URL pluginResource = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), path, null); + if (pluginResource != null) { + URL url = FileLocator.toFileURL(pluginResource); + if (url != null) { + return new File(url.getPath()); + } + } + } + } catch (IOException e) { + PreviewerPlugin.log(e); + } + return null; + } + public static URI getPreviewerStartingPage(String widget) { return getServerURIForResource(new Path(widget).append(HttpPreviewer.PREVIEW_STARTING_PAGE).makeAbsolute(), null);