# HG changeset patch # User Ed Swartz # Date 1262712167 21600 # Node ID 9fca333f8b5e374156c860b9d3ecba12a6cf4170 # Parent a5752f0943f6de66afcd10d8399bae41394e7a1b Improve startup performance by recreating SPN view in a Job diff -r a5752f0943f6 -r 9fca333f8b5e project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SPNViewContentProvider.java --- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SPNViewContentProvider.java Tue Jan 05 11:20:53 2010 -0600 +++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SPNViewContentProvider.java Tue Jan 05 11:22:47 2010 -0600 @@ -2535,7 +2535,7 @@ IMemento childMem = memento.getChild(TAG_EXPANDED); if (childMem != null) { - List elements = new ArrayList(); + final List elements = new ArrayList(); for (IMemento project : childMem.getChildren(TAG_IPROJECT)) { String path = project.getString(TAG_PATH); if (path != null) { @@ -2576,12 +2576,16 @@ } } - viewer.setExpandedElements(elements.toArray()); + Display.getDefault().syncExec(new Runnable() { + public void run() { + viewer.setExpandedElements(elements.toArray()); + } + }); } childMem = memento.getChild(TAG_SELECTION); if (childMem != null) { - List list = new ArrayList(); + final List list = new ArrayList(); for (IMemento project : childMem.getChildren(TAG_IPROJECT)) { String path = project.getString(TAG_PATH); if (path != null) { @@ -2622,7 +2626,11 @@ } } - viewer.setSelection(new StructuredSelection(list)); + Display.getDefault().syncExec(new Runnable() { + public void run() { + viewer.setSelection(new StructuredSelection(list)); + } + }); } Integer i = memento.getInteger(TAG_FILTERING_ENABLED); diff -r a5752f0943f6 -r 9fca333f8b5e project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SymbianProjectNavigatorView.java --- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SymbianProjectNavigatorView.java Tue Jan 05 11:20:53 2010 -0600 +++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/views/SymbianProjectNavigatorView.java Tue Jan 05 11:22:47 2010 -0600 @@ -29,6 +29,10 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; +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.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; @@ -57,6 +61,7 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ScrollBar; @@ -169,7 +174,21 @@ viewer.setInput(getViewSite()); if (memento != null) { - restoreState(memento); + final IMemento theMemento = memento; + // this takes a heckuva long time at startup since it leads to loading + // all the CDT metadata, possibly re-parsing bld.inf/mmps, etc... + Job job = new Job("Restoring Symbian Project Navigator") { + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + protected IStatus run(IProgressMonitor monitor) { + restoreState(theMemento); + return Status.OK_STATUS; + } + }; + job.setUser(false); + job.schedule(); } memento = null; @@ -460,28 +479,32 @@ viewer.getControl().setRedraw(true); } - void restoreState(IMemento memento) { + void restoreState(final IMemento memento) { contentProvider.restoreTreeStateAndSelection(memento); - Tree tree = viewer.getTree(); - ScrollBar bar = tree.getVerticalBar(); - if (bar != null) { - try { - String posStr = memento.getString(TAG_VERTICAL_POSITION); - int position = new Integer(posStr).intValue(); - bar.setSelection(position); - } catch (NumberFormatException e) { + Display.getDefault().syncExec(new Runnable() { + public void run() { + Tree tree = viewer.getTree(); + ScrollBar bar = tree.getVerticalBar(); + if (bar != null) { + try { + String posStr = memento.getString(TAG_VERTICAL_POSITION); + int position = new Integer(posStr).intValue(); + bar.setSelection(position); + } catch (NumberFormatException e) { + } + } + bar = tree.getHorizontalBar(); + if (bar != null) { + try { + String posStr = memento.getString(TAG_HORIZONTAL_POSITION); + int position = new Integer(posStr).intValue(); + bar.setSelection(position); + } catch (NumberFormatException e) { + } + } } - } - bar = tree.getHorizontalBar(); - if (bar != null) { - try { - String posStr = memento.getString(TAG_HORIZONTAL_POSITION); - int position = new Integer(posStr).intValue(); - bar.setSelection(position); - } catch (NumberFormatException e) { - } - } + }); } public void saveState(IMemento memento) {