--- a/org.symbian.tools.wrttools.debug.core/META-INF/MANIFEST.MF Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools.debug.core/META-INF/MANIFEST.MF Tue Feb 09 15:52:35 2010 -0800
@@ -21,7 +21,8 @@
org.eclipse.ui.ide;bundle-version="3.5.0",
org.eclipse.wst.sse.ui;bundle-version="1.1.100",
org.eclipse.wst.sse.core;bundle-version="1.1.400",
- org.eclipse.wst.html.core;bundle-version="1.1.300"
+ org.eclipse.wst.html.core;bundle-version="1.1.300",
+ org.eclipse.wst.jsdt.core;bundle-version="1.0.201"
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
Bundle-ActivationPolicy: lazy
--- a/org.symbian.tools.wrttools.debug.core/plugin.xml Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools.debug.core/plugin.xml Tue Feb 09 15:52:35 2010 -0800
@@ -207,5 +207,18 @@
</provider>
</breakpointContribution>
</extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ class="org.symbian.tools.wrttools.debug.internal.property.LaunchableFactory"
+ adaptableType="org.eclipse.wst.jsdt.core.IJavaScriptElement">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+ <factory
+ class="org.symbian.tools.wrttools.debug.internal.property.LaunchableFactory"
+ adaptableType="org.eclipse.core.resources.IResource">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+ </extension>
</plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/property/LaunchableFactory.java Tue Feb 09 15:52:35 2010 -0800
@@ -0,0 +1,17 @@
+package org.symbian.tools.wrttools.debug.internal.property;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+
+public class LaunchableFactory implements IAdapterFactory {
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ // It is only needed to exist
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ // It is only needed to exist
+ return null;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/.options Tue Feb 09 15:52:35 2010 -0800
@@ -0,0 +1,3 @@
+org.symbian.tools.wrttools.previewer/debug=false
+org.symbian.tools.wrttools.previewer/servlet=false
+org.symbian.tools.wrttools.previewer/mapping=false
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Tue Feb 09 15:52:35 2010 -0800
@@ -20,6 +20,7 @@
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
@@ -36,17 +37,20 @@
// The plug-in ID
public static final String PLUGIN_ID = "org.symbian.tools.wrttools.previewer";
+ public static final boolean DEBUG = Platform.inDebugMode()
+ && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID + "/debug"));
+ public static final boolean TRACE_SERVLET = DEBUG
+ && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID
+ + "/servlet"));
+ public static final boolean TRACE_MAPPING = DEBUG
+ && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID
+ + "/mapping"));
+
// The shared instance
private static PreviewerPlugin plugin;
private HttpPreviewer previewer = new HttpPreviewer();
- /**
- * The constructor
- */
- public PreviewerPlugin() {
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Tue Feb 09 15:52:35 2010 -0800
@@ -28,6 +28,7 @@
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.text.MessageFormat;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -50,7 +51,6 @@
public class WorkspaceResourcesServlet extends HttpServlet {
private static final String PREVIEW_START = "/preview/wrt_preview.html";
- private static final String METADATA_FILE = "Info.plist";
private static final String PREVIEW_PATH = "preview";
private static final String STARTING_PAGE = "preview-frame.html";
private static final String INDEX_PAGE = "wrt_preview_main.html";
@@ -62,6 +62,10 @@
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
+ long time = 0;
+ if (PreviewerPlugin.TRACE_SERVLET) {
+ time = System.currentTimeMillis();
+ }
IPath path = new Path(req.getPathInfo());
InputStream contents = null;
try {
@@ -81,6 +85,11 @@
contents.close();
}
}
+ if (PreviewerPlugin.TRACE_SERVLET) {
+ System.out.println(MessageFormat.format(
+ "Resource {0} was downloaded in {1}", req.getPathInfo(),
+ System.currentTimeMillis() - time));
+ }
}
private InputStream getSpecialResource(IPath path) throws IOException,
@@ -104,9 +113,10 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
projectName);
if (project.isAccessible()) {
- String indexFileName = CoreUtil.getIndexFileName(CoreUtil.readFile(project, METADATA_FILE));
+ String indexFileName = CoreUtil.getIndexFile(project);
if (indexFileName != null) {
- String string = CoreUtil.readFile(project, indexFileName);
+ String string = CoreUtil.readFile(project, CoreUtil.getFile(
+ project, indexFileName));
if (string != null) {
Matcher matcher = HEAD_TAG_PATTERN.matcher(string);
if (matcher.find()) {
@@ -165,8 +175,7 @@
.getProject(p.segment(0));
try {
if (p.removeFirstSegments(1).toString().equals(
- CoreUtil.getIndexFileName(CoreUtil.readFile(project,
- METADATA_FILE)))) {
+ CoreUtil.getIndexFile(project))) {
return getServerURIForResource(new Path(p.segment(0))
.append(INDEX_PAGE).makeAbsolute().toString());
}
@@ -232,15 +241,13 @@
path = new Path(fileName);
if (path.segmentCount() == 2 && INDEX_PAGE.equals(path.lastSegment())) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
- path = new Path(project.getName()).append(CoreUtil.getIndexFileName(CoreUtil.readFile(project, METADATA_FILE)));
+ path = new Path(project.getName()).append(CoreUtil.getIndexFile(project));
}
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
} catch (CoreException e) {
PreviewerPlugin.log(e);
- } catch (IOException e) {
- PreviewerPlugin.log(e);
}
return path;
}
--- a/org.symbian.tools.wrttools/plugin.xml Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools/plugin.xml Tue Feb 09 15:52:35 2010 -0800
@@ -399,23 +399,6 @@
</or>
</possibleChildren>
<actionProvider
- class="org.eclipse.wst.jsdt.internal.ui.navigator.JavaNavigatorViewActionProvider"
- id="org.eclipse.wst.jsdt.ui.navigator.actions.ViewActions">
- <enablement>
- <or>
- <instanceof
- value="org.eclipse.core.resources.IWorkspaceRoot">
- </instanceof>
- <adapt
- type="java.util.Collection">
- <count
- value="0">
- </count>
- </adapt>
- </or>
- </enablement>
- </actionProvider>
- <actionProvider
class="org.eclipse.wst.jsdt.internal.ui.navigator.JavaNavigatorActionProvider"
id="org.eclipse.wst.jsdt.ui.navigator.actions.StandardActions">
<!-- <enablement>
@@ -450,35 +433,8 @@
<actionProvider
class="org.eclipse.wst.jsdt.internal.ui.navigator.JavaNavigatorRefactorActionProvider"
id="org.eclipse.wst.jsdt.ui.navigator.actions.RefactorActions"
- overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions">
- <enablement>
- <or>
- <and>
- <instanceof
- value="org.eclipse.core.resources.IProject">
- </instanceof>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.symbian.tools.wrttools.WidgetProjectNature">
- </test>
- </and>
- <instanceof
- value="org.eclipse.wst.jsdt.core.IJavaScriptElement">
- </instanceof>
- <instanceof
- value="org.eclipse.wst.jsdt.core.IJarEntryResource">
- </instanceof>
- <instanceof
- value="org.eclipse.wst.jsdt.internal.ui.packageview.PackageFragmentRootContainer">
- </instanceof>
- <adapt
- type="java.util.Collection">
- <count
- value="0">
- </count>
- </adapt>
- </or>
- </enablement>
+ overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions"
+ priority="high">
</actionProvider>
<actionProvider
class="org.eclipse.wst.jsdt.internal.ui.navigator.PackageExplorerOpenActionProvider"
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java Tue Feb 09 13:35:06 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java Tue Feb 09 15:52:35 2010 -0800
@@ -4,8 +4,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -13,11 +14,15 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
+import org.symbian.tools.wrttools.Activator;
public class CoreUtil {
+ public static final String METADATA_FILE = "Info.plist";
public static final String PROPERTY_PATTERN = "<key>\\s*{0}\\s*</key>\\s*<string>\\s*(.*)\\s*</string>";
public static boolean isWindows() {
@@ -68,25 +73,57 @@
return null;
}
- public static String readFile(IProject project, String fileName)
- throws CoreException, UnsupportedEncodingException, IOException {
- IFile file = getFile(project, fileName);
- if (file.isAccessible()) {
- InputStream contents = file.getContents();
- final BufferedReader reader = new BufferedReader(
- new InputStreamReader(contents, file.getCharset()));
- StringBuffer buffer = new StringBuffer();
- try {
- int c = 0;
- char[] buf = new char[4096];
- while ((c = reader.read(buf)) > 0) {
- buffer.append(buf, 0, c);
+ public static String readFile(IProject project, IFile file)
+ throws CoreException {
+ try {
+ if (file.isAccessible()) {
+ InputStream contents = file.getContents();
+ final BufferedReader reader = new BufferedReader(
+ new InputStreamReader(contents, file.getCharset()));
+ StringBuffer buffer = new StringBuffer();
+ try {
+ int c = 0;
+ char[] buf = new char[4096];
+ while ((c = reader.read(buf)) > 0) {
+ buffer.append(buf, 0, c);
+ }
+ return buffer.toString();
+ } finally {
+ reader.close();
}
- return buffer.toString();
- } finally {
- reader.close();
+ }
+ return null;
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format("Failed to read file {0} in project {1}", file.getName(), project.getName())));
+ }
+ }
+
+ private static final Map<IProject, IndexFileRecord> INDEX_FILES = new HashMap<IProject, IndexFileRecord>();
+
+ public static synchronized String getIndexFile(IProject project) throws CoreException {
+ // There will really be a lot of calls to this method. We need to cache values.
+ IFile file = getFile(project, METADATA_FILE);
+ if (INDEX_FILES.containsKey(project)) {
+ IndexFileRecord record = INDEX_FILES.get(project);
+ if (file == null || !file.isAccessible()) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, MessageFormat.format("No Info.plist for project {0}", project.getName())));
+ }
+ if (record.timeStamp == file.getModificationStamp()) {
+ return record.fileName;
}
}
- return null;
+ String fileName = getIndexFileName(readFile(project, file));
+ INDEX_FILES.put(project, new IndexFileRecord(fileName, file.getModificationStamp()));
+ return fileName;
+ }
+
+ private static class IndexFileRecord {
+ public final String fileName;
+ public final long timeStamp;
+
+ public IndexFileRecord(String fileName, long timeStamp) {
+ this.fileName = fileName;
+ this.timeStamp = timeStamp;
+ }
}
}