*** empty log message ***
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/ConfigurationManagerWindow.java b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/ConfigurationManagerWindow.java
index b660655..319438f 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/ConfigurationManagerWindow.java
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/ConfigurationManagerWindow.java
@@ -10,6 +10,13 @@
*******************************************************************************/
package org.eclipse.update.internal.ui;
+import java.util.Hashtable;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
@@ -18,7 +25,9 @@
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -26,17 +35,22 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.update.internal.ui.views.ConfigurationView;
+import org.eclipse.update.ui.UpdateJob;
/**
* Configuration Manager window.
*/
-public class ConfigurationManagerWindow
- extends ApplicationWindow
- {
+public class ConfigurationManagerWindow extends ApplicationWindow {
private ConfigurationView view;
+
private GlobalAction propertiesAction;
+
private IAction propertiesActionHandler;
+
+ private IJobChangeListener jobListener;
+ private Hashtable jobNames;
+
class GlobalAction extends Action implements IPropertyChangeListener {
private IAction handler;
@@ -84,16 +98,18 @@
addMenuBar();
addActions();
addToolBar(SWT.FLAT);
-// addStatusLine();
+ addStatusLine();
}
private void addActions() {
IMenuManager menuBar = getMenuBarManager();
- IMenuManager fileMenu = new MenuManager(UpdateUIMessages.ConfigurationManagerWindow_fileMenu);
+ IMenuManager fileMenu = new MenuManager(
+ UpdateUIMessages.ConfigurationManagerWindow_fileMenu);
menuBar.add(fileMenu);
propertiesAction = new GlobalAction();
- propertiesAction.setText(UpdateUIMessages.ConfigurationManagerWindow_properties);
+ propertiesAction
+ .setText(UpdateUIMessages.ConfigurationManagerWindow_properties);
propertiesAction.setEnabled(false);
fileMenu.add(propertiesAction);
@@ -104,15 +120,15 @@
close();
}
};
- closeAction.setText(UpdateUIMessages.ConfigurationManagerWindow_close);
+ closeAction.setText(UpdateUIMessages.ConfigurationManagerWindow_close);
fileMenu.add(closeAction);
}
-
+
private void hookGlobalActions() {
- if(propertiesActionHandler!=null)
+ if (propertiesActionHandler != null)
propertiesAction.setActionHandler(propertiesActionHandler);
}
-
+
protected Control createContents(Composite parent) {
view = new ConfigurationView(this);
Composite container = new Composite(parent, SWT.NULL);
@@ -121,51 +137,147 @@
layout.verticalSpacing = 0;
container.setLayout(layout);
+ addSeparator(container);
GridData gd;
- Label separator = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.heightHint = 1;
- separator.setLayoutData(gd);
view.createPartControl(container);
Control viewControl = view.getControl();
gd = new GridData(GridData.FILL_BOTH);
viewControl.setLayoutData(gd);
+
+ addSeparator(container);
+
hookGlobalActions();
updateActionBars();
UpdateLabelProvider provider = UpdateUI.getDefault().getLabelProvider();
getShell().setImage(provider.get(UpdateUIImages.DESC_CONFIGS_VIEW, 0));
-
+
return container;
}
+ public void updateStatusLine(String message, Image image) {
+ getStatusLineManager().setMessage(image, message);
+ getStatusLineManager().update(true);
+ }
+
+ public void trackUpdateJob(Job job, String name) {
+ if (jobListener == null) {
+ jobNames = new Hashtable();
+ jobListener = new IJobChangeListener() {
+ public void aboutToRun(IJobChangeEvent event) {
+ }
+
+ public void awake(IJobChangeEvent event) {
+ }
+
+ public void done(IJobChangeEvent event) {
+ Job job = event.getJob();
+ if (job.belongsTo(UpdateJob.FAMILY)) {
+ Job [] remaining = Platform.getJobManager().find(UpdateJob.FAMILY);
+ updateProgress(false, remaining);
+ jobNames.remove(job);
+ }
+ }
+
+ public void running(IJobChangeEvent event) {
+ Job job = event.getJob();
+ if (job.belongsTo(UpdateJob.FAMILY)) {
+ Job [] existing = Platform.getJobManager().find(UpdateJob.FAMILY);
+ updateProgress(true, existing);
+ }
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+ }
+ };
+ Platform.getJobManager().addJobChangeListener(jobListener);
+ }
+ jobNames.put(job, name);
+ }
+
+ private void updateProgress(final boolean begin, final Job[] jobs) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IProgressMonitor monitor = getStatusLineManager()
+ .getProgressMonitor();
+ if (begin) {
+ if (jobs.length == 1)
+ monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ updateTaskName(monitor, jobs);
+ } else {
+ if (jobs.length == 0) {
+ monitor.done();
+ }
+ else
+ updateTaskName(monitor, jobs);
+ }
+ getStatusLineManager().update(true);
+ }
+ });
+ }
+
+ private void updateTaskName(IProgressMonitor monitor, Job [] jobs) {
+ StringBuffer buf = new StringBuffer();
+ for (int i=0; i<jobs.length; i++) {
+ String name = (String)jobNames.get(jobs[i]);
+ if (name!=null) {
+ if (buf.length()>0)
+ buf.append(", "); //$NON-NLS-1$
+ buf.append(name);
+ }
+ }
+ monitor.subTask(NLS.bind(
+ UpdateUIMessages.ConfigurationManagerWindow_searchTaskName,
+ buf.toString())); //$NON-NLS-1$
+ }
+
+ private void addSeparator(Composite parent) {
+ GridData gd;
+ Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.heightHint = 1;
+ separator.setLayoutData(gd);
+ }
+
private void updateActionBars() {
getMenuBarManager().updateAll(false);
getToolBarManager().update(false);
-// getStatusLineManager().update(false);
+ getStatusLineManager().update(false);
}
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.window.Window#close()
*/
public boolean close() {
+ if (jobListener != null)
+ Platform.getJobManager().removeJobChangeListener(jobListener);
if (view != null)
view.dispose();
return super.close();
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.window.Window#create()
*/
public void create() {
super.create();
// set the title
- getShell().setText(UpdateUIMessages.ConfigurationManagerAction_title);
+ getShell().setText(UpdateUIMessages.ConfigurationManagerAction_title);
getShell().setSize(800, 600);
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.window.Window#open()
*/
public int open() {
@@ -173,8 +285,8 @@
updateActionBars();
return super.open();
}
-
- public void setPropertiesActionHandler(IAction handler){
- propertiesActionHandler=handler;
+
+ public void setPropertiesActionHandler(IAction handler) {
+ propertiesActionHandler = handler;
}
}
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIMessages.java b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIMessages.java
index d395484..d154032 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIMessages.java
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIMessages.java
@@ -401,4 +401,7 @@
static {
NLS.initializeMessages(BUNDLE_NAME, UpdateUIMessages.class);
}
+
+ public static String ConfigurationManagerWindow_searchTaskName;
+ public static String FindUpdatesAction_trackedProgress;
}
\ No newline at end of file
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIPluginResources.properties b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIPluginResources.properties
index 5d5b0d1..f5c75de 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIPluginResources.properties
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/UpdateUIPluginResources.properties
@@ -25,6 +25,7 @@
ConfigurationManagerAction_title=Product Configuration
ConfigurationManagerWindow_fileMenu=&File
ConfigurationManagerWindow_properties=&Properties
+ConfigurationManagerWindow_searchTaskName=Searching for updates: {0}
ConfigurationManagerWindow_close=&Close
EditBookmarksAction_edit=Edit Bookmarks...
@@ -229,6 +230,7 @@
SiteStateAction_enableMessage=Do you want to enable features in "{0}"?
FindUpdatesAction_updates=Updates
+FindUpdatesAction_trackedProgress={0} {1}: ({2}%)
InstallationHistoryAction_title=Installation History
InstallationHistoryAction_desc=The list below represents the history of your update activities from the product installation to date. Each operation carries a date it commenced, as well as activities performed. Operations are sorted by date in ascending order.
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/ConfigurationView.java b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/ConfigurationView.java
index 56fb7fc..35c1dfd 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/ConfigurationView.java
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/ConfigurationView.java
@@ -523,7 +523,7 @@
swapVersionAction = new ReplaceVersionAction(getConfigurationWindow().getShell(), UpdateUIMessages.ConfigurationView_anotherVersion);
findUpdatesAction =
- new FindUpdatesAction(getControl().getShell(), UpdateUIMessages.ConfigurationView_findUpdates);
+ new FindUpdatesAction(configurationWindow, UpdateUIMessages.ConfigurationView_findUpdates);
showActivitiesAction = new ShowActivitiesAction(getControl().getShell(), UpdateUIMessages.ConfigurationView_showActivitiesLabel);
PlatformUI.getWorkbench().getHelpSystem().setHelp(
@@ -960,6 +960,15 @@
protected void handleSelectionChanged(IStructuredSelection ssel) {
Object obj = ssel.getFirstElement();
+ if (obj!=null) {
+ ILabelProvider labelProvider = (ILabelProvider)treeViewer.getLabelProvider();
+ String text = labelProvider.getText(obj);
+ //Image img = labelProvider.getImage(obj);
+ Image img = null;
+ configurationWindow.updateStatusLine(text, img);
+ }
+ else
+ configurationWindow.updateStatusLine(null, null);
if (obj instanceof IFeatureAdapter) {
try {
propertiesAction.setEnabled(true);
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/FindUpdatesAction.java b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/FindUpdatesAction.java
index 4e14911..dcc935d 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/FindUpdatesAction.java
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/internal/ui/views/FindUpdatesAction.java
@@ -10,70 +10,134 @@
*******************************************************************************/
package org.eclipse.update.internal.ui.views;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.dialogs.*;
-import org.eclipse.jface.wizard.*;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.update.core.*;
-import org.eclipse.update.internal.operations.*;
-import org.eclipse.update.internal.ui.*;
-import org.eclipse.update.internal.ui.wizards.*;
-import org.eclipse.update.operations.*;
-import org.eclipse.update.search.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.update.core.IFeature;
+import org.eclipse.update.internal.ui.ConfigurationManagerWindow;
+import org.eclipse.update.internal.ui.UpdateUIMessages;
+import org.eclipse.update.internal.ui.wizards.InstallWizard;
+import org.eclipse.update.internal.ui.wizards.InstallWizardOperation;
+import org.eclipse.update.operations.OperationsManager;
+import org.eclipse.update.ui.UpdateJob;
public class FindUpdatesAction extends Action {
private IFeature feature;
- private Shell shell;
- public FindUpdatesAction(Shell shell, String text) {
- super(text);
- this.shell = shell;
+ private ConfigurationManagerWindow window;
+
+ private class TrackingProgressMonitor extends ProgressMonitorWrapper {
+ private String name;
+
+ private String subname;
+
+ private int totalWork;
+
+ private double workSoFar;
+
+ protected TrackingProgressMonitor(IProgressMonitor monitor) {
+ super(monitor);
+ }
+
+ public void beginTask(String name, int totalWork) {
+ this.name = name;
+ this.totalWork = totalWork;
+ super.beginTask(name, totalWork);
+ updateStatus();
+ }
+
+ public void internalWorked(double ticks) {
+ super.internalWorked(ticks);
+ workSoFar += ticks;
+ updateStatus();
+ }
+
+ public void subTask(String subTask) {
+ subname = subTask;
+ super.subTask(subTask);
+ updateStatus();
+ }
+
+ private void updateStatus() {
+ if (window.getShell().isDisposed())
+ return;
+ String perc = ((int) (workSoFar * 100.0) / totalWork) + ""; //$NON-NLS-1$
+ final String message = NLS.bind(UpdateUIMessages.FindUpdatesAction_trackedProgress, new String[] {
+ name, subname, perc });
+ window.getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ window.updateStatusLine(message, null);
+ }
+ });
+ }
}
-
+
+ private class TrackedUpdateJob extends UpdateJob {
+ public TrackedUpdateJob(String name, boolean isAutomatic,
+ boolean download, IFeature[] features) {
+ super(name, isAutomatic, download, features);
+ }
+
+ public IStatus run(IProgressMonitor monitor) {
+ return super.run(new TrackingProgressMonitor(monitor));
+ }
+ }
+
+ public FindUpdatesAction(ConfigurationManagerWindow window, String text) {
+ super(text);
+ this.window = window;
+ }
+
public void setFeature(IFeature feature) {
this.feature = feature;
}
public void run() {
-
- IStatus status = OperationsManager.getValidator().validatePlatformConfigValid();
- if (status != null) {
- ErrorDialog.openError(shell, null, null, status);
- return;
- }
-
- // If current config is broken, confirm with the user to continue
- if (OperationsManager.getValidator().validateCurrentState() != null &&
- !confirm(UpdateUIMessages.Actions_brokenConfigQuestion))
- return;
-
- if (InstallWizard.isRunning()) {
- MessageDialog.openInformation(shell, UpdateUIMessages.InstallWizard_isRunningTitle, UpdateUIMessages.InstallWizard_isRunningInfo);
- return;
- }
-
- IFeature [] features=null;
- if (feature!=null)
- features = new IFeature[] { feature };
- final UpdateSearchRequest searchRequest = UpdateUtils.createNewUpdatesRequest(features);
- BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
- public void run() {
- InstallWizard wizard = new InstallWizard(searchRequest);
- WizardDialog dialog = new ResizableInstallWizardDialog(shell, wizard, UpdateUIMessages.FindUpdatesAction_updates);
- dialog.create();
- dialog.open();
- }
- });
+ IStatus status = OperationsManager.getValidator()
+ .validatePlatformConfigValid();
+ if (status != null) {
+ ErrorDialog.openError(window.getShell(), null, null, status);
+ return;
+ }
+
+ // If current config is broken, confirm with the user to continue
+ if (OperationsManager.getValidator().validateCurrentState() != null
+ && !confirm(UpdateUIMessages.Actions_brokenConfigQuestion))
+ return;
+
+ if (InstallWizard.isRunning()) {
+ MessageDialog.openInformation(window.getShell(),
+ UpdateUIMessages.InstallWizard_isRunningTitle,
+ UpdateUIMessages.InstallWizard_isRunningInfo);
+ return;
+ }
+
+ IFeature[] features = null;
+ if (feature != null)
+ features = new IFeature[] { feature };
+
+ UpdateJob job = new TrackedUpdateJob(
+ UpdateUIMessages.InstallWizard_jobName, false, false, features);
+
+ job.setUser(true);
+ job.setPriority(Job.INTERACTIVE);
+
+ window.trackUpdateJob(job, feature.getLabel());
+ InstallWizardOperation operation = new InstallWizardOperation();
+
+ operation.run(window.getShell(), job);
+
}
-
+
private boolean confirm(String message) {
- return MessageDialog.openConfirm(
- shell,
- UpdateUIMessages.FeatureStateAction_dialogTitle,
- message);
+ return MessageDialog.openConfirm(window.getShell(),
+ UpdateUIMessages.FeatureStateAction_dialogTitle, message);
}
}
diff --git a/update/org.eclipse.update.ui/src/org/eclipse/update/ui/UpdateJob.java b/update/org.eclipse.update.ui/src/org/eclipse/update/ui/UpdateJob.java
index 90380f8..3454c02 100644
--- a/update/org.eclipse.update.ui/src/org/eclipse/update/ui/UpdateJob.java
+++ b/update/org.eclipse.update.ui/src/org/eclipse/update/ui/UpdateJob.java
@@ -35,226 +35,284 @@
import org.eclipse.update.search.UpdateSearchRequest;
/**
- * An UpdateJob performs the lookup for new features or updates to the existing features,
- * depending on how you construct it.
+ * An UpdateJob performs the lookup for new features or updates to the existing
+ * features, depending on how you construct it.
+ *
* @since 3.1
*/
public class UpdateJob extends Job {
-
+
private class SearchResultCollector implements IUpdateSearchResultCollector {
public void accept(IFeature feature) {
- IInstallFeatureOperation operation =
- OperationsManager
- .getOperationFactory()
- .createInstallOperation(null, feature, null, null, null);
+ IInstallFeatureOperation operation = OperationsManager
+ .getOperationFactory().createInstallOperation(null,
+ feature, null, null, null);
updates.add(operation);
}
}
- // job family
- public static final Object family = new Object();
- private IUpdateSearchResultCollector resultCollector;
- private UpdateSearchRequest searchRequest;
- private ArrayList updates;
- private boolean isUpdate;
- private boolean download;
- private boolean isAutomatic;
- private IStatus jobStatus = Status.OK_STATUS;
+ /**
+ * The job family to use for queries
+ */
+ public static final Object FAMILY = new Object();
- /**
- * Use this constructor to search for updates to installed features
- * @param isAutomatic true if automatically searching for updates
- * @param name the job name
- * @param download download updates automatically
- */
- public UpdateJob( String name, boolean isAutomatic, boolean download ) {
+ /**
+ * The job family to use for queries
+ *
+ * @deprecated use FAMILY
+ */
+ public static final Object family = FAMILY;
+
+ private IUpdateSearchResultCollector resultCollector;
+
+ private UpdateSearchRequest searchRequest;
+
+ private ArrayList updates;
+
+ private boolean isUpdate;
+
+ private boolean download;
+
+ private boolean isAutomatic;
+
+ private IStatus jobStatus = Status.OK_STATUS;
+
+ /**
+ * Use this constructor to search for updates to installed features
+ *
+ * @param isAutomatic
+ * true if automatically searching for updates
+ * @param name
+ * the job name
+ * @param download
+ * download updates automatically
+ */
+ public UpdateJob(String name, boolean isAutomatic, boolean download) {
+ this(name, isAutomatic, download, null);
+ }
+
+ /**
+ * Use this constructor to search for updates to installed features
+ *
+ * @param isAutomatic
+ * true if automatically searching for updates
+ * @param name
+ * the job name
+ * @param download
+ * download updates automatically
+ * @param features
+ * the features to search for updates. If you want to search all
+ * features, pass a null array or use the other constructor.
+ */
+ public UpdateJob(String name, boolean isAutomatic, boolean download,
+ IFeature[] features) {
super(name);
- this.isUpdate = true;
- this.isAutomatic = isAutomatic;
- this.download = download;
+ this.isUpdate = true;
+ this.isAutomatic = isAutomatic;
+ this.download = download;
+ updates = new ArrayList();
+ searchRequest = UpdateUtils.createNewUpdatesRequest(features);
+ setPriority(Job.DECORATE);
+ }
+
+ /**
+ * Use this constructor to search for features as indicated by the search
+ * request
+ *
+ * @param name
+ * the job name
+ * @param searchRequest
+ * the search request to execute
+ */
+ public UpdateJob(String name, UpdateSearchRequest searchRequest) {
+ super(name);
+ this.searchRequest = searchRequest;
updates = new ArrayList();
setPriority(Job.DECORATE);
}
- /**
- * Use this constructor to search for features as indicated by the search request
- * @param name the job name
- * @param searchRequest the search request to execute
- */
- public UpdateJob( String name, UpdateSearchRequest searchRequest ) {
- super(name);
- this.searchRequest = searchRequest;
- updates = new ArrayList();
- setPriority(Job.DECORATE);
- }
+ /**
+ * Returns true if the job is performing update lookups, or false when
+ * searching for new features
+ *
+ * @return true when searching for updates of existing features
+ */
+ public boolean isUpdate() {
+ return isUpdate;
+ }
- /**
- * Returns true if the job is performing update lookups, or false when searching for new features
- * @return true when searching for updates of existing features
- */
- public boolean isUpdate() {
- return isUpdate;
- }
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.core.internal.jobs.InternalJob#belongsTo(java.lang.Object)
*/
public boolean belongsTo(Object family) {
- return UpdateJob.family == family;
+ return UpdateJob.FAMILY == family;
}
-
- /**
- * Runs the job and returns the OK status. Call getStatus() to get the actual execution status.
- * @param monitor progress monitor
- * @return IStatus the return code is always OK
- */
- public IStatus run(IProgressMonitor monitor) {
- if (isUpdate)
- jobStatus = runUpdates(monitor);
- else
- jobStatus = runSearchForNew(monitor);
- return Status.OK_STATUS;
- }
-
- private IStatus runSearchForNew(IProgressMonitor monitor) {
- if (UpdateCore.DEBUG) {
- UpdateCore.debug("Search for features started."); //$NON-NLS-1$
- }
- try {
- if (resultCollector == null)
- resultCollector = new ResultCollectorWithMirrors();
- searchRequest.performSearch(resultCollector, monitor);
- if (UpdateCore.DEBUG) {
- UpdateCore.debug("Automatic update search finished - " //$NON-NLS-1$
- + updates.size() + " results."); //$NON-NLS-1$
- }
- return Status.OK_STATUS;
- } catch (CoreException e) {
- return e.getStatus();
- }
- }
-
+ /**
+ * Runs the job and returns the OK status. Call getStatus() to get the
+ * actual execution status.
+ *
+ * @param monitor
+ * progress monitor
+ * @return IStatus the return code is always OK
+ */
+ public IStatus run(IProgressMonitor monitor) {
+ if (isUpdate)
+ jobStatus = runUpdates(monitor);
+ else
+ jobStatus = runSearchForNew(monitor);
+ return Status.OK_STATUS;
+ }
+
+ private IStatus runSearchForNew(IProgressMonitor monitor) {
+ if (UpdateCore.DEBUG) {
+ UpdateCore.debug("Search for features started."); //$NON-NLS-1$
+ }
+
+ try {
+ if (resultCollector == null)
+ resultCollector = new ResultCollectorWithMirrors();
+ searchRequest.performSearch(resultCollector, monitor);
+ if (UpdateCore.DEBUG) {
+ UpdateCore.debug("Automatic update search finished - " //$NON-NLS-1$
+ + updates.size() + " results."); //$NON-NLS-1$
+ }
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
private IStatus runUpdates(IProgressMonitor monitor) {
- ArrayList statusList = new ArrayList();
- if (UpdateCore.DEBUG) {
- if (isAutomatic)
- UpdateCore.debug("Automatic update search started."); //$NON-NLS-1$
- else
- UpdateCore.debug("Update search started."); //$NON-NLS-1$
- }
- searchRequest = UpdateUtils.createNewUpdatesRequest(null);
+ ArrayList statusList = new ArrayList();
+ if (UpdateCore.DEBUG) {
+ if (isAutomatic)
+ UpdateCore.debug("Automatic update search started."); //$NON-NLS-1$
+ else
+ UpdateCore.debug("Update search started."); //$NON-NLS-1$
+ }
- if (resultCollector == null)
- resultCollector = new ResultCollectorWithMirrors();
- try {
- searchRequest.performSearch(resultCollector, monitor);
- } catch (CoreException e) {
- statusList.add(e.getStatus());
- }
- if (UpdateCore.DEBUG) {
- UpdateCore.debug("Automatic update search finished - " //$NON-NLS-1$
- + updates.size() + " results."); //$NON-NLS-1$
- }
- if (updates.size() > 0) {
- // silently download if download enabled
- if (download) {
- if (UpdateCore.DEBUG) {
- UpdateCore.debug("Automatic download of updates started."); //$NON-NLS-1$
- }
- for (int i = 0; i < updates.size(); i++) {
- IInstallFeatureOperation op = (IInstallFeatureOperation) updates
- .get(i);
- IFeature feature = op.getFeature();
- try {
- UpdateUtils.downloadFeatureContent(op.getTargetSite(),
- feature, null, monitor);
- } catch (InstallAbortedException e) {
- return Status.CANCEL_STATUS;
- } catch (CoreException e) {
- statusList.add(e.getStatus());
- updates.remove(i);
- i -= 1;
- }
- }
- if (UpdateCore.DEBUG) {
- UpdateCore.debug("Automatic download of updates finished."); //$NON-NLS-1$
- }
- }
- }
-
- if (statusList.size() == 0)
- return Status.OK_STATUS;
- else if (statusList.size() == 1)
- return (IStatus) statusList.get(0);
- else {
- IStatus[] children = (IStatus[]) statusList
- .toArray(new IStatus[statusList.size()]);
- return new MultiStatus("org.eclipse.update.ui", //$NON-NLS-1$
- ISite.SITE_ACCESS_EXCEPTION, children, Messages.Search_networkProblems, //$NON-NLS-1$
- null);
- }
- }
+ if (resultCollector == null)
+ resultCollector = new ResultCollectorWithMirrors();
+ try {
+ searchRequest.performSearch(resultCollector, monitor);
+ } catch (CoreException e) {
+ statusList.add(e.getStatus());
+ }
+ if (UpdateCore.DEBUG) {
+ UpdateCore.debug("Automatic update search finished - " //$NON-NLS-1$
+ + updates.size() + " results."); //$NON-NLS-1$
+ }
+ if (updates.size() > 0) {
+ // silently download if download enabled
+ if (download) {
+ if (UpdateCore.DEBUG) {
+ UpdateCore.debug("Automatic download of updates started."); //$NON-NLS-1$
+ }
+ for (int i = 0; i < updates.size(); i++) {
+ IInstallFeatureOperation op = (IInstallFeatureOperation) updates
+ .get(i);
+ IFeature feature = op.getFeature();
+ try {
+ UpdateUtils.downloadFeatureContent(op.getTargetSite(),
+ feature, null, monitor);
+ } catch (InstallAbortedException e) {
+ return Status.CANCEL_STATUS;
+ } catch (CoreException e) {
+ statusList.add(e.getStatus());
+ updates.remove(i);
+ i -= 1;
+ }
+ }
+ if (UpdateCore.DEBUG) {
+ UpdateCore.debug("Automatic download of updates finished."); //$NON-NLS-1$
+ }
+ }
+ }
- /**
- * Returns an array of features to install
- * @return IInstallFeatureOperation[]
- */
- public IInstallFeatureOperation[] getUpdates() {
- return (IInstallFeatureOperation[]) updates.toArray(new IInstallFeatureOperation[updates.size()]);
- }
-
- /**
- * Returns the job status upon termination.
- * @return IStatus
- */
- public IStatus getStatus() {
- return jobStatus;
- }
-
- /**
- * Returns the update search request for this job.
- * @return UpdateSearchRequest
- */
- public UpdateSearchRequest getSearchRequest() {
- return searchRequest;
- }
-
- private class ResultCollectorWithMirrors extends SearchResultCollector
- implements IUpdateSearchResultCollectorFromMirror {
-
- private HashMap mirrors = new HashMap(0);
-
- /* (non-Javadoc)
- * @see org.eclipse.update.search.IUpdateSearchResultCollectorFromMirror#getMirror(org.eclipse.update.core.ISite, java.lang.String)
- */
- public IURLEntry getMirror(final ISiteWithMirrors site, final String siteName) {
- //return null;
- if (mirrors.containsKey(site))
- return (IURLEntry)mirrors.get(site);
- try {
- IURLEntry[] mirrorURLs = site.getMirrorSiteEntries();
- if (mirrorURLs.length == 0)
- return null;
- else {
- // here we need to prompt the user
- final IURLEntry[] returnValue = new IURLEntry[1];
- UpdateUI.getStandardDisplay().syncExec(new Runnable() {
- public void run() {
- MirrorsDialog dialog = new MirrorsDialog(UpdateUI.getActiveWorkbenchShell(), site, siteName);
- dialog.create();
- dialog.open();
- IURLEntry mirror = dialog.getMirror();
- mirrors.put(site, mirror);
- returnValue[0] = mirror;
- }
- });
- return returnValue[0];
- }
- } catch (CoreException e) {
- return null;
- }
- }
- }
+ if (statusList.size() == 0)
+ return Status.OK_STATUS;
+ else if (statusList.size() == 1)
+ return (IStatus) statusList.get(0);
+ else {
+ IStatus[] children = (IStatus[]) statusList
+ .toArray(new IStatus[statusList.size()]);
+ return new MultiStatus("org.eclipse.update.ui", //$NON-NLS-1$
+ ISite.SITE_ACCESS_EXCEPTION, children,
+ Messages.Search_networkProblems, //$NON-NLS-1$
+ null);
+ }
+ }
+
+ /**
+ * Returns an array of features to install
+ *
+ * @return IInstallFeatureOperation[]
+ */
+ public IInstallFeatureOperation[] getUpdates() {
+ return (IInstallFeatureOperation[]) updates
+ .toArray(new IInstallFeatureOperation[updates.size()]);
+ }
+
+ /**
+ * Returns the job status upon termination.
+ *
+ * @return IStatus
+ */
+ public IStatus getStatus() {
+ return jobStatus;
+ }
+
+ /**
+ * Returns the update search request for this job.
+ *
+ * @return UpdateSearchRequest
+ */
+ public UpdateSearchRequest getSearchRequest() {
+ return searchRequest;
+ }
+
+ private class ResultCollectorWithMirrors extends SearchResultCollector
+ implements IUpdateSearchResultCollectorFromMirror {
+
+ private HashMap mirrors = new HashMap(0);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.update.search.IUpdateSearchResultCollectorFromMirror#getMirror(org.eclipse.update.core.ISite,
+ * java.lang.String)
+ */
+ public IURLEntry getMirror(final ISiteWithMirrors site,
+ final String siteName) {
+ // return null;
+ if (mirrors.containsKey(site))
+ return (IURLEntry) mirrors.get(site);
+ try {
+ IURLEntry[] mirrorURLs = site.getMirrorSiteEntries();
+ if (mirrorURLs.length == 0)
+ return null;
+ else {
+ // here we need to prompt the user
+ final IURLEntry[] returnValue = new IURLEntry[1];
+ UpdateUI.getStandardDisplay().syncExec(new Runnable() {
+ public void run() {
+ MirrorsDialog dialog = new MirrorsDialog(UpdateUI
+ .getActiveWorkbenchShell(), site, siteName);
+ dialog.create();
+ dialog.open();
+ IURLEntry mirror = dialog.getMirror();
+ mirrors.put(site, mirror);
+ returnValue[0] = mirror;
+ }
+ });
+ return returnValue[0];
+ }
+ } catch (CoreException e) {
+ return null;
+ }
+ }
+ }
}