# HG changeset patch # User Eugene Ostroukhov # Date 1265151561 28800 # Node ID aeba352033d28b542cd297d82bdd890220ea42d6 # Parent c772873429380d7037f6d8371dec46e370258086 WRTKit library was introduced diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java Tue Feb 02 13:54:21 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java Tue Feb 02 14:59:21 2010 -0800 @@ -92,7 +92,6 @@ try{ nsIServiceManager servMgr = null; try { - Mozilla.getInstance().initialize(null); servMgr = Mozilla.getInstance().getServiceManager(); if (servMgr == null) return; } catch (Exception x) { diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Tue Feb 02 13:54:21 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Tue Feb 02 14:59:21 2010 -0800 @@ -92,14 +92,6 @@ @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); diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch --- a/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch Tue Feb 02 13:54:21 2010 -0800 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch Tue Feb 02 14:59:21 2010 -0800 @@ -6,7 +6,7 @@ - + @@ -21,8 +21,8 @@ - - + + diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/IWrtIdeContainer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/IWrtIdeContainer.java Tue Feb 02 14:59:21 2010 -0800 @@ -0,0 +1,11 @@ +package org.symbian.tools.wrttools.core.libraries; + +import java.io.IOException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public interface IWrtIdeContainer { + void populateProject(IProject project, IProgressMonitor monitor) throws IOException, CoreException; +} diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/WrtKitLibInitializer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/libraries/WrtKitLibInitializer.java Tue Feb 02 14:59:21 2010 -0800 @@ -0,0 +1,147 @@ +package org.symbian.tools.wrttools.core.libraries; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.wst.jsdt.core.IJavaScriptProject; +import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer; +import org.eclipse.wst.jsdt.core.compiler.libraries.LibraryLocation; +import org.osgi.framework.Bundle; +import org.symbian.tools.wrttools.Activator; + +public class WrtKitLibInitializer extends JsGlobalScopeContainerInitializer implements IWrtIdeContainer { + + public static class WrtKitLocation implements LibraryLocation { + private static final WrtKitLocation LOCATION = new WrtKitLocation(); + + public char[][] getLibraryFileNames() { + return convert(getFiles()); + } + + private char[][] convert(String[] files) { + final Set set = new HashSet(); + for (String string : files) { + if (string.endsWith(".js")) { + set.add(string.toCharArray()); + } + } + return set.toArray(new char[set.size()][]); + } + + public IPath getLibraryPathInPlugin() { + return new Path("/projecttemplates/WRTKit"); + } + + public static WrtKitLocation getInstance() { + return LOCATION; + } + + public String[] getFiles() { + Bundle bundle = Activator.getDefault().getBundle(); + String path = getLibraryPathInPlugin().toString(); + + final Set set = getEntries(bundle, path); + return set.toArray(new String[set.size()]); + } + + @SuppressWarnings("unchecked") + private Set getEntries(Bundle bundle, String p) { + final Set set = new TreeSet(); + Enumeration entries = bundle.getEntryPaths(p); + while (entries.hasMoreElements()) { + String path = (String) entries.nextElement(); + if (path.endsWith("/")) { + set.addAll(getEntries(bundle, path)); + } else { + set.add(path.substring(getLibraryPathInPlugin().toString().length())); + } + } + return set; + } + + public String getLibraryPath(String name) { + System.out.println(name); + return null; + } + + public String getLibraryPath(char[] name) { + Bundle bundle = Activator.getDefault().getBundle(); + URL url = FileLocator.find(bundle, getLibraryPathInPlugin().append(new String(name)), null); + try { + URL fileURL = FileLocator.toFileURL(url); + return fileURL.getPath(); + } catch (IOException e) { + Activator.log(e); + } + return null; + } + + public IPath getWorkingLibPath() { + System.out.println(); + return null; + } + } + + public LibraryLocation getLibraryLocation() { + return WrtKitLocation.getInstance(); + } + + @Override + public String getDescription() { + return "WRTKit Support Library"; + } + + @Override + public String getDescription(IPath containerPath, IJavaScriptProject project) { + return containerPath.lastSegment(); + } + + public void populateProject(IProject project, + IProgressMonitor monitor) throws IOException, CoreException { + WrtKitLocation location = WrtKitLocation.getInstance(); + String[] files = location.getFiles(); + Bundle bundle = Activator.getDefault().getBundle(); + monitor.beginTask("Copying library entries", files.length); + for (String file : files) { + Path path = new Path(file); + InputStream stream = FileLocator.openStream(bundle, location.getLibraryPathInPlugin().append(path), false); + try { + IFile f = project.getFile(new Path("WRTKit").append(path)); + create(f, stream); + } finally { + stream.close(); + } + monitor.worked(1); + } + } + + private void create(IFile f, InputStream stream) throws CoreException { + IContainer container = f.getParent(); + createContainer(container); + f.create(stream, false, new NullProgressMonitor()); + } + + private void createContainer(IContainer container) throws CoreException { + if (!container.exists()) { + createContainer(container.getParent()); + ((IFolder) container).create(false, true, new NullProgressMonitor()); + } + } + +} diff -r c77287342938 -r aeba352033d2 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtKitLibraryWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtKitLibraryWizardPage.java Tue Feb 02 14:59:21 2010 -0800 @@ -0,0 +1,59 @@ +package org.symbian.tools.wrttools.wizards; + +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +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.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.wst.jsdt.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.wst.jsdt.ui.wizards.IJsGlobalScopeContainerPage; +import org.eclipse.wst.jsdt.ui.wizards.IJsGlobalScopeContainerPageExtension; +import org.eclipse.wst.jsdt.ui.wizards.IJsGlobalScopeContainerPageExtension2; +import org.eclipse.wst.jsdt.ui.wizards.NewElementWizardPage; + +public class WrtKitLibraryWizardPage extends NewElementWizardPage implements IJsGlobalScopeContainerPage, IJsGlobalScopeContainerPageExtension, IJsGlobalScopeContainerPageExtension2 { + + private static final String CONTAINER_ID="org.symbian.wrtkit"; + + public WrtKitLibraryWizardPage() { + super("WrtKitLib"); + setTitle("WRTKit JavaScript Library"); + } + + public boolean finish() { + return true; + } + + public IIncludePathEntry getSelection() { + System.out.println("Unimplemented method:BaseLibraryWizardPage.getSelection"); + return null; + } + + public void setSelection(IIncludePathEntry containerEntry) { + } + + public void createControl(Composite parent) { + Composite composite= new Composite(parent, SWT.NONE); + composite.setFont(parent.getFont()); + DialogField field = new DialogField(); + + field.setLabelText("Symbian WRTKit library support was added to your project"); + LayoutUtil.doDefaultLayout(composite, new DialogField[] {field }, false, SWT.DEFAULT, SWT.DEFAULT); + Dialog.applyDialogFont(composite); + setControl(composite); + setDescription("Symbian WRTKit Support"); + } + + public void initialize(IJavaScriptProject project, IIncludePathEntry[] currentEntries) { + // nothing to initialize + } + + public IIncludePathEntry[] getNewContainers() { + IIncludePathEntry library = JavaScriptCore.newContainerEntry( new Path(CONTAINER_ID)); + return new IIncludePathEntry[] {library}; + } + +}