--- a/org.symbian.tools.wrttools.previewer/plugin.xml Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools.previewer/plugin.xml Tue Feb 02 13:53:56 2010 -0800
@@ -5,6 +5,7 @@
point="org.eclipse.ui.views">
<view
allowMultiple="false"
+ category="org.symbian.tools.wrttools.views"
class="org.symbian.tools.wrttools.previewer.preview.PreviewView"
icon="icons/obj16/html-editor.gif"
id="org.symbian.tools.wrttools.editing.wrtpreview"
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Tue Feb 02 13:53:56 2010 -0800
@@ -7,7 +7,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.URL;
import java.util.Collection;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -24,6 +26,8 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -35,9 +39,9 @@
import org.eclipse.ui.part.MessagePage;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.PageBookView;
-import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+import org.osgi.framework.Bundle;
import org.symbian.tools.wrttools.previewer.IWrtEditingPreferences;
-import org.symbian.tools.wrttools.util.CoreUtil;
+import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
import org.symbian.tools.wrttools.util.ProjectUtils;
public class PreviewView extends PageBookView {
@@ -88,6 +92,14 @@
@Override
public void createPartControl(Composite parent) {
+ Bundle bundle = Platform.getBundle("org.eclipse.wst.sse.ui");
+ Enumeration findEntries = bundle.findEntries("/icons/full/", "*", true);
+ URL resolved;
+ try {
+ resolved = FileLocator.resolve((URL) findEntries.nextElement());
+ System.out.println(resolved);
+ } catch (IOException e) {
+ }
super.createPartControl(parent);
ResourcesPlugin.getWorkspace().addResourceChangeListener(
resourceListener);
--- a/org.symbian.tools.wrttools/plugin.xml Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools/plugin.xml Tue Feb 02 13:53:56 2010 -0800
@@ -208,42 +208,45 @@
</description>
</projectTemplate>
<projectTemplate
+ name="Basic WRT Project with WRTKit Support"
archive="projecttemplates/wrtkit.zip"
default-css-name="basic"
default-html-name="index"
default-js-name="basic"
icon="icons/main16.gif"
- id-pattern="com.{0}.basic.widget"
- name="Basic WRT Project with WRTKit Support">
+ id-pattern="com.{0}.basic.widget">
<description>
This wizard generates an basic project with a minimal Info.plist, html,css and js along with WRTKit.
</description>
+ <requires-library>org.symbian.wrtkit</requires-library>
</projectTemplate>
<projectTemplate
+ name="Flickr Application Project"
archive="projecttemplates/flickr.zip"
default-css-name="Flickr"
default-html-name="index"
default-js-name="Flickr"
icon="icons/flickr.gif"
id-pattern="com.{0}.flickr.widget"
- name="Flickr Application Project"
wizard-page-factory="org.symbian.tools.wrttools.wizards.FlickrProjectDetailsWizardPage$Factory">
<description>
This wizard generates an Flickr project with a minimal Info.plist, html,css and js and WRTKit.
</description>
+ <requires-library>org.symbian.wrtkit</requires-library>
</projectTemplate>
<projectTemplate
+ name="RSS Reader Application Project"
archive="projecttemplates/rssreader.zip"
default-css-name="RSSReader"
default-html-name="index"
default-js-name="RSSReader"
icon="icons/rss.gif"
id-pattern="com.{0}.rssreader.widget"
- name="RSS Reader Application Project"
wizard-page-factory="org.symbian.tools.wrttools.wizards.RssReaderProjectDetailsWizardPage$Factory">
<description>
This wizard generates an RSS Reader project with a minimal Info.plist, html,css and js and WRTKit.
</description>
+ <requires-library>org.symbian.wrtkit</requires-library>
</projectTemplate>
</extension>
@@ -256,7 +259,14 @@
icon="icons/main16.gif" id="org.symbian.tools.wrttools.import.aptanaImport"
name="Aptana IDE WRT Project">
</wizard>
- </extension>
+ <wizard
+ category="org.symbian.tools.wrttools.import"
+ class="org.symbian.tools.wrttools.wizards.WgzImportWizard"
+ icon="icons/main16.gif"
+ id="org.symbian.tools.wrttools.importwgz"
+ name="Import WRT Application Archive">
+ </wizard>
+ </extension>
<!-- Problem Markers -->
<extension id="org.symbian.tools.wrt.xmlProblem" name="XML Problem"
@@ -543,9 +553,29 @@
<adapt
type="org.eclipse.core.resources.IResource">
</adapt>
- <count
- value="0">
- </count>
+ <adapt
+ type="java.util.Collection">
+ <count
+ value="0">
+ </count>
+ </adapt>
+ </or>
+ </enablement>
+ </commonWizard>
+ <commonWizard
+ type="import"
+ wizardId="org.symbian.tools.wrttools.importwgz">
+ <enablement>
+ <or>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ </adapt>
+ <adapt
+ type="java.util.Collection">
+ <count
+ value="0">
+ </count>
+ </adapt>
</or>
</enablement>
</commonWizard>
@@ -569,4 +599,19 @@
</commonSorter>
</navigatorContent>
</extension>
+ <extension
+ point="org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer">
+ <JsGlobalScopeContainerInitializer
+ class="org.symbian.tools.wrttools.core.libraries.WrtKitLibInitializer"
+ id="org.symbian.wrtkit">
+ </JsGlobalScopeContainerInitializer>
+ </extension>
+ <extension
+ point="org.eclipse.wst.jsdt.ui.JsGlobalScopeContainerPage">
+ <JsGlobalScopeContainerPage
+ name="WRTKit"
+ class="org.symbian.tools.wrttools.wizards.WrtKitLibraryWizardPage"
+ id="org.symbian.wrtkit">
+ </JsGlobalScopeContainerPage>
+ </extension>
</plugin>
--- a/org.symbian.tools.wrttools/schema/projectTemplates.exsd Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools/schema/projectTemplates.exsd Tue Feb 02 13:53:56 2010 -0800
@@ -49,8 +49,11 @@
<element name="projectTemplate">
<complexType>
- <sequence>
- <element ref="description" minOccurs="0" maxOccurs="1"/>
+ <sequence minOccurs="1" maxOccurs="unbounded">
+ <choice>
+ <element ref="description"/>
+ <element ref="requires-library" minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
</sequence>
<attribute name="name" type="string" use="required">
<annotation>
@@ -131,6 +134,9 @@
</annotation>
</element>
+ <element name="requires-library" type="string">
+ </element>
+
<annotation>
<appinfo>
<meta.section type="since"/>
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java Tue Feb 02 13:53:56 2010 -0800
@@ -70,6 +70,16 @@
}
}
+ public String[] getLibraryIds() {
+ IConfigurationElement[] elements = element.getChildren("requires-library");
+ String[] ids = new String[elements.length];
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement element = elements[i];
+ ids[i] = element.getValue();
+ }
+ return ids;
+ }
+
public static ProjectTemplate[] getAllTemplates() {
if (templates == null) {
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(Activator.PLUGIN_ID, "projectTemplates");
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Tue Feb 02 13:52:03 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Tue Feb 02 13:53:56 2010 -0800
@@ -45,6 +45,7 @@
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -55,8 +56,14 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.wst.jsdt.core.IIncludePathEntry;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JavaScriptCore;
+import org.eclipse.wst.jsdt.core.JavaScriptModelException;
+import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
import org.symbian.tools.wrttools.Activator;
import org.symbian.tools.wrttools.core.ProjectTemplate;
+import org.symbian.tools.wrttools.core.libraries.IWrtIdeContainer;
import org.symbian.tools.wrttools.util.NonClosingStream;
import org.symbian.tools.wrttools.util.ProjectUtils;
@@ -106,10 +113,42 @@
throws CoreException {
monitor.beginTask("Creating project", 100);
IProject project = ProjectUtils.createWrtProject(context.getProjectName(), context.getProjectUri(), new SubProgressMonitor(monitor, 30));
- populateProject(project, new SubProgressMonitor(monitor, 70));
+ populateProject(project, new SubProgressMonitor(monitor, 30));
+ try {
+ initLibraries(project, context.getTemplate().getLibraryIds(), new SubProgressMonitor(monitor, 40));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to setup libraries", e));
+ }
monitor.done();
}
+ private void initLibraries(IProject project, String[] libraryIds, IProgressMonitor progressMonitor) throws IOException, CoreException {
+ if (libraryIds.length == 0) {
+ progressMonitor.done();
+ return;
+ }
+ progressMonitor.beginTask("Installing JS libraries", 100);
+ int perContainer = 90 / libraryIds.length;
+ for (String string : libraryIds) {
+ JsGlobalScopeContainerInitializer containerInitializer = JavaScriptCore.getJsGlobalScopeContainerInitializer(string);
+ if (containerInitializer instanceof IWrtIdeContainer) {
+ ((IWrtIdeContainer) containerInitializer).populateProject(project, new SubProgressMonitor(progressMonitor, perContainer));
+ }
+ }
+ IJavaScriptProject js = JavaScriptCore.create(project);
+ IIncludePathEntry[] rawIncludepath = js.getRawIncludepath();
+ int preconfigured = rawIncludepath.length;
+ IIncludePathEntry[] newIncludepath = new IIncludePathEntry[preconfigured + libraryIds.length];
+ System.arraycopy(rawIncludepath, 0, newIncludepath, 0, preconfigured);
+ for (int i = 0; i < libraryIds.length; i++) {
+ String string = libraryIds[i];
+ IIncludePathEntry entry = JavaScriptCore.newContainerEntry(new Path(string));
+ newIncludepath[preconfigured + i] = entry;
+ }
+ js.setRawIncludepath(newIncludepath, new SubProgressMonitor(progressMonitor, 10));
+ progressMonitor.done();
+ }
+
private void populateProject(IProject project, IProgressMonitor monitor)
throws CoreException {
URL projectContents = context.getTemplate().getProjectContents();