WRT library container
authorEugene Ostroukhov <eugeneo@symbian.org>
Tue, 26 Jan 2010 12:57:46 -0800
changeset 46 8928e0dc33b0
parent 45 aa2fb3fcc303
child 47 206295ed5a0d
WRT library container
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtContainerInitializer.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryLocation.java
org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryWizardPage.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtContainerInitializer.java	Tue Jan 26 12:57:46 2010 -0800
@@ -0,0 +1,25 @@
+package org.symbian.tools.wrttools.previewer.jsdt;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.jsdt.core.IJavaScriptProject;
+import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer;
+import org.eclipse.wst.jsdt.core.compiler.libraries.LibraryLocation;
+
+public class WrtContainerInitializer extends JsGlobalScopeContainerInitializer {
+	public static final String CONTAINER_ID = "org.symbian.wrt";
+	
+	@Override
+	public LibraryLocation getLibraryLocation() {
+		return new WrtLibraryLocation();
+	}
+	
+	@Override
+	public String getDescription() {
+		return "WebRuntime Support Library";
+	}
+	
+	@Override
+	public String getDescription(IPath containerPath, IJavaScriptProject project) {
+		return getDescription();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryLocation.java	Tue Jan 26 12:57:46 2010 -0800
@@ -0,0 +1,60 @@
+package org.symbian.tools.wrttools.previewer.jsdt;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.jsdt.core.compiler.libraries.LibraryLocation;
+import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+
+public class WrtLibraryLocation implements LibraryLocation {
+	private static final Path LIBRARIES_PATH = new Path("/preview/script/lib");
+	private static final char[][] FILE_NAMES = { 
+		"console.js".toCharArray(),
+		"device.js".toCharArray(),
+		"loader.js".toCharArray(),
+		"menu.js".toCharArray(),
+		"menuItem.js".toCharArray(),
+		"systeminfo.js".toCharArray(),
+		"widget.js".toCharArray(),
+	};
+	
+	@Override
+	public char[][] getLibraryFileNames() {
+		return FILE_NAMES;
+	}
+
+	@Override
+	public String getLibraryPath(String name) {
+		System.out.println(name);
+		return null;
+	}
+
+	@Override
+	public String getLibraryPath(char[] name) {
+		URL entry = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), LIBRARIES_PATH.append(new String(name)), null);
+		if (entry != null) {
+			try {
+				URL fileURL = FileLocator.toFileURL(entry);
+				final IPath path = new Path(fileURL.getPath());
+				return path.toString();
+			} catch (IOException e) {
+				PreviewerPlugin.log(e);
+			}
+		}
+		return null;
+	}
+
+	@Override
+	public IPath getLibraryPathInPlugin() {
+		return LIBRARIES_PATH;
+	}
+
+	@Override
+	public IPath getWorkingLibPath() {
+		return new Path(getLibraryPath(""));
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryWizardPage.java	Tue Jan 26 12:57:46 2010 -0800
@@ -0,0 +1,69 @@
+package org.symbian.tools.wrttools.previewer.jsdt;
+
+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;
+
+/**
+ * Wizard page for adding IE library support to the project.
+ */
+public class WrtLibraryWizardPage extends NewElementWizardPage implements
+		IJsGlobalScopeContainerPage, IJsGlobalScopeContainerPageExtension,
+		IJsGlobalScopeContainerPageExtension2 {
+
+	private static final String CONTAINER_ID = WrtContainerInitializer.CONTAINER_ID;
+
+	public WrtLibraryWizardPage() {
+		super("InternetExplorerBrowserLib");
+		setTitle("WRT Library");
+		// setImageDescriptor(JavaPluginImages.DESC_WIZBAN_ADD_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("WRT Library added to Project.\n\n  - This library supports WRT APIs for Symbian platform.");
+		LayoutUtil.doDefaultLayout(composite, new DialogField[] { field },
+				false, SWT.DEFAULT, SWT.DEFAULT);
+		Dialog.applyDialogFont(composite);
+		setControl(composite);
+		setDescription("WebRuntime Libraries");
+	}
+
+	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 };
+	}
+}