Fix for Bug 10645, added prompt for restart in bubble help.
authorstechong
Thu, 23 Sep 2010 13:24:28 -0500
changeset 2096 bd274827cfab
parent 2094 90b9cb908a6b
child 2097 0cf5e2f33838
Fix for Bug 10645, added prompt for restart in bubble help.
core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java
core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java	Thu Sep 23 10:16:37 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java	Thu Sep 23 13:24:28 2010 -0500
@@ -17,17 +17,19 @@
 package com.nokia.carbide.cpp.internal.sdk.ui;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
-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.SubMonitor;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
 
 import com.nokia.carbide.cpp.internal.api.sdk.ISBSv2BuildInfo;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuilderID;
@@ -57,6 +59,7 @@
 			protected IStatus run(IProgressMonitor monitor) {
 				boolean installed = false;
 				SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
+				Collection<String> sdkIdList = new ArrayList<String>();
 				int worked = 100 / sdkList.size();
 				for (ISymbianSDK sdk : sdkList) {
 					if (!sdk.isEnabled()){
@@ -71,13 +74,11 @@
 							try {
 								IStatus status = DynamicP2Installer.install(sdk.getUniqueId(), featureDir, subMonitor);
 								if (status.isOK()) {
-									RemoteConnectionsActivator.getStatusDisplay().displayStatus(
-											SDKUIPlugin.makeStatus(IStatus.INFO, "Installed features from\n" + sdk.getUniqueId(), null));
+									sdkIdList.add(sdk.getUniqueId());
 									installed = true;
 								}
 								else if (status.getSeverity() == IStatus.CANCEL) {
-									// TODO was installed 
-									installed = true;
+									// TODO installation canceled 
 								}
 							} catch (Exception e) {
 								// Boog 8383: We should fail silently, since this will not break anything and may SDKs will not have any documentation
@@ -93,7 +94,7 @@
 				
 				if (installed) {
 					// plugins from some SDK were installed
-					//doEclipseRestartDialog(workbench);
+					doEclipseRestartDialog(workbench, sdkIdList);
 				}
 				
 				return Status.OK_STATUS;
@@ -102,24 +103,28 @@
 		job.schedule();
 	}
 
-	public static void doEclipseRestartDialog(final IWorkbench workbench) {
+	public static void doEclipseRestartDialog(final IWorkbench workbench, Collection<String> sdkIdList) {
 		if (WorkbenchUtils.isJUnitRunning()){
 			// Don't show the restart dialog if JUnit is running
 			return;
 		}
-		workbench.getDisplay().asyncExec(new Runnable() {
-			public void run() {
-				IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
-				if (window != null) {
-					Shell shell = window.getShell();
-					// Possible Enhancement: Set the SDKs that have new features so they can be displayed to the user
-					RestartIDEDialog.show(shell,
-							Messages.getString("NewPluginChecker.New_Plugins_Installed") + //$NON-NLS-1$
-					Messages.getString("NewPluginChecker.Restart_Msg")); //$NON-NLS-1$
-				} else {
-					ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.WARNING, SDKUIPlugin.PLUGIN_ID, IStatus.WARNING, Messages.getString("NewPluginChecker.Restart_Error"), null)); //$NON-NLS-1$
+		String message = Messages.getString("NewPluginChecker.New_Plugins_Installed");
+		for (Iterator<String> itr = sdkIdList.iterator(); itr.hasNext();) {
+			String sdkId = itr.next();
+			message += sdkId + "\n";
+		}
+		RemoteConnectionsActivator.getStatusDisplay().displayStatusWithAction(
+			SDKUIPlugin.makeStatus(IStatus.INFO, message, null),
+			Messages.getString("NewPluginChecker.Restart_Msg"),
+			new Runnable() {
+				public void run() {
+					Display.getDefault().asyncExec(new Runnable() {
+						public void run() {
+							PlatformUI.getWorkbench().restart();
+						}
+					});
 				}
 			}
-		});
+		);
 	}
 }
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties	Thu Sep 23 10:16:37 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/messages.properties	Thu Sep 23 13:24:28 2010 -0500
@@ -33,8 +33,8 @@
 BuildPlatformFilterPage.EKA1_Platforms_Label=EKA1 Platforms
 BuildPlatformFilterPage.BSF_Help=Scans for .bsf and/or .var files under \\epoc32\\tools for platform variants.
 BuildPlatformFilterPage.BSF_Label=Discover customization (.bsf) and Symbian Binary Variant (.var) platforms dynamically
-NewPluginChecker.New_Plugins_Installed=New plugins have been installed from an SDK.
-NewPluginChecker.Restart_Msg=\n\nPress "Restart" to restart Carbide.c++ now or "Later" to apply changes next time you restart Carbide.c++.
+NewPluginChecker.New_Plugins_Installed=New plugins have been installed from:\n
+NewPluginChecker.Restart_Msg=Restart Carbide.c++ for the changes to take effect.
 NewPluginChecker.Restart_Error=New plugins were installed into Carbide.c++ from an SDK. However, an error in the workbench prevented a Restart dialog from being displayed. You will need to restart Carbide in order to pick up the latest changes.
 RestartIDEDialog.Restart=Restart
 RestartIDEDialog.Later=Later