Merged with the most current version
authorEugene Ostroukhov <eugeneo@symbian.org>
Wed, 20 Jan 2010 18:00:15 -0800
changeset 38 954dbf7baac6
parent 37 641b65b14318
child 39 eb7d9e33e288
Merged with the most current version
org.symbian.tools.wrttools.editing/META-INF/MANIFEST.MF
org.symbian.tools.wrttools.editing/icons/obj16/refresh.gif
org.symbian.tools.wrttools.editing/icons/obj16/refresh_green.gif
org.symbian.tools.wrttools.editing/icons/obj16/refresh_red.gif
org.symbian.tools.wrttools.editing/plugin.xml
org.symbian.tools.wrttools.editing/preferences.ini
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/Activator.java
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/IWrtEditingPreferences.java
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/Images.java
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preferences/WrtEditingPreferencePage.java
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewPage.java
org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewView.java
org.symbian.tools.wrttools/META-INF/MANIFEST.MF
org.symbian.tools.wrttools/plugin.xml
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/NavigatorSorter.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/perspectives/RelEngPerspective.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java
--- a/org.symbian.tools.wrttools.editing/META-INF/MANIFEST.MF	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools.editing/META-INF/MANIFEST.MF	Wed Jan 20 18:00:15 2010 -0800
@@ -7,16 +7,16 @@
 Bundle-Vendor: Symbian Foundation
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
- org.eclipse.wst.sse.core;bundle-version="1.1.400",
- org.eclipse.wst.sse.ui;bundle-version="1.1.100",
- org.eclipse.wst.xml.core;bundle-version="1.1.400",
- org.eclipse.wst.xml.ui;bundle-version="1.1.0",
- org.eclipse.jface.text;bundle-version="3.5.0",
+ org.eclipse.wst.sse.core;bundle-version="1.1.401",
+ org.eclipse.wst.sse.ui;bundle-version="1.1.101",
+ org.eclipse.wst.xml.core;bundle-version="1.1.401",
+ org.eclipse.wst.xml.ui;bundle-version="1.1.1",
+ org.eclipse.jface.text;bundle-version="3.5.1",
  org.eclipse.wst.html.core;bundle-version="1.1.300",
- org.eclipse.wst.html.ui;bundle-version="1.0.400",
+ org.eclipse.wst.html.ui;bundle-version="1.0.401",
  org.mozilla.xulrunner;bundle-version="1.9.1";resolution:=optional,
- org.eclipse.core.resources;bundle-version="3.5.0",
+ org.eclipse.core.resources;bundle-version="3.5.1",
  org.eclipse.wst.css.core;bundle-version="1.1.300",
- org.eclipse.wst.jsdt.core;bundle-version="1.0.200"
+ org.eclipse.wst.jsdt.core;bundle-version="1.0.201"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
Binary file org.symbian.tools.wrttools.editing/icons/obj16/refresh.gif has changed
Binary file org.symbian.tools.wrttools.editing/icons/obj16/refresh_green.gif has changed
Binary file org.symbian.tools.wrttools.editing/icons/obj16/refresh_red.gif has changed
--- a/org.symbian.tools.wrttools.editing/plugin.xml	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools.editing/plugin.xml	Wed Jan 20 18:00:15 2010 -0800
@@ -9,7 +9,7 @@
             default="false"
             icon="icons/obj16/html-editor.gif"
             id="org.symbian.tools.wrttools.editing.editor2"
-            name="HTML Editor"
+            name="WRT HTML Editor"
             symbolicFontName="org.eclipse.wst.sse.ui.textfont">
          <contentTypeBinding
                contentTypeId="org.eclipse.wst.html.core.htmlsource">
@@ -19,7 +19,7 @@
    <extension
          point="org.eclipse.ui.views">
       <view
-            allowMultiple="true"
+            allowMultiple="false"
             class="org.symbian.tools.wrttools.editing.preview.PreviewView"
             icon="icons/obj16/html-editor.gif"
             id="org.symbian.tools.wrttools.editing.wrtpreview"
@@ -27,5 +27,28 @@
             restorable="true">
       </view>
    </extension>
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            class="org.symbian.tools.wrttools.editing.preferences.WrtEditingPreferencePage"
+            id="org.symbian.tools.wrttools.editing.preferences.WrtEditingPreferencePage"
+            name="WRT">
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.symbian.tools.wrttools.mainPerspective">
+         <viewShortcut
+               id="org.symbian.tools.wrttools.editing.wrtpreview">
+         </viewShortcut>
+         <view
+               id="org.symbian.tools.wrttools.editing.wrtpreview"
+               minimized="false"
+               relationship="stack"
+               relative="org.eclipse.ui.views.ContentOutline">
+         </view>
+      </perspectiveExtension>
+   </extension>
 
 </plugin>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.editing/preferences.ini	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,1 @@
+preview.autorefresh=prompt
\ No newline at end of file
--- a/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/Activator.java	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/Activator.java	Wed Jan 20 18:00:15 2010 -0800
@@ -1,8 +1,9 @@
 package org.symbian.tools.wrttools.editing;
 
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
 
@@ -32,10 +33,18 @@
 		plugin = this;
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
-	 */
+	@Override
+	protected void initializeImageRegistry(ImageRegistry reg) {
+		addImage(reg, Images.GREEN_SYNC);
+		addImage(reg, Images.RED_SYNC);
+		addImage(reg, Images.YELLOW_SYNC);
+	}
+	
+	private void addImage(ImageRegistry reg, String path) {
+		ImageDescriptor imageDescriptor = imageDescriptorFromPlugin(PLUGIN_ID, path);
+		reg.put(path, imageDescriptor);
+	}
+
 	public void stop(BundleContext context) throws Exception {
 		plugin = null;
 		super.stop(context);
@@ -50,7 +59,7 @@
 		return plugin;
 	}
 
-	public static void log(CoreException e) {
+	public static void log(Exception e) {
 		log(e.getLocalizedMessage(), e);
 	}
 
@@ -59,4 +68,7 @@
 		getDefault().getLog().log(status);
 	}
 
