--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Wed Apr 07 13:34:34 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Thu Apr 08 14:59:28 2010 -0700
@@ -50,6 +50,7 @@
import org.eclipse.core.runtime.Path;
import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
import org.symbian.tools.wrttools.util.CoreUtil;
+import org.symbian.tools.wrttools.util.ProjectUtils;
public class WorkspaceResourcesServlet extends HttpServlet {
private static final String PREVIEW_START = "/preview/wrt_preview.html";
@@ -97,7 +98,7 @@
contents = getSpecialResource(path, req.getParameterMap());
if (contents == null) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (file.isAccessible()) {
+ if (file.isAccessible() && !ProjectUtils.isExcluded(file)) {
contents = file.getContents();
}
}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Wed Apr 07 13:34:34 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Thu Apr 08 14:59:28 2010 -0700
@@ -9,7 +9,6 @@
import java.io.OutputStream;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
@@ -19,11 +18,8 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
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.Platform;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -41,45 +37,15 @@
import org.symbian.tools.wrttools.util.ProjectUtils;
public class PreviewView extends PageBookView {
- private static final class ChangedResourcesCollector implements
- IResourceDeltaVisitor {
- public final Collection<IFile> files = new HashSet<IFile>();
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- if (isRelevantResource(delta.getResource())) {
- if ((delta.getFlags() & (IResourceDelta.CONTENT
- | IResourceDelta.COPIED_FROM | IResourceDelta.ENCODING
- | IResourceDelta.LOCAL_CHANGED
- | IResourceDelta.MOVED_FROM | IResourceDelta.MOVED_TO
- | IResourceDelta.MOVED_FROM | IResourceDelta.REPLACED | IResourceDelta.SYNC)) != 0) {
- files.add((IFile) delta.getResource());
- }
- }
- 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() {
public void resourceChanged(IResourceChangeEvent event) {
if (event.getDelta() != null) {
- ChangedResourcesCollector visitor = new ChangedResourcesCollector();
- try {
- event.getDelta().accept(visitor);
- } catch (CoreException e) {
- PreviewerPlugin.log(e);
- }
- refreshPages(visitor.files);
+ new RefreshJob(event.getDelta(), PreviewView.this).schedule();
}
}
};
- private Map<IProject, IPreviewPage> projectToPage = new HashMap<IProject, IPreviewPage>();
+ private final Map<IProject, IPreviewPage> projectToPage = new HashMap<IProject, IPreviewPage>();
private boolean preferencesLoaded = false;
private final Map<IProject, Boolean> autorefresh = new HashMap<IProject, Boolean>();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/RefreshJob.java Thu Apr 08 14:59:28 2010 -0700
@@ -0,0 +1,97 @@
+/**
+ * Copyright (c) 2010 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.previewer.preview;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
+import org.symbian.tools.wrttools.util.ProjectUtils;
+
+public class RefreshJob extends Job {
+ private static final class ChangedResourcesCollector implements IResourceDeltaVisitor {
+ public final Collection<IFile> files = new HashSet<IFile>();
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ if (isRelevantResource(delta.getResource())) {
+ IResource resource = delta.getResource();
+ if (delta.getKind() == IResourceDelta.ADDED | delta.getKind() == IResourceDelta.REMOVED) {
+ if (!ProjectUtils.isExcluded(resource)) {
+ files.add((IFile) resource);
+ }
+ } else if ((delta.getFlags() & (IResourceDelta.CONTENT | IResourceDelta.ENCODING
+ | IResourceDelta.LOCAL_CHANGED | IResourceDelta.REPLACED | IResourceDelta.SYNC)) != 0) {
+ if (!ProjectUtils.isExcluded(resource)) {
+ files.add((IFile) resource);
+ }
+ } else if (delta.getMarkerDeltas().length != 0) {
+ for (IMarkerDelta markerDelta : delta.getMarkerDeltas()) {
+ if (markerDelta.getType().equals(ProjectUtils.EXCLUDE_MARKER_ID)) {
+ files.add((IFile) resource);
+ break;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ public static boolean isRelevantResource(IResource resource) {
+ return resource.getType() == IResource.FILE && !resource.getFullPath().segment(1).equalsIgnoreCase("preview")
+ && !"wgz".equalsIgnoreCase(resource.getFileExtension());
+ }
+
+ private final IResourceDelta delta;
+ private final PreviewView view;
+
+ public RefreshJob(IResourceDelta delta, PreviewView view) {
+ super("Refresh preview browser");
+ this.delta = delta;
+ this.view = view;
+ setRule(ResourcesPlugin.getWorkspace().getRoot());
+ setSystem(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ ChangedResourcesCollector visitor = new ChangedResourcesCollector();
+ try {
+ delta.accept(visitor);
+ } catch (CoreException e) {
+ PreviewerPlugin.log(e);
+ }
+ if (visitor.files.size() > 0) {
+ view.refreshPages(visitor.files);
+ }
+ return Status.OK_STATUS;
+ }
+
+}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/PackageApplicationHandler.java Wed Apr 07 13:34:34 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/handlers/PackageApplicationHandler.java Thu Apr 08 14:59:28 2010 -0700
@@ -23,21 +23,40 @@
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.PlatformUI;
import org.symbian.tools.wrttools.WRTStatusListener;
import org.symbian.tools.wrttools.core.packager.WrtPackageActionDelegate;
import org.symbian.tools.wrttools.util.ProjectUtils;
public class PackageApplicationHandler extends AbstractHandler implements IHandler {
+ private final class JobExtension extends Job {
+ private final IProject project;
+
+ private JobExtension(IProject project) {
+ super(String.format("Package %s", project.getName()));
+ setRule(ResourcesPlugin.getWorkspace().getRoot());
+ this.project = project;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ WRTStatusListener statusListener = new WRTStatusListener();
+ new WrtPackageActionDelegate().packageProject(project, statusListener);
+ return Status.OK_STATUS;
+ }
+ }
public Object execute(ExecutionEvent event) throws ExecutionException {
- IProject project = ProjectUtils.getProjectFromCommandContext(event);
-
+ final IProject project = ProjectUtils.getProjectFromCommandContext(event);
if (project != null) {
PlatformUI.getWorkbench().saveAllEditors(true);
if (project != null) {
- WRTStatusListener statusListener = new WRTStatusListener();
- new WrtPackageActionDelegate().packageProject(project, statusListener);
+ new JobExtension(project).schedule();
}
}
return null;
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Wed Apr 07 13:34:34 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Thu Apr 08 14:59:28 2010 -0700
@@ -84,7 +84,7 @@
@SuppressWarnings("restriction")
public class ProjectUtils {
- private static final String EXCLUDE_MARKER_ID = "org.symbian.tools.wrttools.excluded";
+ public static final String EXCLUDE_MARKER_ID = "org.symbian.tools.wrttools.excluded";
private static final class FocusOnProjectJob extends Job {