Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-04-14 17:58:11 +0000
committerSusan Franklin2010-04-14 17:58:11 +0000
commit88e18b045924b05c2ac9a55042482ab5ab025702 (patch)
tree0204617fb1b2e48820cae57289194bb69784de41 /bundles/org.eclipse.equinox.p2.ui.sdk
parent68240f1d5c8f5d6ef8bc1351700d562d14e7630c (diff)
downloadrt.equinox.p2-88e18b045924b05c2ac9a55042482ab5ab025702.tar.gz
rt.equinox.p2-88e18b045924b05c2ac9a55042482ab5ab025702.tar.xz
rt.equinox.p2-88e18b045924b05c2ac9a55042482ab5ab025702.zip
Bug 305810 - [ui] checking for updates can block UI thread if resolution fails
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui.sdk')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/.settings/.api_filters8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/InstallNewSoftwareHandler.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties6
6 files changed, 57 insertions, 8 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/.settings/.api_filters b/bundles/org.eclipse.equinox.p2.ui.sdk/.settings/.api_filters
index 7e9c85365..69033c6c2 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/.settings/.api_filters
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/.settings/.api_filters
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.equinox.p2.ui.sdk" version="2">
+ <resource path="src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java" type="org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler">
+ <filter id="571519004">
+ <message_arguments>
+ <message_argument value="org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler.doExecuteAndLoad()"/>
+ <message_argument value="LoadMetadataRepositoryJob"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/equinox/internal/p2/ui/sdk/RevertProfilePageWithCompare.java" type="org.eclipse.equinox.internal.p2.ui.sdk.RevertProfilePageWithCompare">
<filter id="571473929">
<message_arguments>
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/InstallNewSoftwareHandler.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/InstallNewSoftwareHandler.java
index 621b658e7..0da34d40e 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/InstallNewSoftwareHandler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/InstallNewSoftwareHandler.java
@@ -48,4 +48,9 @@ public class InstallNewSoftwareHandler extends PreloadingRepositoryHandler {
loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true));
}
}
+
+ @Override
+ protected String getProgressTaskName() {
+ return ProvSDKMessages.InstallNewSoftwareHandler_ProgressTaskName;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
index 4139b4fa2..7a20a9f8f 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/PreloadingRepositoryHandler.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.p2.ui.sdk;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.*;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
@@ -45,7 +46,20 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
if (preloadRepositories()) {
//cancel any load that is already running
Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
- final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI());
+ final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI()) {
+ public IStatus runModal(IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, getProgressTaskName(), 1000);
+ IStatus status = super.runModal(sub.newChild(500));
+ if (status.getSeverity() == IStatus.CANCEL)
+ return status;
+ try {
+ doPostLoadBackgroundWork(sub.newChild(500));
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return status;
+ }
+ };
setLoadJobProperties(loadJob);
if (waitForPreload()) {
loadJob.addJobChangeListener(new JobChangeAdapter() {
@@ -66,20 +80,26 @@ abstract class PreloadingRepositoryHandler extends AbstractHandler {
} else {
loadJob.setSystem(true);
loadJob.setUser(false);
- loadJob.setProperty(LoadMetadataRepositoryJob.WIZARD_CLIENT_SHOULD_SCHEDULE, Boolean.toString(true));
- doExecute(loadJob);
+ loadJob.schedule();
+ doExecute(null);
}
} else {
doExecute(null);
}
}
+ protected abstract String getProgressTaskName();
+
protected abstract void doExecute(LoadMetadataRepositoryJob job);
protected boolean preloadRepositories() {
return true;
}
+ protected void doPostLoadBackgroundWork(IProgressMonitor monitor) throws OperationCanceledException {
+ // default is to do nothing more.
+ }
+
protected boolean waitForPreload() {
return true;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
index fbead9ce3..4a258e64c 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java
@@ -24,6 +24,7 @@ public class ProvSDKMessages extends NLS {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, ProvSDKMessages.class);
}
+ public static String InstallNewSoftwareHandler_ProgressTaskName;
public static String PreferenceInitializer_Error;
public static String ProvisioningPreferencePage_AlwaysOpenWizard;
public static String ProvisioningPreferencePage_BrowsingPrefsGroup;
@@ -39,4 +40,5 @@ public class ProvSDKMessages extends NLS {
public static String SDKPolicy_PrefPageName;
public static String UpdateHandler_NoSitesMessage;
public static String UpdateHandler_NoSitesTitle;
+ public static String UpdateHandler_ProgressTaskName;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java
index 07d7e3023..9bdfdb794 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.sdk;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.operations.UpdateOperation;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
@@ -23,6 +24,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
public class UpdateHandler extends PreloadingRepositoryHandler {
boolean hasNoRepos = false;
+ UpdateOperation operation;
protected void doExecute(LoadMetadataRepositoryJob job) {
if (hasNoRepos) {
@@ -34,14 +36,19 @@ public class UpdateHandler extends PreloadingRepositoryHandler {
}
return;
}
- UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
- // check for updates
- operation.resolveModal(null);
if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
getProvisioningUI().openUpdateWizard(false, operation, job);
}
}
+ protected void doPostLoadBackgroundWork(IProgressMonitor monitor) throws OperationCanceledException {
+ operation = getProvisioningUI().getUpdateOperation(null, null);
+ // check for updates
+ IStatus resolveStatus = operation.resolveModal(monitor);
+ if (resolveStatus.getSeverity() == IStatus.CANCEL)
+ throw new OperationCanceledException();
+ }
+
protected boolean preloadRepositories() {
hasNoRepos = false;
RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
@@ -51,4 +58,9 @@ public class UpdateHandler extends PreloadingRepositoryHandler {
}
return super.preloadRepositories();
}
+
+ @Override
+ protected String getProgressTaskName() {
+ return ProvSDKMessages.UpdateHandler_ProgressTaskName;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
index 67c825358..8c95028ec 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2009 IBM Corporation and others.
+# Copyright (c) 2007, 2010 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
# IBM Corporation - initial API and implementation
###############################################################################
+InstallNewSoftwareHandler_ProgressTaskName=Searching for available software...
PreferenceInitializer_Error=Error accessing preferences.
ProvSDKUIActivator_ErrorSavingPrefs=Error saving update preferences
ProvSDKUIActivator_NoSelfProfile=Could not locate the running profile instance. The eclipse.p2.data.area and eclipse.p2.profile properties may not be set correctly in this application's config.ini file.
@@ -23,4 +24,5 @@ ProvisioningPreferencePage_OpenWizardIfInvalid=When software selected for an ins
ProvisioningPreferencePage_PromptToOpenWizard=As&k me what to do when it happens
SDKPolicy_PrefPageName=Available Software Sites
UpdateHandler_NoSitesMessage=There are no update sites to search. Do you wish to open the "Available Software Sites" preferences?
-UpdateHandler_NoSitesTitle=No Updates Found \ No newline at end of file
+UpdateHandler_NoSitesTitle=No Updates Found
+UpdateHandler_ProgressTaskName=Checking for updates...

Back to the top