Bug 11483 use progress dialog instead of workbench window for catalog viewer runnable context
authordadubrow
Tue, 22 Jun 2010 15:25:44 -0500
changeset 1523 2786ba7415f3
parent 1513 8a8e855bd44e
child 1524 13b01d8765f4
Bug 11483 use progress dialog instead of workbench window for catalog viewer runnable context
core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties
core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/view/DiscoveryView.java
--- a/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF	Mon Jun 21 18:45:14 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF	Tue Jun 22 15:25:44 2010 -0500
@@ -14,7 +14,8 @@
  org.eclipse.equinox.p2.operations;bundle-version="2.0.0",
  org.eclipse.equinox.p2.core;bundle-version="2.0.0",
  org.eclipse.equinox.p2.metadata;bundle-version="2.0.0",
- org.eclipse.equinox.p2.repository;bundle-version="2.0.0"
+ org.eclipse.equinox.p2.repository;bundle-version="2.0.0",
+ org.eclipse.equinox.p2.engine;bundle-version="2.0.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-Vendor: Nokia
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java	Mon Jun 21 18:45:14 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Messages.java	Tue Jun 22 15:25:44 2010 -0500
@@ -6,6 +6,8 @@
 	private static final String BUNDLE_NAME = "com.nokia.carbide.discovery.ui.messages"; //$NON-NLS-1$
 	public static String DiscoveryView_AdvancedInstallLabel;
 	public static String DiscoveryView_CheckAllLabel;
+	public static String DiscoveryView_GatherExtensionsTitle;
+	public static String DiscoveryView_GatheringInstallInfoTitle;
 	public static String DiscoveryView_InstallLabel;
 	public static String DiscoveryView_MissingDirectoryURLError;
 	public static String DiscoveryView_RefreshLabel;
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties	Mon Jun 21 18:45:14 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/messages.properties	Tue Jun 22 15:25:44 2010 -0500
@@ -1,5 +1,7 @@
 DiscoveryView_AdvancedInstallLabel=Advanced Install...
 DiscoveryView_CheckAllLabel=Check All Items
+DiscoveryView_GatherExtensionsTitle=Gathering Extensions
+DiscoveryView_GatheringInstallInfoTitle=Gathering Install Information
 DiscoveryView_InstallLabel=Install Checked Items...
 DiscoveryView_MissingDirectoryURLError=Could not find URL in configuration/server.properties file for key={0}
 DiscoveryView_RefreshLabel=Refresh
--- a/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/view/DiscoveryView.java	Mon Jun 21 18:45:14 2010 -0500
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/view/DiscoveryView.java	Tue Jun 22 15:25:44 2010 -0500
@@ -46,7 +46,7 @@
 import org.eclipse.osgi.service.datalocation.Location;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
@@ -58,6 +58,22 @@
 @SuppressWarnings("restriction")
 public class DiscoveryView extends ViewPart {
 	
+	private final class RunnableContextDialog extends ProgressMonitorDialog {
+		private final String title;
+
+		private RunnableContextDialog(Shell parent, String title) {
+			super(parent);
+			this.title = title;
+		}
+
+		@Override
+		protected void configureShell(Shell shell) {
+			super.configureShell(shell);
+			shell.setText(title);
+		}
+		
+	}
+
 	private static final String DIRECTORY_KEY = "com.nokia.carbide.discovery.directory"; //$NON-NLS-1$
 
 	private CatalogViewer viewer;
@@ -66,14 +82,8 @@
 	private BaseSelectionListenerAction checkNoneAction;
 	private BaseSelectionListenerAction installAction;
 	private Action showInstallWizardAction;
-
-	private boolean initialized;
-
 	private ISelectionChangedListener selectionListener;
 
-	public DiscoveryView() {
-	}
-
 	/**
 	 * This is a callback that will allow us
 	 * to create the viewer and initialize it.
@@ -81,7 +91,10 @@
 	public void createPartControl(Composite parent) {
 		Composite c = new Composite(parent, SWT.NONE);
 		GridLayoutFactory.fillDefaults().applyTo(c);
-		viewer = new CatalogViewer(getCatalog(), getSite(), getSite().getWorkbenchWindow(), getConfiguration());
+		viewer = new CatalogViewer(getCatalog(), getSite(), 
+				new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
+						Messages.DiscoveryView_GatherExtensionsTitle), 
+				getConfiguration());
 		viewer.createControl(c);
 		GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
 		
@@ -90,6 +103,12 @@
 				"com.nokia.carbide.discovery.ui.view.DiscoveryView.catalogviewer"); //$NON-NLS-1$
 		makeActions();
 		contributeToActionBars();
+		getSite().getShell().getDisplay().asyncExec(new Runnable() {
+			@Override
+			public void run() {
+				viewer.updateCatalog();
+			}
+		});
 	}
 	
 	private CatalogConfiguration getConfiguration() {
@@ -195,7 +214,9 @@
 		};
 		installAction = new BaseSelectionListenerAction(Messages.DiscoveryView_InstallLabel) {
 			public void run() {
-				DiscoveryUi.install(viewer.getCheckedItems(), new ProgressMonitorDialog(DiscoveryView.this.getViewSite().getShell()));
+				DiscoveryUi.install(viewer.getCheckedItems(), 
+						new RunnableContextDialog(DiscoveryView.this.getViewSite().getShell(), 
+								Messages.DiscoveryView_GatheringInstallInfoTitle));
 			};
 			
 			protected boolean updateSelection(IStructuredSelection selection) {
@@ -238,17 +259,6 @@
 	 * Passing the focus request to the viewer's control.
 	 */
 	public void setFocus() {
-		if (!initialized) {
-			initialized = true;
-			Display.getDefault().asyncExec(new Runnable() {
-				@Override
-				public void run() {
-					if (viewer.getViewer().getContentProvider() != null) {
-						viewer.updateCatalog();
-					}
-				}
-			});
-		}
 	}
 
 	private void showInstallWizard() {