--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/AbstractPreviewPage.java Thu Apr 08 14:59:28 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/AbstractPreviewPage.java Fri Apr 09 11:42:56 2010 -0700
@@ -5,6 +5,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
@@ -12,7 +14,10 @@
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.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.actions.ActionFactory;
@@ -22,178 +27,202 @@
import org.symbian.tools.wrttools.previewer.PreviewerPlugin;
public abstract class AbstractPreviewPage extends Page implements IPreviewPage, ISelectionProvider {
- private final IAction refreshAction = new Action("Refresh") {
- public void run() {
- refresh(true);
- };
- };
- private final IAction toggleRefresh = new Action("Toggle Refresh", IAction.AS_RADIO_BUTTON) {
- public void run() {
- toggleRefresh();
- };
- };
+ private final IAction refreshAction = new Action("Refresh") {
+ public void run() {
+ refresh(true);
+ };
+ };
+ private final IAction toggleRefresh = new Action("Toggle Refresh", IAction.AS_RADIO_BUTTON) {
+ public void run() {
+ toggleRefresh();
+ };
+ };
- protected final IProject project;
- private Browser browser;
- private boolean toggleState = true;
- private final PreviewView previewView;
- private boolean needsRefresh = false;
+ protected IProject project;
+ private Browser browser;
+ private boolean toggleState = true;
+ private final PreviewView previewView;
+ private boolean needsRefresh = false;
+ private Composite pane;
- public AbstractPreviewPage(IProject project, PreviewView previewView) {
- this.project = project;
- this.previewView = previewView;
- }
+ public AbstractPreviewPage(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(true);
- }
- }
+ protected void toggleRefresh() {
+ toggleState = !toggleState;
+ toggleRefresh.setChecked(toggleState);
+ previewView.setProjectAutorefresh(project, toggleState);
+ toggleRefresh.setToolTipText(getToggleActionTooltip());
+ if (toggleState && needsRefresh) {
+ refresh(true);
+ }
+ }
-
- @Override
- public void createControl(Composite parent) {
- browser = createBrowser(parent);
- browser.setUrl(getURI().toASCIIString());
- }
-
- protected abstract Browser createBrowser(Composite parent);
+ @Override
+ public void createControl(Composite parent) {
+ pane = new Composite(parent, SWT.EMBEDDED);
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ pane.setLayout(layout);
+ addBrowser();
+ }
- private URI getURI() {
- return PreviewerPlugin.getDefault().getHttpPreviewer().previewProject(project);
- }
+ private void addBrowser() {
+ browser = createBrowser(pane);
+ browser.setLayoutData(new GridData(GridData.FILL_BOTH));
+ browser.setUrl(getURI().toASCIIString());
+ pane.layout();
+ }
+
+ protected abstract Browser createBrowser(Composite parent);
- @Override
- public Control getControl() {
- return browser;
- }
+ private URI getURI() {
+ return PreviewerPlugin.getDefault().getHttpPreviewer().previewProject(project);
+ }
+
+ @Override
+ public Control getControl() {
+ return pane;
+ }
- @Override
- public void setFocus() {
- if (browser != null && !browser.isDisposed()) {
- browser.setFocus();
- }
- }
-
- private boolean refreshScheduled = false;
+ @Override
+ public void setFocus() {
+ if (browser != null && !browser.isDisposed()) {
+ browser.setFocus();
+ }
+ }
+
+ private boolean refreshScheduled = false;
- public synchronized void process(Collection<IFile> files) {
- if (!refreshScheduled && needsRefresh(files)) {
- asyncExec(new Runnable() {
- public void run() {
- refreshBrowser();
- }
- });
- refreshScheduled = true;
- }
- }
+ public synchronized void process(Collection<IFile> files) {
+ if (!refreshScheduled && needsRefresh(files)) {
+ asyncExec(new Runnable() {
+ public void run() {
+ refreshBrowser();
+ }
+ });
+ refreshScheduled = true;
+ }
+ }
- protected void promptIfNeeded() {
- if (toggleState) {
- toggleState = previewView.promptUserToToggle(project, toggleState);
- toggleRefresh.setChecked(toggleState);
- }
- }
+ protected void promptIfNeeded() {
+ if (toggleState) {
+ toggleState = previewView.promptUserToToggle(project, toggleState);
+ toggleRefresh.setChecked(toggleState);
+ }
+ }
- private void asyncExec(Runnable runnable) {
- getControl().getDisplay().asyncExec(runnable);
- }
+ private void asyncExec(Runnable runnable) {
+ getControl().getDisplay().asyncExec(runnable);
+ }
- private boolean needsRefresh(Collection<IFile> files) {
- for (IFile iFile : files) {
- if (iFile.getProject().equals(project)) {
- return true;
- }
- }
- return false;
- }
+ private boolean needsRefresh(Collection<IFile> files) {
+ for (IFile iFile : files) {
+ if (iFile.getProject().equals(project)) {
+ return true;
+ }
+ }
+ return false;
+ }
- protected synchronized void refresh(boolean manual) {
- try {
- if (!browser.isDisposed()) {
- final Control focusControl = browser.getDisplay().getFocusControl();
- browser.refresh();
- refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC));
- if (!manual && focusControl != null) {
- asyncExec(new Runnable() {
- public void run() {
- focusControl.setFocus();
- }
- });
- }
- refreshAction.setToolTipText("Refresh the preview browser");
- }
- needsRefresh = false;
- } finally {
- refreshScheduled = false;
- }
- }
+ protected synchronized void refresh(boolean manual) {
+ try {
+ if (!isDisposed()) {
+ final Control focusControl = browser.getDisplay().getFocusControl();
+ browser.refresh();
+ refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC));
+ if (!manual && focusControl != null) {
+ asyncExec(new Runnable() {
+ 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();
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ IToolBarManager toolBar = pageSite.getActionBars().getToolBarManager();
contributeToToolbar(toolBar);
- refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC));
- refreshAction.setToolTipText("Refresh the preview browser");
- toolBar.add(refreshAction);
-
- toggleState = previewView.getProjectAutorefresh(project);
-
- toggleRefresh.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.YELLOW_SYNC));
- toggleRefresh.setToolTipText(getToggleActionTooltip());
- toggleRefresh.setChecked(toggleState);
- toolBar.add(toggleRefresh);
-
- pageSite.getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
- getSite().setSelectionProvider(this);
- }
+ refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC));
+ refreshAction.setToolTipText("Refresh the preview browser");
+ toolBar.add(refreshAction);
+
+ toggleState = previewView.getProjectAutorefresh(project);
+
+ toggleRefresh.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.YELLOW_SYNC));
+ toggleRefresh.setToolTipText(getToggleActionTooltip());
+ toggleRefresh.setChecked(toggleState);
+ toolBar.add(toggleRefresh);
+
+ pageSite.getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
+ getSite().setSelectionProvider(this);
+ }
protected void contributeToToolbar(IToolBarManager toolBar) {
// Do nothing here
}
private String getToggleActionTooltip() {
- return toggleState ? "Disable preview autorefresh" : "Enable preview autorefresh";
- }
+ return toggleState ? "Disable preview autorefresh" : "Enable preview autorefresh";
+ }
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- // Do nothing
- }
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ // Do nothing
+ }
+
+ public ISelection getSelection() {
+ return new StructuredSelection(project);
+ }
- public ISelection getSelection() {
- return new StructuredSelection(project);
- }
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ // Do nothing
+ }
- public void removeSelectionChangedListener(
- ISelectionChangedListener listener) {
- // Do nothing
- }
+ public void setSelection(ISelection selection) {
+ // Do nothing
+ }
+
+ public boolean isDisposed() {
+ return browser != null && browser.isDisposed();
+ }
- public void setSelection(ISelection selection) {
- // Do nothing
- }
-
- public boolean isDisposed() {
- return browser != null && browser.isDisposed();
- }
+ private synchronized void refreshBrowser() {
+ if (toggleState) {
+ promptIfNeeded();
+ }
+ if (toggleState) {
+ refresh(false);
+ } else {
+ needsRefresh = true;
+ refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.RED_SYNC));
+ refreshAction.setToolTipText("Refresh the preview browser (there are updated files)");
+ }
+ }
- private synchronized void refreshBrowser() {
- if (toggleState) {
- promptIfNeeded();
- }
- if (toggleState) {
- refresh(false);
- } else {
- needsRefresh = true;
- refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.RED_SYNC));
- refreshAction.setToolTipText("Refresh the preview browser (there are updated files)");
- }
- }
+ public IProject getProject() {
+ return project;
+ }
+
+ public synchronized void projectRenamed(IPath newPath) {
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(newPath.lastSegment());
+ asyncExec(new Runnable() {
+ public void run() {
+ browser.dispose();
+ addBrowser();
+ }
+ });
+ }
}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/IPreviewPage.java Thu Apr 08 14:59:28 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/IPreviewPage.java Fri Apr 09 11:42:56 2010 -0700
@@ -3,9 +3,13 @@
import java.util.Collection;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.part.IPageBookViewPage;
public interface IPreviewPage extends IPageBookViewPage {
void process(Collection<IFile> files);
boolean isDisposed();
+ void projectRenamed(IPath newPath);
+ IProject getProject();
}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Thu Apr 08 14:59:28 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Fri Apr 09 11:42:56 2010 -0700
@@ -20,6 +20,7 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
@@ -258,4 +259,12 @@
return toggle;
}
+ public synchronized void projectRenamed(IProject project, IPath newPath) {
+ IPreviewPage page = projectToPage.remove(project);
+ Boolean refresh = autorefresh.remove(project);
+ page.projectRenamed(newPath);
+ projectToPage.put(page.getProject(), page);
+ autorefresh.put(page.getProject(), refresh);
+ }
+
}
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/RefreshJob.java Thu Apr 08 14:59:28 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/RefreshJob.java Fri Apr 09 11:42:56 2010 -0700
@@ -19,15 +19,20 @@
package org.symbian.tools.wrttools.previewer.preview;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IProject;
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.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -38,10 +43,21 @@
public class RefreshJob extends Job {
private static final class ChangedResourcesCollector implements IResourceDeltaVisitor {
public final Collection<IFile> files = new HashSet<IFile>();
+ public final Collection<IProject> deleted = new HashSet<IProject>();
+ public final Map<IProject, IPath> renamed = new HashMap<IProject, IPath>();
public boolean visit(IResourceDelta delta) throws CoreException {
- if (isRelevantResource(delta.getResource())) {
- IResource resource = delta.getResource();
+ IResource resource = delta.getResource();
+ if (resource.getType() == IResource.PROJECT) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ renamed.put(resource.getProject(), delta.getMovedToPath());
+ } else {
+ deleted.add((IProject) resource);
+ }
+ return false;
+ }
+ } else if (isRelevantResource(resource)) {
if (delta.getKind() == IResourceDelta.ADDED | delta.getKind() == IResourceDelta.REMOVED) {
if (!ProjectUtils.isExcluded(resource)) {
files.add((IFile) resource);
@@ -88,6 +104,9 @@
} catch (CoreException e) {
PreviewerPlugin.log(e);
}
+ for (Entry<IProject, IPath> entry : visitor.renamed.entrySet()) {
+ view.projectRenamed(entry.getKey(), entry.getValue());
+ }
if (visitor.files.size() > 0) {
view.refreshPages(visitor.files);
}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/PackagingInformationDecorator.java Thu Apr 08 14:59:28 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/PackagingInformationDecorator.java Fri Apr 09 11:42:56 2010 -0700
@@ -35,7 +35,7 @@
} else if (element instanceof IAdaptable) {
resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
}
- if (resource != null && ProjectUtils.isExcluded(resource)) {
+ if (resource != null && resource.isAccessible() && ProjectUtils.isExcluded(resource)) {
decoration.addOverlay(WRTImages.getExcludedImageDescriptor(), IDecoration.TOP_RIGHT);
}
}