+	public static ImageDescriptor getImageDescriptor(String id) {
+		return getDefault().getImageRegistry().getDescriptor(id);
+	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/IWrtEditingPreferences.java	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,5 @@
+package org.symbian.tools.wrttools.editing;
+
+public interface IWrtEditingPreferences {
+	String PREF_AUTO_REFRESH = "preview.autorefresh";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/Images.java	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,7 @@
+package org.symbian.tools.wrttools.editing;
+
+public interface Images {
+	String RED_SYNC = "/icons/obj16/refresh_red.gif";
+	String YELLOW_SYNC = "/icons/obj16/refresh.gif";
+	String GREEN_SYNC = "/icons/obj16/refresh_green.gif";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preferences/WrtEditingPreferencePage.java	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,81 @@
+package org.symbian.tools.wrttools.editing.preferences;
+
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.symbian.tools.wrttools.editing.Activator;
+import org.symbian.tools.wrttools.editing.IWrtEditingPreferences;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By 
+ * subclassing <samp>FieldEditorPreferencePage</samp>, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to 
+ * save, restore and apply itself.
+ * <p>
+ * This page is used to modify preferences only. They
+ * are stored in the preference store that belongs to
+ * the main plug-in class. That way, preferences can
+ * be accessed directly via the preference store.
+ */
+
+public class WrtEditingPreferencePage
+	extends FieldEditorPreferencePage
+	implements IWorkbenchPreferencePage {
+
+	private RadioGroupFieldEditor enableAutorefresh;
+
+	public WrtEditingPreferencePage() {
+		super(GRID);
+		setPreferenceStore(Activator.getDefault().getPreferenceStore());
+	}
+	
+	/**
+	 * Creates the field editors. Field editors are abstractions of
+	 * the common GUI blocks needed to manipulate various types
+	 * of preferences. Each field editor knows how to save and
+	 * restore itself.
+	 */
+	public void createFieldEditors() {
+        Composite projectComposite = new Composite(getFieldEditorParent(), SWT.NONE);
+        projectComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        projectComposite.setFont(getFieldEditorParent().getFont());
+
+		String[][] namesAndValues = {
+				{ "Enable", MessageDialogWithToggle.ALWAYS },
+				{ "Disable", MessageDialogWithToggle.NEVER },
+				{ "Prompt", MessageDialogWithToggle.PROMPT } };
+		enableAutorefresh = new RadioGroupFieldEditor(
+				IWrtEditingPreferences.PREF_AUTO_REFRESH,
+				"Preview autorefresh for new WRT projects",
+				namesAndValues.length, namesAndValues, projectComposite, true);
+		enableAutorefresh.setPreferenceStore(getPreferenceStore());
+		enableAutorefresh.setPage(this);
+		enableAutorefresh.load();
+        addField(enableAutorefresh);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench workbench) {
+	}
+
+//	@Override
+//	protected void performDefaults() {
+//		enableAutorefresh.loadDefault();
+//		super.performDefaults();
+//	}
+//	
+//	@Override
+//	public boolean performOk() {
+//		enableAutorefresh.store();
+//		return super.performOk();
+//	}
+}
\ No newline at end of file
--- a/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewPage.java	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewPage.java	Wed Jan 20 18:00:15 2010 -0800
@@ -13,19 +13,23 @@
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
 import org.eclipse.ui.part.IPageBookViewPage;
 import org.eclipse.ui.part.IPageSite;
 import org.eclipse.ui.part.Page;
 import org.osgi.framework.Bundle;
+import org.symbian.tools.wrttools.editing.Activator;
+import org.symbian.tools.wrttools.editing.Images;
 
-public class PreviewPage extends Page implements IPageBookViewPage {
+public class PreviewPage extends Page implements IPageBookViewPage, ISelectionProvider {
 	private static final String XUL_RUNNER_PATH_PARAMETER = "org.eclipse.swt.browser.XULRunnerPath";
 	
 	private final IAction refreshAction = new Action("Refresh") {
@@ -42,14 +46,22 @@
 	private final IProject project;
 	private Browser browser;
 	private boolean toggleState = true;
+	private final PreviewView previewView;
+	private boolean needsRefresh = false;
 
-	public PreviewPage(IProject project) {
+	public PreviewPage(IProject project, PreviewView previewView) {
 		this.project = project;
+		this.previewView = previewView;
 	}
 
 	protected void toggleRefresh() {
 		toggleState = !toggleState;
 		toggleRefresh.setChecked(toggleState);
+		previewView.setProjectAutorefresh(project, toggleState);
+		toggleRefresh.setToolTipText(getToggleActionTooltip());
+		if (toggleState && needsRefresh) {
+			refresh();
+		}
 	}
 
 	private synchronized void initMozilla() {
@@ -95,20 +107,31 @@
 	public void setFocus() {
 		browser.setFocus();
 	}
+	
+	private boolean refreshScheduled = false;
 
-	public void process(Collection<IFile> files) {
-		if (needsRefresh(files)) {
-			getControl().getDisplay().asyncExec(new Runnable() {
+	public synchronized void process(Collection<IFile> files) {
+		if (!refreshScheduled && needsRefresh(files)) {
+			asyncExec(new Runnable() {
 				@Override
 				public void run() {
 					if (toggleState) {
 						refresh();
+					} else {
+						needsRefresh = true;
+						refreshAction.setImageDescriptor(Activator.getImageDescriptor(Images.RED_SYNC));
+						refreshAction.setToolTipText("Refresh the preview browser (there are updated files)");
 					}
 				}
 			});
+			refreshScheduled = true;
 		}
 	}
 
+	private void asyncExec(Runnable runnable) {
+		getControl().getDisplay().asyncExec(runnable);
+	}
+
 	private boolean needsRefresh(Collection<IFile> files) {
 		for (IFile iFile : files) {
 			if (iFile.getProject().equals(project)) {
@@ -118,24 +141,66 @@
 		return false;
 	}
 
-	protected void refresh() {
-		browser.refresh();
+	protected synchronized void refresh() {
+		try {
+			final Control focusControl = browser.getDisplay().getFocusControl();
+			browser.refresh();
+			refreshAction.setImageDescriptor(Activator
+					.getImageDescriptor(Images.GREEN_SYNC));
+			asyncExec(new Runnable() {
+				@Override
+				public void run() {
+					focusControl.setFocus();
+				}
+			});
+			refreshAction.setToolTipText("Refresh the preview browser");
+			needsRefresh = false;
+		} finally {
+			refreshScheduled = false;
+		}
 	}
 
 	@Override
 	public void init(IPageSite pageSite) {
 		super.init(pageSite);
 		IToolBarManager toolBar = pageSite.getActionBars().getToolBarManager();
-		ImageDescriptor image = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED);
-		refreshAction.setImageDescriptor(image);
-		refreshAction.setDescription("Refresh the preview browser");
+		refreshAction.setImageDescriptor(Activator.getImageDescriptor(Images.GREEN_SYNC));
 		refreshAction.setToolTipText("Refresh the preview browser");
 		toolBar.add(refreshAction);
 		
-		toggleRefresh.setImageDescriptor(image);
-		toggleRefresh.setDescription("Enable or disable automatic refresh");
-		toggleRefresh.setToolTipText("Enable or disable automatic refresh");
+		toggleState = previewView.getProjectAutorefresh(project);
+		
+		toggleRefresh.setImageDescriptor(Activator.getImageDescriptor(Images.YELLOW_SYNC));
+		toggleRefresh.setToolTipText(getToggleActionTooltip());
 		toggleRefresh.setChecked(toggleState);
 		toolBar.add(toggleRefresh);
+		
+		pageSite.getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
+		getSite().setSelectionProvider(this);
+	}
+
+	private String getToggleActionTooltip() {
+		return toggleState ? "Disable preview autorefresh" : "Enable preview autorefresh";
+	}
+
+	@Override
+	public void addSelectionChangedListener(ISelectionChangedListener listener) {
+		// Do nothing
+	}
+
+	@Override
+	public ISelection getSelection() {
+		return new StructuredSelection(project);
+	}
+
+	@Override
+	public void removeSelectionChangedListener(
+			ISelectionChangedListener listener) {
+		// Do nothing
+	}
+
+	@Override
+	public void setSelection(ISelection selection) {
+		// Do nothing
 	}
 }
--- a/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewView.java	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools.editing/src/org/symbian/tools/wrttools/editing/preview/PreviewView.java	Wed Jan 20 18:00:15 2010 -0800
@@ -1,12 +1,18 @@
 package org.symbian.tools.wrttools.editing.preview;
 
-import java.util.Arrays;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
+import java.util.Properties;
+import java.util.Map.Entry;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -15,9 +21,12 @@
 import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchPart;
@@ -25,16 +34,14 @@
 import org.eclipse.ui.part.MessagePage;
 import org.eclipse.ui.part.PageBook;
 import org.eclipse.ui.part.PageBookView;
-import org.eclipse.wst.css.core.internal.provisional.contenttype.ContentTypeIdForCSS;
-import org.eclipse.wst.html.core.internal.provisional.contenttype.ContentTypeIdForHTML;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
 import org.symbian.tools.wrttools.editing.Activator;
+import org.symbian.tools.wrttools.editing.IWrtEditingPreferences;
 
 public class PreviewView extends PageBookView {
-	private static final Set<String> CONTENT_TYPES = new TreeSet<String>(Arrays.asList(ContentTypeIdForCSS.ContentTypeID_CSS, ContentTypeIdForHTML.ContentTypeID_HTML, JavaScriptCore.JAVA_SOURCE_CONTENT_TYPE));
-	
-	private static final class ChangedResourcesCollector implements IResourceDeltaVisitor {
+	private static final class ChangedResourcesCollector implements
+			IResourceDeltaVisitor {
 		public final Collection<IFile> files = new HashSet<IFile>();
+
 		@Override
 		public boolean visit(IResourceDelta delta) throws CoreException {
 			if (isRelevantResource(delta.getResource())) {
@@ -43,7 +50,13 @@
 			return true;
 		}
 	}
-	
+
+	public static boolean isRelevantResource(IResource resource) {
+		return resource.getType() == IResource.FILE
+				&& !resource.getFullPath().segment(1).equalsIgnoreCase(
+						"preview");
+	}
+
 	private final IResourceChangeListener resourceListener = new IResourceChangeListener() {
 		@Override
 		public void resourceChanged(IResourceChangeEvent event) {
@@ -56,53 +69,50 @@
 			refreshPages(visitor.files);
 		}
 	};
-	
+
 	private Map<IProject, PreviewPage> projectToPage = new HashMap<IProject, PreviewPage>();
-	
+	private boolean preferencesLoaded = false;
+	private final Map<IProject, Boolean> autorefresh = new HashMap<IProject, Boolean>();
+
 	@Override
 	protected IPage createDefaultPage(PageBook book) {
 		MessagePage messagePage = new MessagePage();
-		messagePage.setMessage("Open editor to preview WRT widget");
+		messagePage.setMessage("Open an editor to preview WRT widget");
+		initPage(messagePage);
+		messagePage.createControl(book);
 		return messagePage;
 	}
 
-	protected void refreshPages(Collection<IFile> files) {
-		Collection<PreviewPage> values = projectToPage.values();
-		for (PreviewPage page : values) {
-			page.process(files);
-		}
+	@Override
+	public void createPartControl(Composite parent) {
+		super.createPartControl(parent);
+		ResourcesPlugin.getWorkspace().addResourceChangeListener(
+				resourceListener);
 	}
 
-	public static boolean isRelevantResource(IResource resource) {
-		if (resource.getType() == IResource.FILE) {
-			IContentType contentType;
-			try {
-				contentType = ((IFile) resource).getContentDescription().getContentType();
-				if (contentType != null) {
-					return CONTENT_TYPES.contains(contentType.getId());
-				}
-			} catch (CoreException e) {
-				Activator.log(e);
-			}
-		}
-		return false;
+	@Override
+	public void dispose() {
+		ResourcesPlugin.getWorkspace().removeResourceChangeListener(
+				resourceListener);
+		super.dispose();
 	}
 
 	@Override
 	protected PageRec doCreatePage(IWorkbenchPart part) {
 		// All checks we need were done in isImportant method
-		IResource resource = (IResource) ((IEditorPart) part).getEditorInput().getAdapter(IResource.class);
-		
+		IResource resource = (IResource) ((IEditorPart) part).getEditorInput()
+				.getAdapter(IResource.class);
+
 		IProject project = resource.getProject();
 		PreviewPage page = projectToPage.get(project);
-		
+
 		if (page == null) {
-			page = new PreviewPage(project);
+			page = new PreviewPage(project, this);
 			initPage(page);
 			page.createControl(getPageBook());
 			projectToPage.put(project, page);
 		}
-		
+
 		return new PageRec(part, page);
 	}
 
@@ -122,10 +132,49 @@
 		return null;
 	}
 
+	private boolean getDefaultAutorefresh(IProject project) {
+		IPreferenceStore preferenceStore = Activator.getDefault()
+				.getPreferenceStore();
+		String value = preferenceStore
+				.getString(IWrtEditingPreferences.PREF_AUTO_REFRESH);
+		if (value == null || value.trim().length() == 0 || MessageDialogWithToggle.PROMPT.equals(value)) {
+			return MessageDialogWithToggle
+					.openYesNoQuestion(
+							getSite().getShell(),
+							"WRT Preview",
+							"WRT IDE can refresh preview whenever any changes are made to project files. Refresh will always return the widget to initial page. Do you want to enable automatic refresh for your project?\nNote: you can toggle this setting for particular project on the preview toolbar.",
+							"Keep this setting for all new projects", false,
+							preferenceStore,
+							IWrtEditingPreferences.PREF_AUTO_REFRESH)
+					.getReturnCode() == IDialogConstants.YES_ID;
+		} else {
+			return MessageDialogWithToggle.ALWAYS.equals(value);
+		}
+	}
+
+	private File getPreferencesFile() {
+		return Activator.getDefault().getStateLocation().append(
+				"autorefreshState.xml").toFile();
+	}
+
+	public boolean getProjectAutorefresh(IProject project) {
+		synchronized (autorefresh) {
+			loadPreferences();
+			if (autorefresh.containsKey(project)) {
+				return autorefresh.get(project);
+			} else {
+				boolean value = getDefaultAutorefresh(project);
+				setProjectAutorefresh(project, value);
+				return value;
+			}
+		}
+	}
+
 	@Override
 	protected boolean isImportant(IWorkbenchPart part) {
 		if (part instanceof IEditorPart) {
-			IResource resource = (IResource) ((IEditorPart) part).getEditorInput().getAdapter(IResource.class);
+			IResource resource = (IResource) ((IEditorPart) part)
+					.getEditorInput().getAdapter(IResource.class);
 			if (resource != null) {
 				return isWrtProject(resource.getProject());
 			}
@@ -136,16 +185,77 @@
 	private boolean isWrtProject(IProject project) {
 		return project.getFile("wrt_preview_frame.html").exists();
 	}
-	
-	@Override
-	public void createPartControl(Composite parent) {
-		super.createPartControl(parent);
-		ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener);
+
+	private void loadPreferences() {
+		synchronized (autorefresh) {
+			if (preferencesLoaded) {
+				return;
+			}
+			preferencesLoaded = true;
+			File preferencesFile = getPreferencesFile();
+			Properties properties = new Properties();
+			if (preferencesFile.exists()) {
+				InputStream inputStream = null;
+				try {
+					inputStream = new FileInputStream(preferencesFile);
+					properties.loadFromXML(inputStream);
+				} catch (IOException e) {
+					Activator.log(e);
+				} finally {
+					if (inputStream != null) {
+						try {
+							inputStream.close();
+						} catch (IOException e) {
+							Activator.log(e);
+						}
+					}
+				}
+				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+				for (Entry<Object, Object> entry : properties.entrySet()) {
+					String projectName = entry.getKey().toString();
+					String value = entry.getValue().toString();
+					IProject project = root.getProject(projectName);
+					if (project.exists()) {
+						autorefresh.put(project, Boolean.valueOf(value));
+					}
+				}
+			}
+		}
 	}
-	
-	@Override
-	public void dispose() {
-		ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceListener);
-		super.dispose();
+
+	protected void refreshPages(Collection<IFile> files) {
+		Collection<PreviewPage> values = projectToPage.values();
+		for (PreviewPage page : values) {
+			page.process(files);
+		}
 	}
+
+	public void setProjectAutorefresh(IProject project, boolean refresh) {
+		synchronized (autorefresh) {
+			autorefresh.put(project, refresh);
+			Properties properties = new Properties();
+			for (Entry<IProject, Boolean> entry : autorefresh.entrySet()) {
+				properties.setProperty(entry.getKey().getName(), entry
+						.getValue().toString());
+			}
+			File path = getPreferencesFile();
+			OutputStream outputStream = null;
+			try {
+				outputStream = new BufferedOutputStream(new FileOutputStream(
+						path));
+				properties.storeToXML(outputStream, null);
+			} catch (IOException e) {
+				Activator.log(e);
+			} finally {
+				if (outputStream != null) {
+					try {
+						outputStream.close();
+					} catch (IOException e) {
+						Activator.log(e);
+					}
+				}
+			}
+		}
+	}
+
 }
--- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Wed Jan 20 18:00:15 2010 -0800
@@ -20,7 +20,9 @@
  org.eclipse.ui.ide;bundle-version="3.5.0",
  org.eclipse.wst.validation;bundle-version="1.2.102",
  org.eclipse.wst.sse.core;bundle-version="1.1.400",
- org.eclipse.wst.xml.core;bundle-version="1.1.400"
+ org.eclipse.wst.xml.core;bundle-version="1.1.400",
+ org.eclipse.ui.navigator;bundle-version="3.4.0",
+ org.eclipse.ui.navigator.resources;bundle-version="3.4.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Import-Package: org.apache.velocity;version="1.5.0",
@@ -44,7 +46,6 @@
  org.eclipse.emf.common.util,
  org.eclipse.emf.ecore,
  org.eclipse.emf.ecore.impl,
- org.eclipse.jdt.ui,
  org.eclipse.ui.console,
  org.eclipse.ui.dialogs,
  org.eclipse.ui.ide,
@@ -53,3 +54,4 @@
  org.eclipse.ui.wizards.newresource
 Bundle-ClassPath: lib/tagsoup-1.2.jar,
  .
+Export-Package: org.symbian.tools.wrttools.wizards
--- a/org.symbian.tools.wrttools/plugin.xml	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools/plugin.xml	Wed Jan 20 18:00:15 2010 -0800
@@ -1,160 +1,384 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
-   <extension-point id="org.eclipse.core.resources" name="Incremental Project Builders" schema="schema/org.eclipse.core.resources.exsd"/>
-   <extension-point id="org.eclipse.ui.javaScriptProjectNatureImage" name="JavaScript Nature Image" schema="schema/org.eclipse.ui.javaScriptProjectNatureImage.exsd"/>
 
-   <extension
-         id="PropertiesFileAuditor"
-         name="Properties File Auditor Project Builder"
-         point="org.eclipse.core.resources.builders">
-      <builder
-            hasNature="true">
-         <run
-               class="org.symbian.tools.wrttools.builder.PropertiesFileAuditor">
-         </run>
-      </builder>
-   </extension>
-   <extension
-         id="PropertiesAuditorNature"
-         name="Properties Auditor Nature"
-         point="org.eclipse.core.resources.natures">
-      <runtime>
-         <run
-               class="org.symbian.tools.wrttools.builder.PropertiesAuditorNature">
-         </run>
-      </runtime>
-      <requires-nature id="org.eclipse.wst.jsdt.core.jsNature"/>
-      <requires-nature id="org.eclipse.pde.PluginNature"/>
-      <builder
-            id="org.symbian.tools.wrttools.builder.PropertiesFileAuditor">
-      </builder>
-   </extension>
-   <extension-point id="projectTemplates" name="WRT application project templates" schema="schema/projectTemplates.exsd"/>
-    <extension
-         id="org.symbian.tools.wrttools.core.cssvalidator"
-         name="CSS Validator"
-         point="org.eclipse.wst.validation.validatorV2">
-      <validator
-            build="true"
-            class="org.symbian.tools.wrttools.core.internal.validation.CssBuildValidator"
-            manual="true"
-            markerId="org.symbian.tools.wrttools.core.cssValidationMarker"
-            version="0.0.1">
-         <include>
-            <rules>
-               <contentType
-                     exactMatch="false"
-                     id="org.eclipse.wst.css.core.csssource">
-               </contentType>
-            </rules>
-         </include>
-      </validator>
-   </extension>
-   <extension
-         point="org.eclipse.ui.newWizards">
-      <category
-            id="org.symbian.tools.wrttools.core.category"
-            name="Web Runtime(WRT)">
-      </category>
-      <wizard
-            category="org.symbian.tools.wrttools.core.category"
-            class="org.symbian.tools.wrttools.wizards.WrtWidgetWizard"
-            finalPerspective="org.eclipse.wst.jsdt.ui.JavaPerspective"
-            hasPages="true"
-            icon="icons/main16.gif"
-            id="org.symbian.tools.wrttools.core.wrtwidgetwizard"
-            name="Web Runtime Application"
-            project="true">
-         <description>
-            Creates a new Symbian WRT application project using one of the provided templates
+	<extension id="PropertiesFileAuditor" name="Properties File Auditor Project Builder"
+		point="org.eclipse.core.resources.builders">
+		<builder hasNature="true">
+			<run class="org.symbian.tools.wrttools.builder.PropertiesFileAuditor">
+			</run>
+		</builder>
+	</extension>
+	<extension id="PropertiesAuditorNature" name="Properties Auditor Nature"
+		point="org.eclipse.core.resources.natures">
+		<runtime>
+			<run class="org.symbian.tools.wrttools.builder.PropertiesAuditorNature">
+			</run>
+		</runtime>
+		<requires-nature id="org.eclipse.wst.jsdt.core.jsNature" />
+		<requires-nature id="org.eclipse.pde.PluginNature" />
+		<builder id="org.symbian.tools.wrttools.builder.PropertiesFileAuditor">
+		</builder>
+	</extension>
+	<extension-point id="projectTemplates" name="WRT application project templates" schema="schema/projectTemplates.exsd"/>
+	<extension id="org.symbian.tools.wrttools.core.cssvalidator"
+		name="CSS Validator" point="org.eclipse.wst.validation.validatorV2">
+		<validator build="true"
+			class="org.symbian.tools.wrttools.core.internal.validation.CssBuildValidator"
+			manual="true" markerId="org.symbian.tools.wrttools.core.cssValidationMarker"
+			version="0.0.1">
+			<include>
+				<rules>
+					<contentType exactMatch="false"
+						id="org.eclipse.wst.css.core.csssource">
+					</contentType>
+				</rules>
+			</include>
+		</validator>
+	</extension>
+	<extension point="org.eclipse.ui.newWizards">
+		<category id="org.symbian.tools.wrttools.core.category" name="Web Runtime(WRT)">
+		</category>
+		<wizard category="org.symbian.tools.wrttools.core.category"
+			class="org.symbian.tools.wrttools.wizards.WrtWidgetWizard"
+			finalPerspective="org.symbian.tools.wrttools.mainPerspective"
+			hasPages="true" icon="icons/main16.gif"
+			id="org.symbian.tools.wrttools.core.wrtwidgetwizard" name="Web Runtime Application"
+			project="true">
+			<description>
+				Creates a new Symbian WRT application project using one of the provided
+				templates
+         </description>
+		</wizard>
+		<wizard category="org.symbian.tools.wrttools.core.category"
+			class="org.symbian.tools.wrttools.wizards.AptanaProjectsImportWizard"
+			finalPerspective="org.symbian.tools.wrttools.mainPerspective"
+			hasPages="true" icon="icons/main16.gif"
+			id="org.symbian.tools.wrttools.newImportAptanaProject" name="Import Aptana IDE WRT Project"
+			project="true">
+		</wizard>
+	</extension>
+	<extension point="org.symbian.tools.wrttools.projectTemplates">
+		<projectTemplate
+		name="Basic Widget Project"
+        archive="projecttemplates/basic.zip"
+        default-css-name="basic"
+        default-html-name="index"
+        default-js-name="basic"
+        icon="icons/main16.gif"
+        id-pattern="com.{0}.basic.widget">
+			<description>
+				This wizard generates an empty widget project with a minimal Info.plist, html,css and js.
          </description>
-      </wizard>
-      <wizard
-            category="org.symbian.tools.wrttools.core.category"
-            class="org.symbian.tools.wrttools.wizards.AptanaProjectsImportWizard"
-            finalPerspective="org.eclipse.wst.jsdt.ui.JavaPerspective"
-            hasPages="true"
-            icon="icons/main16.gif"
-            id="org.symbian.tools.wrttools.newImportAptanaProject"
-            name="Import Aptana IDE WRT Project"
-            project="true">
-      </wizard>
-   </extension>
-   <extension
-         point="org.symbian.tools.wrttools.projectTemplates">
-      <projectTemplate
-            archive="projecttemplates/basic.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 Widget Project">
-         <description>
-            This wizard generates an empty widget project with a minimal Info.plist, html,css and js.
-         </description>
-      </projectTemplate>
-   </extension>
-   <extension
-         point="org.eclipse.ui.importWizards">
-      <category
-            id="org.symbian.tools.wrttools.import"
-            name="Web Runtime(WRT)">
-      </category>
-      <wizard
-            category="org.symbian.tools.wrttools.import"
-            class="org.symbian.tools.wrttools.wizards.AptanaProjectsImportWizard"
-            icon="icons/main16.gif"
-            id="org.symbian.tools.wrttools.import.aptanaImport"
-            name="Aptana IDE WRT Project">
-      </wizard>
-   </extension>
-      <extension
-         id="org.symbian.tools.wrt.xmlProblem"
-         name="XML Problem"
-         point="org.eclipse.core.resources.markers">
-      <super
-            type="org.eclipse.core.resources.problemmarker">
-      </super>
-      <persistent
-            value="true">
-      </persistent>
-   </extension>
-   <extension
-         id="org.symbian.tools.wrt.jsProblem"
-         name="JSProblem"
-         point="org.eclipse.core.resources.markers">
-      <super
-            type="org.eclipse.core.resources.problemmarker">
-      </super>
-      <persistent
-            value="true">
-      </persistent>
-   </extension>
-      <extension
-         point="org.eclipse.core.contenttype.contentTypes">
-      <content-type
-            base-type="org.eclipse.core.runtime.xml"
-            file-extensions="plist"
-            id="org.symbian.tools.wrttools.contenttype.plist"
-            name="WebRuntime Descriptor File"
-            priority="normal">
-      </content-type>
-   </extension>
-      <extension
-            point="org.eclipse.ui.perspectiveExtensions">
-         <perspectiveExtension
-               targetID="org.eclipse.wst.jsdt.ui.JavaPerspective">
-            <newWizardShortcut
-                  id="org.symbian.tools.wrttools.core.wrtwidgetwizard">
-            </newWizardShortcut>
-         </perspectiveExtension>
-         <perspectiveExtension
-               targetID="org.eclipse.debug.ui.DebugPerspective">
-            <newWizardShortcut
-                  id="org.symbian.tools.wrttools.core.wrtwidgetwizard">
-            </newWizardShortcut>
-         </perspectiveExtension>
-      </extension>
+		</projectTemplate>
+	</extension>
+	<extension point="org.eclipse.ui.importWizards">
+		<category id="org.symbian.tools.wrttools.import" name="Web Runtime(WRT)">
+		</category>
+		<wizard category="org.symbian.tools.wrttools.import"
+			class="org.symbian.tools.wrttools.wizards.AptanaProjectsImportWizard"
+			icon="icons/main16.gif" id="org.symbian.tools.wrttools.import.aptanaImport"
+			name="Aptana IDE WRT Project">
+		</wizard>
+	</extension>
+	<extension id="org.symbian.tools.wrt.xmlProblem" name="XML Problem"
+		point="org.eclipse.core.resources.markers">
+		<super type="org.eclipse.core.resources.problemmarker">
+		</super>
+		<persistent value="true">
+		</persistent>
+	</extension>
+	<extension id="org.symbian.tools.wrt.jsProblem" name="JSProblem"
+		point="org.eclipse.core.resources.markers">
+		<super type="org.eclipse.core.resources.problemmarker">
+		</super>
+		<persistent value="true">
+		</persistent>
+	</extension>
+	<extension point="org.eclipse.core.contenttype.contentTypes">
+		<content-type base-type="org.eclipse.core.runtime.xml"
+			file-extensions="plist" id="org.symbian.tools.wrttools.contenttype.plist"
+			name="WebRuntime Descriptor File" priority="normal">
+		</content-type>
+	</extension>
+	<extension point="org.eclipse.ui.perspectiveExtensions">
+		<perspectiveExtension targetID="org.eclipse.wst.jsdt.ui.JavaPerspective">
+			<newWizardShortcut id="org.symbian.tools.wrttools.core.wrtwidgetwizard">
+			</newWizardShortcut>
+		</perspectiveExtension>
+		<perspectiveExtension targetID="org.eclipse.debug.ui.DebugPerspective">
+			<newWizardShortcut id="org.symbian.tools.wrttools.core.wrtwidgetwizard">
+			</newWizardShortcut>
+		</perspectiveExtension>
+	</extension>
+	<extension point="org.eclipse.ui.views">
+		<view allowMultiple="false" category="org.symbian.tools.wrttools.views"
+			class="org.eclipse.ui.navigator.CommonNavigator" icon="icons/main16.gif"
+			id="org.symbian.tools.wrttools.wrtnavigator" name="WRT Navigator"
+			restorable="true">
+		</view>
+		<category id="org.symbian.tools.wrttools.views" name="WRT Tools">
+		</category>
+	</extension>
+	<extension point="org.eclipse.ui.navigator.viewer">
+		<viewer viewerId="org.symbian.tools.wrttools.wrtnavigator">
+			<popupMenu allowsPlatformContributions="true"
+				id="org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
+				<insertionPoint name="group.new" />
+				<insertionPoint name="group.open" separator="true" />
+				<insertionPoint name="group.openWith" />
+				<insertionPoint name="group.edit" separator="true" />
+				<insertionPoint name="group.reorganize" />
+				<insertionPoint name="group.port" separator="true" />
+				<insertionPoint name="group.build" separator="true" />
+				<insertionPoint name="group.generate" separator="true" />
+				<insertionPoint name="group.search" separator="true" />
+				<insertionPoint name="additions" separator="true" />
+				<insertionPoint name="group.properties" separator="true" />
+
+			</popupMenu>
+		</viewer>
+		<viewerContentBinding viewerId="org.symbian.tools.wrttools.wrtnavigator">
+			<includes>
+				<contentExtension pattern="org.eclipse.ui.navigator.resourceContent" />
+				<contentExtension
+          isRoot="true"
+          pattern="org.symbian.tools.wrttools.navigatorcontent"/>
+				<contentExtension pattern="org.eclipse.ui.navigator.resources.filters.*" />
+				<contentExtension pattern="org.eclipse.ui.navigator.resources.linkHelper" />
+				<contentExtension pattern="org.eclipse.ui.navigator.resources.workingSets" />
+			</includes>
+		</viewerContentBinding>
+		<viewerActionBinding viewerId="org.symbian.tools.wrttools.wrtnavigator">
+			<includes>
+				<actionExtension pattern="org.eclipse.ui.navigator.resources.*" />
+			</includes>
+		</viewerActionBinding>
+		<dragAssistant
+			class="org.eclipse.ui.navigator.resources.ResourceDragAdapterAssistant"
+			viewerId="org.symbian.tools.wrttools.wrtnavigator" />
+	</extension>
+	 <extension
+       point="org.eclipse.ui.navigator.navigatorContent">
+    <navigatorContent
+          activeByDefault="true"
+          contentProvider="org.symbian.tools.wrttools.navigator.WRTNavigatorContentProvider"
+          icon="icons/main16.gif"
+          id="org.symbian.tools.wrttools.navigatorcontent"
+          labelProvider="org.eclipse.wst.jsdt.internal.ui.navigator.JavaNavigatorLabelProvider"
+          name="WRT Elements"
+          priority="high"
+          providesSaveables="false">
+       <triggerPoints>
+          <or>
+             <and>
+                <instanceof
+                      value="org.eclipse.core.resources.IResource">
+                </instanceof>
+                <adapt
+                      type="org.eclipse.core.resources.IProject">
+                   <test
+                         property="org.eclipse.core.resources.projectNature"
+                         value="org.eclipse.wst.jsdt.core.jsNature">
+                   </test>
+                </adapt>
+             </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>
+             <instanceof
+                   value="org.eclipse.wst.jsdt.ui.ProjectLibraryRoot">
+             </instanceof>
+          </or>
+       </triggerPoints>
+       <possibleChildren>
+          <or>
+             <instanceof
+                   value="org.eclipse.core.resources.IResource">
+             </instanceof>
+             <instanceof
+                   value="org.eclipse.wst.jsdt.core.IJavaScriptElement">
+             </instanceof>
+             <instanceof
+                   value="org.eclipse.wst.jsdt.core.IJarEntryResource">
+             </instanceof>
+             <instanceof
+                   value="org.eclipse.wst.jsdt.ui.ProjectLibraryRoot">
+             </instanceof>
+          </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"
+             overrides="org.eclipse.ui.navigator.resources.actions.EditActions">
+          <enablement>
+             <or>
+                <and>
+                   <instanceof
+                         value="org.eclipse.core.resources.IProject">
+                   </instanceof>
+                   <test
+                         property="org.eclipse.core.resources.projectNature"
+                         value="org.eclipse.wst.jsdt.core.jsNature">
+                   </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>
+       </actionProvider>
+       <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.eclipse.wst.jsdt.core.jsNature">
+                   </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>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.wst.jsdt.internal.ui.navigator.PackageExplorerOpenActionProvider"
+             id="org.eclipse.wst.jsdt.ui.navigator.actions.OpenActions"
+             overrides="org.eclipse.ui.navigator.resources.OpenActions">
+       </actionProvider>
+       <override
+             policy="InvokeAlwaysRegardlessOfSuppressedExt"
+             suppressedExtensionId="org.eclipse.ui.navigator.resourceContent">
+       </override>
+       <commonWizard
+             menuGroupId="group.new"
+             type="new"
+             wizardId="org.symbian.tools.wrttools.core.wrtwidgetwizard">
+          <enablement>
+             <or>
+                <adapt
+                      type="org.eclipse.core.resources.IResource">
+                </adapt>
+                <count
+                      value="0">
+                </count>
+             </or>
+          </enablement>
+       </commonWizard>
+       <commonWizard
+             type="new"
+             wizardId="org.eclipse.wst.html.ui.internal.wizard.NewHTMLWizard">
+          <enablement>
+             <adapt
+                   type="org.eclipse.core.resources.IResource">
+             </adapt>
+          </enablement>
+       </commonWizard>
+       <commonWizard
+             type="new"
+             wizardId="org.eclipse.wst.css.ui.internal.wizard.NewCSSWizard">
+          <enablement>
+             <adapt
+                   type="org.eclipse.core.resources.IResource">
+             </adapt>
+          </enablement>
+       </commonWizard>
+       <commonWizard
+             type="new"
+             wizardId="org.eclipse.wst.jsdt.ui.NewJSWizard">
+          <enablement>
+             <adapt
+                   type="org.eclipse.core.resources.IResource">
+             </adapt>
+          </enablement>
+       </commonWizard>
+       <commonWizard
+             type="import"
+             wizardId="org.symbian.tools.wrttools.import.aptanaImport">
+          <enablement>
+             <or>
+                <adapt
+                      type="org.eclipse.core.resources.IResource">
+                </adapt>
+                <count
+                      value="0">
+                </count>
+             </or>
+          </enablement>
+       </commonWizard>
+       <dropAssistant
+             class="org.eclipse.wst.jsdt.internal.ui.navigator.JavaDropAdapterAssistant"
+             id="org.eclipse.wst.jsdt.ui.dropAssistant">
+          <possibleDropTargets>
+             <or>
+                <instanceof
+                      value="org.eclipse.core.resources.IResource">
+                </instanceof>
+                <instanceof
+                      value="org.eclipse.wst.jsdt.core.IJavaScriptElement">
+                </instanceof>
+             </or>
+          </possibleDropTargets>
+       </dropAssistant>
+       <commonSorter
+             class="org.symbian.tools.wrttools.navigator.NavigatorSorter"
+             id="org.symbian.tools.wrttools.sorter">
+       </commonSorter>
+    </navigatorContent>
+ </extension>
 </plugin>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/NavigatorSorter.java	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,67 @@
+package org.symbian.tools.wrttools.navigator;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.ui.JavaScriptElementComparator;
+
+public class NavigatorSorter extends ViewerSorter {
+	private final JavaScriptElementComparator jsComparator = new JavaScriptElementComparator();
+	
+	@Override
+	public int compare(Viewer viewer, Object e1, Object e2) {
+		if (e1 == e2) {
+			return 0;
+		} else if (e1 == null) { 
+			return 1;
+		} else if (e2 == null) {
+			return -1;
+		}
+		
+		if (e1 instanceof IJavaScriptElement && e2 instanceof IJavaScriptElement) {
+			return compareJavaScriptElements(viewer, (IJavaScriptElement) e1, (IJavaScriptElement) e2);
+		}
+		IResource res1 = getResource(e1);
+		IResource res2 = getResource(e2);
+		
+		if (res1 == res2) {
+			return 0;
+		} else if (res1 == null) {
+			return 1;
+		} else if (res2 == null) {
+			return -1;
+		} else {
+			int res1type = res1.getType();
+			int res2type = res2.getType();
+			if (res1type == res2type) {
+				// Note: Files cannot have same name in different case - enforced by Eclipse
+				return res1.getName().toLowerCase().compareTo(res2.getName().toLowerCase());
+			} else if (res1type == IResource.PROJECT) {
+				return -1;
+			} else if (res1type == IResource.PROJECT) {
+				return 1;
+			} else if (res1type == IResource.FOLDER) {
+				return -1;
+			} else {
+				return 1;
+			}
+		}
+	}
+
+	private IResource getResource(Object e1) {
+		if (e1 instanceof IResource) {
+			return (IResource) e1;
+		} else if (e1 instanceof IAdaptable) {
+			return (IResource) ((IAdaptable) e1).getAdapter(IResource.class);
+		} else {
+			return null;
+		}
+	}
+
+	private int compareJavaScriptElements(Viewer viewer, IJavaScriptElement e1, IJavaScriptElement e2) {
+		return jsComparator.compare(viewer, e1, e2);
+	}
+	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java	Wed Jan 20 18:00:15 2010 -0800
@@ -0,0 +1,137 @@
+package org.symbian.tools.wrttools.navigator;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.wst.jsdt.core.IJavaScriptElement;
+import org.eclipse.wst.jsdt.core.IJavaScriptModel;
+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.internal.ui.navigator.JavaNavigatorContentProvider;
+import org.symbian.tools.wrttools.Activator;
+
+public class WRTNavigatorContentProvider extends JavaNavigatorContentProvider
+		implements ITreeContentProvider {
+
+	private static final class TreeElementsComparator implements Comparator<Object> {
+		@Override
+		public int compare(Object o1, Object o2) {
+			IResource res1 = getResource(o1);
+			IResource res2 = getResource(o2);
+			if (o1 == o2) {
+				return 0;
+			} else if (o1 == null) {
+				return -1;
+			} else if (o2 == null) {
+				return 1;
+			}
+			
+			boolean isFolder1 = isFolder(res1);
+			boolean isFolder2 = isFolder(res2);
+			
+			if (isFolder1 == isFolder2) {
+				return res1.getName().compareTo(res2.getName());
+			} else if (isFolder1) {
+				return 1;
+			} else {
+				return -1;
+			}
+		}
+
+		private boolean isFolder(IResource res1) {
+			return res1.getType() == IResource.FOLDER || res1.getType() == IResource.PROJECT;
+		}
+
+		private IResource getResource(Object o1) {
+			final IResource result;
+			if (o1 instanceof IResource) {
+				result = (IResource) o1;
+			} else if (o1 instanceof IAdaptable) {
+				result = (IResource) ((IAdaptable) o1).getAdapter(IResource.class);
+			} else {
+				result = null;
+			}
+			return result;
+		}
+	}
+	
+	
+	@Override
+	protected Object[] getPackageFragmentRoots(IJavaScriptProject project)
+			throws JavaScriptModelException {
+		try {
+			return filter(project.getProject().members());
+		} catch (CoreException e) {
+			Activator.log(e);
+		}
+		return new Object[0];
+	}
+	
+	private Object[] filter(IResource[] members) {
+		TreeSet<Object> output = new TreeSet<Object>(new TreeElementsComparator());
+		for (int i = 0; i < members.length; i++) {
+			IResource resource = members[i];
+			Object res = resource;
+			if (resource.getType() == IResource.FILE) {
+				IJavaScriptElement element = JavaScriptCore.create(resource);
+				if (element != null) {
+					res = element;
+				}
+			}
+			output.add(res);
+		}
+		return output.toArray();
+	}
+
+	@Override
+	protected Object[] getFolderContent(IFolder folder) throws CoreException {
+		return filter(folder.members());
+	}
+	
+	@Override
+	protected void postAdd(Object parent, Object element, Collection runnables) {
+		if (parent instanceof IWorkspace) {
+			super.postAdd(((IWorkspace) parent).getRoot(), element, runnables);
+		} else if (parent instanceof IJavaScriptModel) {
+			super.postAdd(((IJavaScriptModel) parent).getWorkspace().getRoot(),
+					element, runnables);
+		} else {
+			super.postAdd(parent, element, runnables);
+		}
+	}
+	
+//	@Override
+//	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+//		this.viewer = viewer;
+//		super.inputChanged(viewer, oldInput, newInput);
+//	}
+//	
+//	@SuppressWarnings("unchecked")
+//	@Override
+//	protected void postAdd(final Object parent, final Object element, Collection runnables) {
+//		final Object p;
+//		if (element instanceof IProject) {
+//			p = null;
+//		} else {
+//			p = parent;
+//		}
+//		runnables.add(new Runnable() {
+//			@Override
+//			public void run() {
+//				if (p != null) {
+//					((TreeViewer) viewer).refresh(p);
+//				} else {
+//					((TreeViewer) viewer).refresh();
+//				}
+//			}
+//		});
+//	}
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/perspectives/RelEngPerspective.java	Wed Jan 20 16:51:26 2010 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/**
- * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of the License "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
- *
- * Initial Contributors:
- * Symbian Foundation - initial contribution.
- * Contributors:
- * Description:
- * Overview:
- * Details:
- * Platforms/Drives/Compatibility:
- * Assumptions/Requirement/Pre-requisites:
- * Failures and causes:
- */
-package org.symbian.tools.wrttools.perspectives;
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.jdt.ui.JavaUI;
-
-
-/**
- *  This class is meant to serve as an example for how various contributions 
- *  are made to a perspective. Note that some of the extension point id's are
- *  referred to as API constants while others are hardcoded and may be subject 
- *  to change. 
- */
-public class RelEngPerspective implements IPerspectiveFactory {
-
-	private IPageLayout factory;
-
-	public RelEngPerspective() {
-		super();
-	}
-
-	public void createInitialLayout(IPageLayout factory) {
-		this.factory = factory;
-		addViews();
-		addActionSets();
-		addNewWizardShortcuts();
-		addPerspectiveShortcuts();
-		addViewShortcuts();
-	}
-
-	private void addViews() {
-		// Creates the overall folder layout. 
-		// Note that each new Folder uses a percentage of the remaining EditorArea.
-		
-		IFolderLayout bottom =
-			factory.createFolder(
-				"bottomRight", //NON-NLS-1
-				IPageLayout.BOTTOM,
-				0.75f,
-				factory.getEditorArea());
-		bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
-		bottom.addView("org.eclipse.team.ui.GenericHistoryView"); //NON-NLS-1
-		bottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
-
-		IFolderLayout topLeft =
-			factory.createFolder(
-				"topLeft", //NON-NLS-1
-				IPageLayout.LEFT,
-				0.25f,
-				factory.getEditorArea());
-		topLeft.addView(IPageLayout.ID_RES_NAV);
-		topLeft.addView("org.eclipse.jdt.junit.ResultView"); //NON-NLS-1
-		
-		factory.addFastView("org.eclipse.team.ccvs.ui.RepositoriesView",0.50f); //NON-NLS-1
-		factory.addFastView("org.eclipse.team.sync.views.SynchronizeView", 0.50f); //NON-NLS-1
-	}
-
-	private void addActionSets() {
-		factory.addActionSet("org.eclipse.debug.ui.launchActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.debug.ui.debugActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.debug.ui.profileActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.jdt.debug.ui.JDTDebugActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.jdt.junit.JUnitActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.team.ui.actionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.team.cvs.ui.CVSActionSet"); //NON-NLS-1
-		factory.addActionSet("org.eclipse.ant.ui.actionSet.presentation"); //NON-NLS-1
-		factory.addActionSet(JavaUI.ID_ACTION_SET);
-		factory.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
-		factory.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); //NON-NLS-1
-	}
-
-	private void addPerspectiveShortcuts() {
-		factory.addPerspectiveShortcut("org.eclipse.team.ui.TeamSynchronizingPerspective"); //NON-NLS-1
-		factory.addPerspectiveShortcut("org.eclipse.team.cvs.ui.cvsPerspective"); //NON-NLS-1
-		factory.addPerspectiveShortcut("org.eclipse.ui.resourcePerspective"); //NON-NLS-1
-	}
-
-	private void addNewWizardShortcuts() {
-		factory.addNewWizardShortcut("org.eclipse.team.cvs.ui.newProjectCheckout");//NON-NLS-1
-		factory.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//NON-NLS-1
-		factory.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//NON-NLS-1
-	}
-
-	private void addViewShortcuts() {
-		factory.addShowViewShortcut("org.eclipse.ant.ui.views.AntView"); //NON-NLS-1
-		factory.addShowViewShortcut("org.eclipse.team.ccvs.ui.AnnotateView"); //NON-NLS-1
-		factory.addShowViewShortcut("org.eclipse.pde.ui.DependenciesView"); //NON-NLS-1
-		factory.addShowViewShortcut("org.eclipse.jdt.junit.ResultView"); //NON-NLS-1
-		factory.addShowViewShortcut("org.eclipse.team.ui.GenericHistoryView"); //NON-NLS-1
-		factory.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-		factory.addShowViewShortcut(JavaUI.ID_PACKAGES);
-		factory.addShowViewShortcut(IPageLayout.ID_RES_NAV);
-		factory.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
-		factory.addShowViewShortcut(IPageLayout.ID_OUTLINE);
-	}
-
-}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java	Wed Jan 20 18:00:15 2010 -0800
@@ -61,6 +61,7 @@
 import org.w3c.dom.NodeList;
 
 public class ProjectUtils {
+	private static final String DEFAULT_APTANA_WORKSPACE = "Aptana Studio Workspace";
 	private static final String WRT_PREVIEW_MAIN_HTML = "wrt_preview_main.html";
 	public static final String PREVIEW_FOLDER = "preview";
 	public static final String PREVIEW_FRAME_FILE = "wrt_preview_frame.html";
@@ -250,8 +251,15 @@
 	public static String getDefaultAptanaLocation() {
 		File myDocuments = FileSystemView.getFileSystemView()
 				.getDefaultDirectory();
-		File file = new File(myDocuments, "Aptana Studio Workspace");
-		return file.exists() ? file.getAbsolutePath() : "";
+		File file = new File(myDocuments, DEFAULT_APTANA_WORKSPACE); // Windows
+		if (file.exists()) {
+			return file.getAbsolutePath();
+		}
+		file = new File(myDocuments, "Documents" + File.separator + DEFAULT_APTANA_WORKSPACE); // Mac OS X
+		if (file.exists()) {
+			return file.getAbsolutePath();
+		}
+		return "";
 	}
 
 	public static boolean isAptanaProject(File f) {
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java	Wed Jan 20 16:51:26 2010 -0800
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java	Wed Jan 20 18:00:15 2010 -0800
@@ -24,11 +24,12 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
 
 public class AptanaProjectsImportWizard extends Wizard implements
-		IImportWizard, IExecutableExtension {
+		IImportWizard, INewWizard, IExecutableExtension {
 
 	private AptanaProjectLocationWizardPage mainPage;
 	private IConfigurationElement config;