# HG changeset patch # User Eugene Ostroukhov # Date 1265147661 28800 # Node ID c772873429380d7037f6d8371dec46e370258086 # Parent b24e6a27768dd73f51fb5d8bc66e9b813b24aab8# Parent f60819888c52fc36ea0f4ff4ea3775c96eb700cf Merged heads diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools.previewer/plugin.xml --- a/org.symbian.tools.wrttools.previewer/plugin.xml Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/plugin.xml Tue Feb 02 13:54:21 2010 -0800 @@ -5,6 +5,7 @@ point="org.eclipse.ui.views"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools.product/wrt-ide.product --- a/org.symbian.tools.wrttools.product/wrt-ide.product Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools.product/wrt-ide.product Tue Feb 02 13:54:21 2010 -0800 @@ -85,7 +85,6 @@ - @@ -140,9 +139,8 @@ - + - @@ -200,9 +198,8 @@ - + - @@ -289,6 +286,7 @@ + diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools/plugin.xml Tue Feb 02 13:54:21 2010 -0800 @@ -208,42 +208,45 @@ + id-pattern="com.{0}.basic.widget"> This wizard generates an basic project with a minimal Info.plist, html,css and js along with WRTKit. + org.symbian.wrtkit This wizard generates an Flickr project with a minimal Info.plist, html,css and js and WRTKit. + org.symbian.wrtkit This wizard generates an RSS Reader project with a minimal Info.plist, html,css and js and WRTKit. + org.symbian.wrtkit @@ -256,7 +259,14 @@ icon="icons/main16.gif" id="org.symbian.tools.wrttools.import.aptanaImport" name="Aptana IDE WRT Project"> - + + + - - + + + + + + + + + + + + + + + + @@ -569,4 +599,19 @@ + + + + + + + + diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools/schema/projectTemplates.exsd --- a/org.symbian.tools.wrttools/schema/projectTemplates.exsd Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools/schema/projectTemplates.exsd Tue Feb 02 13:54:21 2010 -0800 @@ -49,8 +49,11 @@ - - + + + + + @@ -131,6 +134,9 @@ + + + diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/ProjectTemplate.java Tue Feb 02 13:54:21 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"); diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Tue Feb 02 13:54:21 2010 -0800 @@ -54,6 +54,9 @@ public static final String PREVIEW_MAIN_FILE = "wrt_preview_main.html"; private static boolean isDefaultProjectLocation(URI uri) { + if (uri == null) { + return true; + } File file = new File(uri); IPath project = new Path(file.getAbsolutePath()); IPath workspace = ResourcesPlugin.getWorkspace().getRoot() diff -r f60819888c52 -r c77287342938 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Tue Feb 02 12:43:30 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Tue Feb 02 13:54:21 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();