using IRunnableContext for retrieving BuildTargetTreeNode input so progress dialog can be displayed for wizards or in the status bar when on the UI thread (e.g. ManageConfigurationsDialog)
Removes API in BuildTargetTreeNode that presumed all nodes were SBSv1 (didn't appear to be used anywhere)
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java Tue Aug 31 14:13:15 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/api/builder/ui/ManageConfigurationsDialog.java Tue Aug 31 17:03:48 2010 -0500
@@ -21,6 +21,9 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
@@ -46,6 +49,7 @@
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.dialogs.PreferencesUtil;
@@ -226,7 +230,11 @@
filteringContentProviderWrapper.setConfigFilter(new QtConfigFilter());
}
- drawSDKConfigTree();
+ try {
+ drawSDKConfigTree();
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
BrokenConfigurationInProjectTreeNode[] brokenTreeInput = BrokenConfigurationInProjectTreeNode.getTreeViewerInput(cpi);
if (brokenTreeInput.length > 0) {
@@ -247,7 +255,11 @@
public void widgetSelected(SelectionEvent e) {
// I don't see a way to open it to a specific tab, only the page
if (Window.OK == PreferencesUtil.createPreferenceDialogOn(getShell(), "com.nokia.carbide.cpp.sdk.ui.preferences.BuildPlatformFilterPage", null, null, 0).open()){ //$NON-NLS-1$
- drawSDKConfigTree();
+ try {
+ drawSDKConfigTree();
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
}
}
});
@@ -260,7 +272,11 @@
public void widgetSelected(SelectionEvent e) {
// I don't see a way to open it to a specific tab, only the page
if (Window.OK == PreferencesUtil.createPreferenceDialogOn(getShell(), "com.nokia.carbide.cpp.sdk.ui.preferences.SDKPreferencePage", null, null, 0).open()){ //$NON-NLS-1$
- drawSDKConfigTree();
+ try {
+ drawSDKConfigTree();
+ } catch (CoreException e1) {
+ e1.printStackTrace();
+ }
}
}
});
@@ -270,11 +286,18 @@
return container;
}
- private void drawSDKConfigTree() {
+ private void drawSDKConfigTree() throws CoreException {
boolean sbsv2Project = CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(cpi.getProject());
properSdkViewer.setContentProvider(filteringContentProviderWrapper);
- BuildTargetTreeNode[] sdkConfigTreeNodes = BuildTargetTreeNode.getTreeViewerInput(sbsv2Project);
+ IWorkbenchWindow wbw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ BuildTargetTreeNode[] sdkConfigTreeNodes = null;
+ if (wbw != null){
+ sdkConfigTreeNodes = BuildTargetTreeNode.getTreeViewerInput(sbsv2Project, wbw);
+ } else {
+ IStatus s = new Status(IStatus.ERROR, CarbideBuilderPlugin.PLUGIN_ID, 0, "Error retrieving workbench window. Cannot display configuration tree.", null);
+ throw new CoreException(s);
+ }
if (sbsv2Project){
replaceFilteredConfigsFromProject(sdkConfigTreeNodes);
}
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetTreeNode.java Tue Aug 31 14:13:15 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetTreeNode.java Tue Aug 31 17:03:48 2010 -0500
@@ -19,9 +19,13 @@
package com.nokia.carbide.cpp.sdk.ui.shared;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.TreeNode;
import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildContext;
@@ -112,60 +116,81 @@
* from the SDK preferences page. Only enabled SDK's are used. Each SDK node will
* have build configurations for children appropriate for the SDK. These configurations
* are filtered based on the platform filtering preference panel.
- * @return
- */
- public static BuildTargetTreeNode[] getTreeViewerInput() {
- return getTreeViewerInput(false);
- }
-
- /**
- * Gets the list of SDK tree nodes for use in a tree viewer. The SDK's are gathered
- * from the SDK preferences page. Only enabled SDK's are used. Each SDK node will
- * have build configurations for children appropriate for the SDK. These configurations
- * are filtered based on the platform filtering preference panel.
* @param sbsv2Project true if this is an SBSv2 project which affects how the build
* configuration list is calculated
+ * @param IRunnableContext - a runnable context for which to update a progress monitor. Cannot be null.
* @return array of BuildTargetTreeNode, or null
* @since 1.4
*/
- public static BuildTargetTreeNode[] getTreeViewerInput(boolean sbsv2Project) {
- ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
- List<ISymbianSDK> sdkList = sdkMgr.getSDKList();
- if (sdkList == null)
- return null;
+ public static BuildTargetTreeNode[] getTreeViewerInput(final boolean sbsv2Project, IRunnableContext runnableContext) {
+
+ final List<BuildTargetTreeNode> assembledInput = new ArrayList<BuildTargetTreeNode>();
- List<ISymbianSDK> sdkListCopy = new ArrayList<ISymbianSDK>();
- // Only add SDKs that are enabled
- for (ISymbianSDK currSDK : sdkList){
- if (currSDK.isEnabled()){
- sdkListCopy.add(currSDK);
- }
- }
-
- if (sbsv2Project) {
- // filter non-SBSv2 supported SDK's
- sdkListCopy = SBSv2Utils.getSupportedSDKs(sdkListCopy);
+ try {
+ runnableContext.run(true, false, new IRunnableWithProgress(){
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+
+ String msgPrefix = "Building SDK/Configuration Model: "; //$NON-NLS-N$
+
+ ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
+ List<ISymbianSDK> sdkList = sdkMgr.getSDKList();
+ monitor.beginTask(msgPrefix, sdkList.size() + 2);
+ if (sdkList == null)
+ return;
+
+ monitor.worked(1);
+ List<ISymbianSDK> sdkListCopy = new ArrayList<ISymbianSDK>();
+ // Only add SDKs that are enabled
+ for (ISymbianSDK currSDK : sdkList) {
+ if (currSDK.isEnabled()) {
+ sdkListCopy.add(currSDK);
+ }
+ }
+
+ if (sbsv2Project) {
+ // filter non-SBSv2 supported SDK's
+ sdkListCopy = SBSv2Utils.getSupportedSDKs(sdkListCopy);
+ }
+
+ BuildTargetTreeNode[] input = new BuildTargetTreeNode[sdkListCopy
+ .size()];
+ int index = 0;
+ monitor.worked(1);
+ for (ISymbianSDK sdk : sdkListCopy) {
+ monitor.worked(1);
+ monitor.setTaskName(msgPrefix + sdk.getUniqueId());
+ BuildTargetTreeNode treeNode = new BuildTargetTreeNode(
+ sdk, sbsv2Project);
+ if (treeNode.getChildren() != null || sbsv2Project) {
+ input[index++] = treeNode;
+ }
+ }
+
+ // Filter out any SDKs that don't have configs
+ monitor.worked(1);
+ for (BuildTargetTreeNode currNode : input) {
+ if (currNode != null) {
+ assembledInput.add(currNode);
+ }
+ }
+ monitor.done();
+ }
+
+
+ });
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
- BuildTargetTreeNode[] input = new BuildTargetTreeNode[sdkListCopy.size()];
- int index = 0;
- for (ISymbianSDK sdk : sdkListCopy) {
-
- BuildTargetTreeNode treeNode = new BuildTargetTreeNode(sdk, sbsv2Project);
- if (treeNode.getChildren() != null || sbsv2Project){
- input[index++] = treeNode;
- }
+ if (assembledInput.size() == 0){
+ return null;
}
-
- // Filter out any SDKs that don't have configs
- BuildTargetTreeNode[] realInput = new BuildTargetTreeNode[index];
- index = 0;
- for (BuildTargetTreeNode currNode : input) {
- if (currNode != null){
- realInput[index++] = currNode;
- }
- }
- return realInput;
+
+ return assembledInput.toArray(new BuildTargetTreeNode[assembledInput.size()]);
}
private static String stripSDKIDFromConfigName(String configName, String sdkID){
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetsPage.java Tue Aug 31 14:13:15 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/sdk/ui/shared/BuildTargetsPage.java Tue Aug 31 17:03:48 2010 -0500
@@ -439,7 +439,7 @@
}
if (setInput) {
- viewer.setInput(BuildTargetTreeNode.getTreeViewerInput(useSBSv2Builder));
+ viewer.setInput(BuildTargetTreeNode.getTreeViewerInput(useSBSv2Builder, getContainer()));
}
if (!inited) {
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/wizards/NewSymbianOSCppProjectWizard.java Tue Aug 31 14:13:15 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/wizards/NewSymbianOSCppProjectWizard.java Tue Aug 31 17:03:48 2010 -0500
@@ -22,6 +22,8 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
import com.nokia.carbide.cpp.internal.api.sdk.ISDKManagerInternal;
import com.nokia.carbide.cpp.internal.api.sdk.ui.TemplateSDKsFilter;
@@ -50,6 +52,7 @@
public NewSymbianOSCppProjectWizard() {
super();
+ setNeedsProgressMonitor(true);
setFilterCheckboxLabel(Messages.getString("NewSymbianOSCppProjectWizard.FilterCheckboxLabel")); //$NON-NLS-1$
setTemplateFilter(new TemplateSDKsFilter());
setWindowTitle(Messages.getString("NewSymbianOSCppProjectWizard.WindowTitle")); //$NON-NLS-1$
@@ -80,6 +83,7 @@
String description = Messages.getString("NewSymbianOSCppProjectWizard.NewProjectPageDesc"); //$NON-NLS-1$
newProjectPage = new NewProjectPage(title, description);
pagesAfterTemplateChoice.add(newProjectPage);
+ setNeedsProgressMonitor(true);
buildTargetsPage = new ProjectWizardBuildTargetsPage(this);
pagesAfterTemplateChoice.add(buildTargetsPage);
notifyTemplateChanged();
@@ -88,6 +92,12 @@
}
@Override
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+ super.init(workbench, currentSelection);
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
public String getChooseTemplatePageTitle() {
return Messages.getString("NewSymbianOSCppProjectWizard.ChooseTemplatePageTitle"); //$NON-NLS-1$
}
--- a/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/NewQtCppProjectWizard.java Tue Aug 31 14:13:15 2010 -0500
+++ b/qt/com.nokia.carbide.cpp.qt.ui/src/com/nokia/carbide/cpp/internal/qt/ui/wizard/NewQtCppProjectWizard.java Tue Aug 31 17:03:48 2010 -0500
@@ -33,11 +33,13 @@
public NewQtCppProjectWizard() {
super();
setWindowTitle(Messages.NewQtCppProjectWizard_title);
+ setNeedsProgressMonitor(true);
}
@Override
public List<IWizardDataPage> getPagesAfterTemplateChoice() {
if (pagesAfterTemplateChoice == null) {
+ setNeedsProgressMonitor(true);
pagesAfterTemplateChoice = new ArrayList<IWizardDataPage>();
newProjectPage = new NewProjectPage(Messages.NewQtCppProjectWizard_title, Messages.NewQtCppProjectWizard_desc);