core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/sdk/ui/NewPluginChecker.java
changeset 2096 bd274827cfab
parent 2045 00e887c4a2c8
--- 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();
+						}
+					});
 				}
 			}
-		});
+		);
 	}
 }