Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2007-10-25 18:50:08 -0400
committerSusan Franklin2007-10-25 18:50:08 -0400
commit0773bcb0a9b0eabfb95a943133fcf82b53bc6e19 (patch)
tree497a5019183b298ae63e9e353697c38ebe0613a5
parent1c8f8373b1d9f3514bceb2729c0bafb5c79df0f5 (diff)
downloadrt.equinox.p2-0773bcb0a9b0eabfb95a943133fcf82b53bc6e19.tar.gz
rt.equinox.p2-0773bcb0a9b0eabfb95a943133fcf82b53bc6e19.tar.xz
rt.equinox.p2-0773bcb0a9b0eabfb95a943133fcf82b53bc6e19.zip
Bug 203011 - [prov] support for automatic updating
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AutomaticUpdateScheduler.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKPolicies.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateHandler.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdater.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java95
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/StaticContentProvider.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java126
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUIActivator.java48
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationResult.java52
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationRunner.java123
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUndoSupport.java164
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java66
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/RollbackAction.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ColocatedRepositoryManipulatorGroup.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/InstallDialog.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java)45
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ProfileModificationDialog.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java)22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UninstallDialog.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java)8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateDialog.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java)85
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateInstallDialog.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/DownloadPhaseSet.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallAndConfigurePhaseSet.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/SizingPhaseSet.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UndoableProvisioningOperation.java6
42 files changed, 916 insertions, 516 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java b/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
index 8035820c2..28921e22e 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin.rcp/src/org/eclipse/equinox/p2/ui/admin/rcp/ApplicationWorkbenchWindowAdvisor.java
@@ -29,6 +29,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
configurer.setInitialSize(new Point(800, 600));
configurer.setShowCoolBar(false);
configurer.setShowStatusLine(false);
+ configurer.setShowProgressIndicator(true);
configurer.setTitle(ProvAdminUIMessages.ApplicationWindowTitle);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
index 829327044..a3dc706a5 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProfilesView.java
@@ -12,8 +12,6 @@ package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddProfileDialog;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.UpdateAndInstallDialog;
import org.eclipse.equinox.p2.engine.Profile;
@@ -63,13 +61,9 @@ public class ProfilesView extends ProvView {
}
}
ProfileOperation op = new RemoveProfilesOperation(ProvAdminUIMessages.Ops_RemoveProfileOperationLabel, (Profile[]) profilesOnly.toArray(new Profile[profilesOnly.size()]));
- try {
- IStatus status = ProvisioningUndoSupport.execute(op, null, ProfilesView.this.getShell());
- if (status.isOK()) {
- viewer.refresh();
- }
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
+ ProvisioningOperationResult result = ProvisioningOperationRunner.execute(op, ProfilesView.this.getShell(), null);
+ if (result.getStatus().isOK()) {
+ viewer.refresh();
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
index d00aa9641..73b000352 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ProvView.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.internal.p2.ui.admin;
import java.util.ArrayList;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
-import org.eclipse.equinox.p2.ui.ProvisioningUndoSupport;
+import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
import org.eclipse.equinox.p2.ui.viewers.*;
import org.eclipse.jface.action.*;
@@ -115,7 +115,7 @@ abstract class ProvView extends ViewPart {
protected abstract IAction getDoubleClickAction();
protected void makeActions() {
- undoRedoGroup = new UndoRedoActionGroup(getSite(), ProvisioningUndoSupport.getProvisioningUndoContext(), true);
+ undoRedoGroup = new UndoRedoActionGroup(getSite(), ProvUI.getProvisioningUndoContext(), true);
refreshAction = new Action(ProvAdminUIMessages.ProvView_RefreshCommandLabel) {
public void run() {
viewer.refresh();
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
index 98983856c..1fd66cfcc 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/RepositoriesView.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.equinox.p2.metadata.InstallableUnit;
import org.eclipse.equinox.p2.ui.*;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
@@ -41,13 +40,7 @@ abstract class RepositoriesView extends ProvView {
}
public void run() {
- ProvisioningOperation op = getRemoveOperation(getSelection().toArray());
- try {
- // TODO hook into platform progress service
- ProvisioningUndoSupport.execute(op, null, getShell());
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
- }
+ ProvisioningOperationRunner.execute(getRemoveOperation(getSelection().toArray()), getShell(), null);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
index e3ffdce8c..1bc0493fe 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/AddProfileDialog.java
@@ -10,16 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin.dialogs;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.admin.ProvAdminUIMessages;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.ui.ProvUI;
-import org.eclipse.equinox.p2.ui.ProvisioningUndoSupport;
+import org.eclipse.equinox.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.p2.ui.admin.ProvAdminUIActivator;
import org.eclipse.equinox.p2.ui.operations.AddProfileOperation;
-import org.eclipse.equinox.p2.ui.operations.ProfileOperation;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.events.ModifyEvent;
@@ -62,29 +59,20 @@ public class AddProfileDialog extends StatusDialog {
}
protected void okPressed() {
- if (addProfile()) {
- super.okPressed();
- }
+ addProfile();
+ super.okPressed();
}
/*
* We only get here if already validated (ok was pressed)
*/
- private boolean addProfile() {
+ private void addProfile() {
profileGroup.updateProfile();
addedProfile = profileGroup.getProfile();
if (addedProfile == null) {
- return false;
- }
- ProfileOperation op = new AddProfileOperation(ProvAdminUIMessages.AddProfileDialog_OperationLabel, addedProfile);
- try {
- ProvisioningUndoSupport.execute(op, null, getShell());
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
- return false;
+ return;
}
- return true;
-
+ ProvisioningOperationRunner.execute(new AddProfileOperation(ProvAdminUIMessages.AddProfileDialog_OperationLabel, addedProfile), getShell(), null);
}
void verifyComplete() {
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
index b6f8f0b70..96d4a686b 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/UpdateAndInstallDialog.java
@@ -60,8 +60,8 @@ public class UpdateAndInstallDialog extends TrayDialog {
filters = new ViewerFilter[] {new IUGroupFilter()};
}
UpdateAndInstallGroup group = new UpdateAndInstallGroup(parent, profile, filters, filters, ProvAdminUIMessages.UpdateAndInstallDialog_InstalledIUsPageLabel, ProvAdminUIMessages.UpdateAndInstallDialog_AvailableIUsPageLabel, null, null, fontMetrics);
- Dialog.applyDialogFont(group.getControl());
- return group.getControl();
+ Dialog.applyDialogFont(group.getTabFolder());
+ return group.getTabFolder();
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AutomaticUpdateScheduler.java
index 3b5e57d9c..7d281ec74 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AutomaticUpdateScheduler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/AutomaticUpdateScheduler.java
@@ -49,7 +49,7 @@ public class AutomaticUpdateScheduler implements IStartup {
checker = (UpdateChecker) ServiceHelper.getService(ProvSDKUIActivator.getContext(), UpdateChecker.class.getName());
if (checker == null) {
// Something did not initialize properly
- IStatus status = new Status(IStatus.ERROR, ProvSDKUIActivator.PLUGIN_ID, "The update checker service is not initialized");
+ IStatus status = new Status(IStatus.ERROR, ProvSDKUIActivator.PLUGIN_ID, ProvSDKMessages.AutomaticUpdateScheduler_UpdateNotInitialized);
StatusManager.getManager().handle(status, StatusManager.LOG);
return;
}
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 9cd0d32d6..61eaf454b 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
@@ -28,8 +28,8 @@ public class ProvSDKMessages extends NLS {
public static String UpdateAndInstallDialog_AvailableFeatures;
public static String UpdateAndInstallDialog_InstalledFeatures;
public static String UpdateAndInstallDialog_ManageSites;
- public static String UpdateAndInstallDialog_0;
- public static String UpdateAndInstallDialog_1;
+ public static String UpdateAndInstallDialog_AlertCheckbox;
+ public static String UpdateAndInstallDialog_PrefLink;
public static String UpdateAndInstallDialog_Title;
public static String UpdateHandler_NoProfilesDefined;
public static String UpdateHandler_NoProfileInstanceDefined;
@@ -68,16 +68,19 @@ public class ProvSDKMessages extends NLS {
public static String SchedulerStartup_12AM;
public static String AutomaticUpdatesJob_AutomaticUpdateSearch;
public static String AutomaticUpdatesPreferencePage_findUpdates;
+ public static String AutomaticUpdateScheduler_UpdateNotInitialized;
+ public static String AutomaticUpdatesDialog_DownloadedNotification;
+ public static String AutomaticUpdatesDialog_UpdatesAvailableTitle;
+ public static String AutomaticUpdater_AutomaticDownloadOperationName;
+ public static String AutomaticUpdatesDialog_UpdatesFoundNotification;
public static String AutomaticUpdatesPreferencePage_UpdateSchedule;
public static String AutomaticUpdatesPreferencePage_findOnStart;
public static String AutomaticUpdatesPreferencePage_findOnSchedule;
public static String AutomaticUpdatesPreferencePage_downloadOptions;
public static String AutomaticUpdatesPreferencePage_searchAndNotify;
public static String AutomaticUpdatesPreferencePage_downloadAndNotify;
- public static String AutomaticUpdatesJob_EclipseUpdates1;
- public static String AutomaticUpdatesJob_UpdatesAvailable;
- public static String AutomaticUpdatesJob_EclipseUpdates2;
public static String AutomaticUpdatesPreferencePage_at;
- public static String AutomaticUpdatesJob_UpdatesDownloaded;
public static String AutomaticUpdatesJob_Updates;
+ public static String AutomaticUpdatesDialog_ClickToReviewDownloaded;
+ public static String AutomaticUpdatesDialog_ClickToReviewNotDownloaded;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKPolicies.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKPolicies.java
new file mode 100644
index 000000000..337e3be1f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKPolicies.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui.sdk;
+
+import java.util.ArrayList;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
+import org.eclipse.equinox.p2.ui.viewers.IUGroupFilter;
+import org.eclipse.equinox.p2.ui.viewers.IUProfilePropertyFilter;
+import org.eclipse.equinox.p2.updatechecker.UpdateEvent;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Implements policy-style decisions about what is shown in the UI.
+ *
+ * @since 3.4
+ */
+
+public class ProvSDKPolicies extends AbstractUIPlugin {
+
+ public static ViewerFilter getInstalledIUFilter() {
+ return new IUProfilePropertyFilter(IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
+ }
+
+ public static ViewerFilter getAvailableIUFilter() {
+ return new IUGroupFilter();
+ }
+
+ public static IInstallableUnit[] getUpdatesToShow(UpdateEvent event) {
+ // TODO hardcoded to only show install roots, there is probably
+ // more policy here.
+ IInstallableUnit[] ius = event.getIUs();
+ ArrayList roots = new ArrayList();
+ for (int i = 0; i < ius.length; i++) {
+ String value = event.getProfile().getInstallableUnitProfileProperty(ius[i], IInstallableUnitConstants.PROFILE_ROOT_IU);
+ if (value != null && value.equals(Boolean.toString(true))) {
+ roots.add(ius[i]);
+ }
+ }
+ return (IInstallableUnit[]) roots.toArray(new IInstallableUnit[roots.size()]);
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
index 35f703145..e8c951d6a 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/UpdateAndInstallDialog.java
@@ -15,11 +15,8 @@ import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.ui.IRepositoryManipulator;
import org.eclipse.equinox.p2.ui.dialogs.UpdateAndInstallGroup;
-import org.eclipse.equinox.p2.ui.viewers.IUGroupFilter;
-import org.eclipse.equinox.p2.ui.viewers.IUProfilePropertyFilter;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.PreferenceDialog;
@@ -42,7 +39,10 @@ import org.eclipse.ui.dialogs.PreferencesUtil;
*/
public class UpdateAndInstallDialog extends TrayDialog {
+ private static final String DIALOG_SETTINGS_SECTION = "UpdateAndInstallDialog"; //$NON-NLS-1$
+ private static final String SELECTED_TAB_SETTING = "SelectedTab"; //$NON-NLS-1$
private Profile profile;
+ private UpdateAndInstallGroup group;
/**
* Create an instance of this Dialog.
@@ -51,6 +51,8 @@ public class UpdateAndInstallDialog extends TrayDialog {
public UpdateAndInstallDialog(Shell shell, Profile profile) {
super(shell);
this.profile = profile;
+ setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.MAX | SWT.RESIZE | getDefaultOrientation());
+ setBlockOnOpen(false);
}
protected void configureShell(Shell shell) {
@@ -69,12 +71,10 @@ public class UpdateAndInstallDialog extends TrayDialog {
FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose();
- ViewerFilter filter = new IUProfilePropertyFilter(IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
- UpdateAndInstallGroup group = new UpdateAndInstallGroup(comp, profile, new ViewerFilter[] {filter}, new ViewerFilter[] {new IUGroupFilter()}, ProvSDKMessages.UpdateAndInstallDialog_InstalledFeatures, ProvSDKMessages.UpdateAndInstallDialog_AvailableFeatures, getRepositoryManipulator(), null, fontMetrics);
-
+ group = new UpdateAndInstallGroup(comp, profile, new ViewerFilter[] {ProvSDKPolicies.getInstalledIUFilter()}, new ViewerFilter[] {ProvSDKPolicies.getAvailableIUFilter()}, ProvSDKMessages.UpdateAndInstallDialog_InstalledFeatures, ProvSDKMessages.UpdateAndInstallDialog_AvailableFeatures, getRepositoryManipulator(), null, fontMetrics);
final Button checkBox = new Button(comp, SWT.CHECK);
final Preferences pref = ProvSDKUIActivator.getDefault().getPluginPreferences();
- checkBox.setText(ProvSDKMessages.UpdateAndInstallDialog_0);
+ checkBox.setText(ProvSDKMessages.UpdateAndInstallDialog_AlertCheckbox);
checkBox.setSelection(pref.getBoolean(PreferenceConstants.P_ENABLED));
checkBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -102,8 +102,9 @@ public class UpdateAndInstallDialog extends TrayDialog {
dialog.open();
}
});
- updatePrefsLink.setText(ProvSDKMessages.UpdateAndInstallDialog_1);
- Dialog.applyDialogFont(group.getControl());
+ updatePrefsLink.setText(ProvSDKMessages.UpdateAndInstallDialog_PrefLink);
+ readDialogSettings();
+ Dialog.applyDialogFont(comp);
return comp;
}
@@ -130,4 +131,34 @@ public class UpdateAndInstallDialog extends TrayDialog {
};
}
+
+ protected void okPressed() {
+ saveDialogSettings();
+ super.okPressed();
+ }
+
+ private void readDialogSettings() {
+ IDialogSettings settings = ProvSDKUIActivator.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section != null) {
+ if (group != null && !group.getTabFolder().isDisposed()) {
+ group.getTabFolder().setSelection(section.getInt(SELECTED_TAB_SETTING));
+ }
+ }
+ }
+
+ private void saveDialogSettings() {
+ if (!group.getTabFolder().isDisposed()) {
+ getDialogBoundsSettings().put(SELECTED_TAB_SETTING, group.getTabFolder().getSelectionIndex());
+ }
+ }
+
+ protected IDialogSettings getDialogBoundsSettings() {
+ IDialogSettings settings = ProvSDKUIActivator.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section == null) {
+ section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
+ }
+ return section;
+ }
}
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 48ed97503..0c8b6707f 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
@@ -18,7 +18,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
/**
- * UpdateHandler invokes the new provisioning update UI.
+ * AutomaticUpdatesPopup invokes the new provisioning update UI.
*
* @since 3.4
*/
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 2e59d7c15..ece72a675 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
@@ -8,10 +8,10 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
-UpdateAndInstallDialog_InstalledFeatures=Installed Features
-UpdateAndInstallDialog_AvailableFeatures=Available Features
-UpdateAndInstallDialog_0=Alert me when updates are available
-UpdateAndInstallDialog_1=Specify the update schedule and other <a>update preferences</a>
+UpdateAndInstallDialog_InstalledFeatures=&Installed Features
+UpdateAndInstallDialog_AvailableFeatures=&Available Features
+UpdateAndInstallDialog_AlertCheckbox=Alert me when updates are available
+UpdateAndInstallDialog_PrefLink=Specify the update schedule and other <a>Update Preferences</a>
UpdateAndInstallDialog_Title=Software Updates and Add-ons
UpdateAndInstallDialog_ManageSites=&Manage sites...
UpdateHandler_SDKUpdateUIMessageTitle=Software Updates
@@ -52,15 +52,18 @@ SchedulerStartup_11PM=11:00 PM
SchedulerStartup_12AM=12:00 AM
AutomaticUpdatesJob_AutomaticUpdateSearch=Automatic Update Search
AutomaticUpdatesPreferencePage_findUpdates=Automatically &find new updates and notify me
+AutomaticUpdateScheduler_UpdateNotInitialized=The update checker service is not initialized
+AutomaticUpdatesDialog_DownloadedNotification=Updates have been downloaded. You may review and install them when you are ready.
+AutomaticUpdatesDialog_UpdatesAvailableTitle=Updates Available
+AutomaticUpdater_AutomaticDownloadOperationName=Automatic updates download
+AutomaticUpdatesDialog_UpdatesFoundNotification=There are updates available for your software. You may review and install them when you are ready.
AutomaticUpdatesPreferencePage_UpdateSchedule=Update &Schedule
AutomaticUpdatesPreferencePage_findOnStart=Look for updates each time &platform is started
AutomaticUpdatesPreferencePage_findOnSchedule=&Look for updates on the following schedule:
AutomaticUpdatesPreferencePage_downloadOptions=Download &Options
AutomaticUpdatesPreferencePage_searchAndNotify=Search for updates and &notify me when they are available
AutomaticUpdatesPreferencePage_downloadAndNotify=Download new &updates automatically and notify me when ready to install them
-AutomaticUpdatesJob_EclipseUpdates1=Automatic Updates
-AutomaticUpdatesJob_UpdatesAvailable=New updates are available. Do you want to review and install them now?
-AutomaticUpdatesJob_EclipseUpdates2=Automatic Updates
+AutomaticUpdatesDialog_ClickToReviewDownloaded=Software updates have been downloaded.\nClick here to <a>Review and Install Updates</a>.
+AutomaticUpdatesDialog_ClickToReviewNotDownloaded=Updates are available for your software.\nClick here to <a>Review and Install Updates</a>.
AutomaticUpdatesPreferencePage_at=at
-AutomaticUpdatesJob_UpdatesDownloaded=New updates are available and downloaded. Do you want to review and install them now?
AutomaticUpdatesJob_Updates=Updates \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdater.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdater.java
index cf0bae93f..346d3fbd5 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdater.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdater.java
@@ -11,10 +11,16 @@
package org.eclipse.equinox.internal.p2.ui.sdk.updates;
import org.eclipse.core.runtime.Preferences;
-import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
+import org.eclipse.equinox.internal.p2.ui.sdk.*;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.operations.*;
import org.eclipse.equinox.p2.updatechecker.IUpdateListener;
import org.eclipse.equinox.p2.updatechecker.UpdateEvent;
+import org.eclipse.ui.PlatformUI;
/**
* @since 3.4
@@ -28,11 +34,30 @@ public class AutomaticUpdater implements IUpdateListener {
}
- public void updatesAvailable(UpdateEvent event) {
- boolean download = prefs.getBoolean(PreferenceConstants.P_DOWNLOAD);
- if (download) {
- // TODO not implemented
+ public void updatesAvailable(final UpdateEvent event) {
+ final boolean download = prefs.getBoolean(PreferenceConstants.P_DOWNLOAD);
+ final IInstallableUnit[] toUpdate = (ProvSDKPolicies.getUpdatesToShow(event));
+ if (toUpdate.length <= 0)
+ return;
+ try {
+ if (download) {
+ IInstallableUnit[] replacements = ProvisioningUtil.updatesFor(toUpdate, null);
+ if (replacements.length > 0) {
+ final ProvisioningPlan plan = ProvisioningUtil.getPlanner().getReplacePlan(toUpdate, replacements, event.getProfile(), null);
+ ProvisioningOperationResult result = ProvisioningOperationRunner.execute(new ProfileModificationOperation(ProvSDKMessages.AutomaticUpdater_AutomaticDownloadOperationName, event.getProfile().getProfileId(), plan, new DownloadPhaseSet(), false), null, null);
+ // TODO need to listen to the job and open the popup when download is done
+ }
+ } else {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ new AutomaticUpdatesPopup(toUpdate, event.getProfile(), download).open();
+ }
+ });
+ }
+
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
}
- }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java
new file mode 100644
index 000000000..6b3e3c55f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/updates/AutomaticUpdatesPopup.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.ui.sdk.updates;
+
+import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages;
+import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.dialogs.UpdateDialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.PopupDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * AutomaticUpdatesPopup is an async popup dialog for notifying
+ * the user of updates.
+ *
+ * @since 3.4
+ */
+public class AutomaticUpdatesPopup extends PopupDialog {
+ private static final int CHAR_HEIGHT = 5;
+ private static final int CHAR_WIDTH = 40;
+ private static final String DIALOG_SETTINGS_SECTION = "AutomaticUpdatesPopup"; //$NON-NLS-1$
+ IInstallableUnit[] toUpdate;
+ Profile profile;
+ boolean downloaded;
+
+ public AutomaticUpdatesPopup(IInstallableUnit[] toUpdate, Profile profile, boolean alreadyDownloaded) {
+ super((Shell) null, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE | SWT.MODELESS, true, true, false, false, ProvSDKMessages.AutomaticUpdatesDialog_UpdatesAvailableTitle, null);
+ downloaded = alreadyDownloaded;
+ this.profile = profile;
+ this.toUpdate = toUpdate;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ Link infoLink = new Link(parent, SWT.MULTI | SWT.WRAP);
+ if (downloaded)
+ infoLink.setText(ProvSDKMessages.AutomaticUpdatesDialog_ClickToReviewDownloaded);
+ else
+ infoLink.setText(ProvSDKMessages.AutomaticUpdatesDialog_ClickToReviewNotDownloaded);
+ infoLink.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ new UpdateDialog(null, toUpdate, profile).open();
+ }
+ });
+ infoLink.setLayoutData(new GridData(GridData.FILL_BOTH));
+ return composite;
+
+ }
+
+ protected Point getInitialSize() {
+ return charToPixels(new Point(CHAR_WIDTH, CHAR_HEIGHT));
+ }
+
+ private Point charToPixels(Point charBounds) {
+ int x = charBounds.x;
+ int y = charBounds.y;
+ GC gc = new GC(getContents());
+ gc.setFont(JFaceResources.getDialogFont());
+ FontMetrics fontMetrics = gc.getFontMetrics();
+ x = x * fontMetrics.getAverageCharWidth();
+ y = y * fontMetrics.getHeight();
+ gc.dispose();
+ return new Point(x, y);
+ }
+
+ protected IDialogSettings getDialogBoundsSettings() {
+ IDialogSettings settings = ProvSDKUIActivator.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
+ if (section == null) {
+ section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
+ }
+ return section;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
index 1ad109cb1..066c32e79 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java
@@ -106,9 +106,11 @@ public class ProvUIMessages extends NLS {
public static String AddRepositoryDialog_Title;
public static String UpdateAction_UpdateInformationTitle;
public static String UpdateAction_UpdatesAvailableMessage;
+ public static String UpdateDialog_AssemblingUpdatesProgress;
public static String UpdateAction_UpdatesAvailableTitle;
public static String PlatformUpdateTitle;
public static String PlatformRestartMessage;
+ public static String ProvUI_InformationTitle;
public static String ProvUI_NameColumnTitle;
public static String ProvUI_SizeColumnTitle;
public static String ProvUI_VersionColumnTitle;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/StaticContentProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/StaticContentProvider.java
index 038d3d662..80b92879f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/StaticContentProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/StaticContentProvider.java
@@ -1,6 +1,14 @@
-/**
- *
- */
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
package org.eclipse.equinox.internal.p2.ui;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -9,7 +17,7 @@ import org.eclipse.jface.viewers.Viewer;
public final class StaticContentProvider implements IStructuredContentProvider {
private final Object[] elements;
- StaticContentProvider(Object[] elements) {
+ public StaticContentProvider(Object[] elements) {
this.elements = elements;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
index 2a4050b0f..60f74b8ba 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties
@@ -78,6 +78,7 @@ UpdateAndInstallSelectionDialog_DeselectAllLabel=&Deselect All
UpdateAndInstallSelectionDialog_SelectAllLabel=&Select All
UpdateAction_UpdateInformationTitle=Update Information
UpdateAction_UpdatesAvailableMessage=Select the updates you wish to install.
+UpdateDialog_AssemblingUpdatesProgress=Assembling updates
UpdateAction_UpdatesAvailableTitle=Available Updates
UpdateOperation_NothingToUpdate=There is nothing to update.
UpdateAndInstallGroup_Refresh=&Refresh
@@ -94,6 +95,7 @@ IUPropertiesGroup_CopyrightProperty=Copyright
PlatformUpdateTitle = Software Updates
PlatformRestartMessage = You will need to restart the system for the changes to take effect. \
Would you like to restart now?
+ProvUI_InformationTitle=Information
ProvUI_NameColumnTitle=Name
ProvUI_SizeColumnTitle=Size
ProvUI_VersionColumnTitle=Version
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
index 6c9ccd107..20535c671 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUI.java
@@ -12,12 +12,18 @@
package org.eclipse.equinox.p2.ui;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.configurator.Configurator;
import org.eclipse.equinox.internal.p2.ui.ApplyProfileChangesDialog;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
@@ -41,7 +47,8 @@ public class ProvUI {
public static final String ROLLBACK_COMMAND_LABEL = ProvUIMessages.RollbackIUCommandLabel;
public static final String ROLLBACK_COMMAND_TOOLTIP = ProvUIMessages.RollbackIUCommandTooltip;
- private static IUColumnConfig[] iuColumnConfig = new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME), new IUColumnConfig(ProvUIMessages.ProvUI_IDColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION)};
+ static ObjectUndoContext provisioningUndoContext;
+ private static IUColumnConfig[] iuColumnConfig = new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION)};
public static Shell getShell(IAdaptable uiInfo) {
Shell shell;
@@ -63,15 +70,21 @@ public class ProvUI {
return display.getActiveShell();
}
- public static void handleException(Throwable t, String message) {
+ public static IStatus handleException(Throwable t, String message) {
if (message == null && t != null) {
message = t.getMessage();
}
IStatus status = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, message, t);
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
+ return status;
}
public static void reportStatus(IStatus status) {
+ // TODO investigate why platform status manager is so ugly with INFO status
+ if (status.getSeverity() == IStatus.INFO) {
+ MessageDialog.openInformation(null, ProvUIMessages.ProvUI_InformationTitle, status.getMessage());
+ return;
+ }
StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.LOG);
}
@@ -96,4 +109,113 @@ public class ProvUI {
PlatformUI.getWorkbench().restart();
}
}
+
+ public static IUndoContext getProvisioningUndoContext() {
+ if (provisioningUndoContext == null) {
+ provisioningUndoContext = new ObjectUndoContext(new Object(), "Provisioning Undo Context"); //$NON-NLS-1$
+ IOperationHistory opHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
+ opHistory.addOperationApprover(getOperationApprover());
+ }
+ return provisioningUndoContext;
+ }
+
+ static IOperationApprover getOperationApprover() {
+ return new IOperationApprover() {
+ public IStatus proceedUndoing(final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
+ final IStatus[] status = new IStatus[1];
+ status[0] = Status.OK_STATUS;
+ if (operation.hasContext(provisioningUndoContext) && operation instanceof IAdvancedUndoableOperation) {
+ final IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ status[0] = ((IAdvancedUndoableOperation) operation).computeUndoableStatus(monitor);
+ if (!status[0].isOK()) {
+ StatusManager.getManager().handle(status[0], StatusManager.SHOW);
+ }
+ } catch (ExecutionException e) {
+ status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
+ ProvUI.handleException(e.getCause(), null);
+ }
+ }
+ };
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ try {
+ new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, runnable);
+ } catch (InterruptedException e) {
+ // don't report thread interruption
+ } catch (InvocationTargetException e) {
+ status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
+ ProvUI.handleException(e.getCause(), null);
+ }
+ }
+ });
+
+ }
+ return status[0];
+ }
+
+ public IStatus proceedRedoing(final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
+ final IStatus[] status = new IStatus[1];
+ status[0] = Status.OK_STATUS;
+ if (operation.hasContext(provisioningUndoContext) && operation instanceof IAdvancedUndoableOperation) {
+ final IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ status[0] = ((IAdvancedUndoableOperation) operation).computeRedoableStatus(monitor);
+ if (!status[0].isOK()) {
+ StatusManager.getManager().handle(status[0], StatusManager.SHOW);
+ }
+ } catch (ExecutionException e) {
+ status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
+ ProvUI.handleException(e.getCause(), null);
+ }
+ }
+ };
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ try {
+ new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, runnable);
+ } catch (InterruptedException e) {
+ // don't report thread interruption
+ } catch (InvocationTargetException e) {
+ status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
+ ProvUI.handleException(e.getCause(), null);
+ }
+ }
+ });
+
+ }
+ return status[0];
+ }
+
+ };
+
+ }
+
+ /**
+ * Make an <code>IAdaptable</code> that adapts to the specified shell,
+ * suitable for passing for passing to any
+ * {@link org.eclipse.core.commands.operations.IUndoableOperation} or
+ * {@link org.eclipse.core.commands.operations.IOperationHistory} method
+ * that requires an {@link org.eclipse.core.runtime.IAdaptable}
+ * <code>uiInfo</code> parameter.
+ *
+ * @param shell
+ * the shell that should be returned by the IAdaptable when asked
+ * to adapt a shell. If this parameter is <code>null</code>,
+ * the returned shell will also be <code>null</code>.
+ *
+ * @return an IAdaptable that will return the specified shell.
+ */
+ static IAdaptable getUIInfoAdapter(final Shell shell) {
+ return new IAdaptable() {
+ public Object getAdapter(Class clazz) {
+ if (clazz == Shell.class) {
+ return shell;
+ }
+ return null;
+ }
+ };
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUIActivator.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUIActivator.java
index 9c086572b..9d45ad77a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUIActivator.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvUIActivator.java
@@ -15,7 +15,11 @@ import java.util.EventObject;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.p2.ui.ProvisioningEventManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
+import org.eclipse.equinox.p2.core.eventbus.ProvisioningListener;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.p2.ui.viewers.StructuredViewerProvisioningListener;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -32,6 +36,7 @@ public class ProvUIActivator extends AbstractUIPlugin {
private static PackageAdmin packageAdmin = null;
private static ServiceReference packageAdminRef = null;
private static ProvUIActivator plugin;
+ private ProvisioningListener profileChangeListener;
private ProvisioningEventManager eventManager = new ProvisioningEventManager();
public static final String PLUGIN_ID = "org.eclipse.equinox.p2.ui"; //$NON-NLS-1$
@@ -91,10 +96,12 @@ public class ProvUIActivator extends AbstractUIPlugin {
getBundle("org.eclipse.equinox.p2.updatechecker").start(); //$NON-NLS-1$
initializeImages();
+ addProfileChangeListener();
}
public void stop(BundleContext bundleContext) throws Exception {
try {
+ removeProfileChangeListener();
plugin = null;
ProvUIActivator.context = null;
} finally {
@@ -102,18 +109,53 @@ public class ProvUIActivator extends AbstractUIPlugin {
}
}
+ private void addProfileChangeListener() {
+ if (profileChangeListener == null) {
+ profileChangeListener = new ProvisioningListener() {
+ public void notify(EventObject o) {
+ if (o instanceof CommitOperationEvent) {
+ CommitOperationEvent event = (CommitOperationEvent) o;
+ try {
+ Profile selfProfile = ProvisioningUtil.getProfile(IProfileRegistry.SELF);
+ if (selfProfile != null && (selfProfile.getProfileId().equals(event.getProfile().getProfileId()))) {
+ ProvUI.requestRestart(false, null);
+ }
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ }
+ }
+ };
+ }
+ getProvisioningEventBus().addListener(profileChangeListener);
+ }
+
+ private void removeProfileChangeListener() {
+ if (profileChangeListener != null) {
+ ProvisioningEventBus bus = getProvisioningEventBus();
+ if (bus != null) {
+ getProvisioningEventBus().removeListener(profileChangeListener);
+ }
+ }
+ }
+
public void addProvisioningListener(StructuredViewerProvisioningListener listener) {
// TODO hack for unsupported repository events.
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=197052
if ((listener.getEventTypes() & StructuredViewerProvisioningListener.PROV_EVENT_REPOSITORY) == StructuredViewerProvisioningListener.PROV_EVENT_REPOSITORY) {
eventManager.addListener(listener);
} else {
- ServiceReference busReference = context.getServiceReference(ProvisioningEventBus.class.getName());
- ProvisioningEventBus bus = (ProvisioningEventBus) context.getService(busReference);
- bus.addListener(listener);
+ getProvisioningEventBus().addListener(listener);
}
}
+ private ProvisioningEventBus getProvisioningEventBus() {
+ ServiceReference busReference = context.getServiceReference(ProvisioningEventBus.class.getName());
+ if (busReference == null)
+ return null;
+ return (ProvisioningEventBus) context.getService(busReference);
+ }
+
// TODO hack for triggering events from the UI.
public void notifyListeners(EventObject event) {
eventManager.notifyListeners(event);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationResult.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationResult.java
new file mode 100644
index 000000000..57dbb5ba5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationResult.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.p2.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
+
+/**
+ * Reports information about a provisioning operation.
+ *
+ * @since 3.4
+ */
+public class ProvisioningOperationResult {
+ private ProvisioningOperation op;
+ private IStatus status;
+ private Job job;
+
+ public ProvisioningOperationResult(ProvisioningOperation op) {
+ this.op = op;
+ }
+
+ public IStatus getStatus() {
+ return status;
+ }
+
+ void setStatus(IStatus status) {
+ this.status = status;
+ }
+
+ public Job getJob() {
+ return job;
+ }
+
+ void setJob(Job job) {
+ this.job = job;
+ }
+
+ public ProvisioningOperation getOperation() {
+ return op;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationRunner.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationRunner.java
new file mode 100644
index 000000000..bbb709a41
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningOperationRunner.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.equinox.p2.ui;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Utility methods for running provisioning operations
+ *
+ * @since 3.4
+ */
+public class ProvisioningOperationRunner {
+
+ private static Object FAMILY_PROVISIONING_OPERATIONS = new Object();
+
+ private static class JobRunnableContext implements IRunnableContext {
+
+ private class ProvisioningJob extends Job {
+ private IRunnableWithProgress runnable;
+
+ ProvisioningJob(String name, IRunnableWithProgress runnable) {
+ super(name);
+ this.runnable = runnable;
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ runnable.run(monitor);
+ } catch (InvocationTargetException e) {
+ return ProvUI.handleException(e, null);
+ } catch (InterruptedException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
+ }
+
+ public boolean belongsTo(Object family) {
+ return family == FAMILY_PROVISIONING_OPERATIONS;
+ }
+
+ }
+
+ private ProvisioningOperation op;
+ private ProvisioningOperationResult result;
+
+ JobRunnableContext(ProvisioningOperation operation, ProvisioningOperationResult result) {
+ this.op = operation;
+ this.result = result;
+ }
+
+ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) {
+ Job job = new ProvisioningJob(op.getLabel(), runnable);
+ job.setUser(op.isUser());
+ job.setPriority(Job.DECORATE); // this is the prio that the old update manager used
+ job.schedule();
+ result.setJob(job);
+ }
+
+ }
+
+ /**
+ * Execute the supplied ProvisioningOperation, and add it to the
+ * undo history if it supports undo.
+ *
+ * @param op The operation to execute
+ * @param shell provided by the caller in order to supply UI information for prompting the
+ * user if necessary. May be <code>null</code>.
+ * @param context the IRunnableContext provided by the caller for running the operation. May be <code>null</code>, in which case
+ * a runnable context will be created based on whether the operation should be run in the foreground or background.
+ * Callers typically need not supply a context unless special handling (such as wizard-based progress reporting) is required.
+ */
+ public static ProvisioningOperationResult execute(final ProvisioningOperation op, final Shell shell, IRunnableContext context) {
+
+ final ProvisioningOperationResult[] result = new ProvisioningOperationResult[1];
+ result[0] = new ProvisioningOperationResult(op);
+ result[0].setStatus(Status.OK_STATUS);
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ try {
+ if (op instanceof IUndoableOperation) {
+ result[0].setStatus(PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute((IUndoableOperation) op, monitor, ProvUI.getUIInfoAdapter(shell)));
+ } else {
+ result[0].setStatus(op.execute(monitor, ProvUI.getUIInfoAdapter(shell)));
+ }
+ } catch (ExecutionException e) {
+ result[0].setStatus(ProvUI.handleException(e.getCause(), null));
+ }
+ }
+ };
+ if (context == null) {
+ if (op.runInBackground())
+ context = new JobRunnableContext(op, result[0]);
+ else
+ context = PlatformUI.getWorkbench().getProgressService();
+ }
+ try {
+ context.run(op.runInBackground(), true, runnable);
+ } catch (InterruptedException e) {
+ // do nothing
+ } catch (InvocationTargetException e) {
+ result[0].setStatus(ProvUI.handleException(e.getCause(), null));
+ }
+ return result[0];
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUndoSupport.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUndoSupport.java
deleted file mode 100644
index 250c29209..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUndoSupport.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.equinox.p2.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.operations.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.statushandlers.StatusManager;
-
-/**
- * Utility methods for clients using undo
- *
- * @since 3.4
- */
-public class ProvisioningUndoSupport {
- static ObjectUndoContext provisioningUndoContext;
-
- /**
- * Return the undo context that should be used for operations involving
- * provisioning.
- *
- * @return the provisioning undo context
- */
- public static IUndoContext getProvisioningUndoContext() {
- if (provisioningUndoContext == null) {
- provisioningUndoContext = new ObjectUndoContext(new Object(), "Provisioning Undo Context"); //$NON-NLS-1$
- IOperationHistory opHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
- opHistory.addOperationApprover(getOperationApprover());
- }
- return provisioningUndoContext;
- }
-
- /**
- * Execute the supplied ProvisioningOperation, and add it to the
- * undo history if it supports undo.
- *
- * @param op The operation to execute
- * @param monitor
- * the progress monitor to use for the operation
- * @param shell provided by the caller in order to supply UI information for prompting the
- * user if necessary. May be <code>null</code>.
- */
- public static IStatus execute(ProvisioningOperation op, IProgressMonitor monitor, Shell shell) throws ExecutionException {
- if (op instanceof IUndoableOperation) {
- return PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute((IUndoableOperation) op, monitor, getUIInfoAdapter(shell));
- }
- return op.execute(monitor, getUIInfoAdapter(shell));
- }
-
- static IOperationApprover getOperationApprover() {
- return new IOperationApprover() {
- public IStatus proceedUndoing(final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
- final IStatus[] status = new IStatus[1];
- status[0] = Status.OK_STATUS;
- if (operation.hasContext(provisioningUndoContext) && operation instanceof IAdvancedUndoableOperation) {
- final IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- try {
- status[0] = ((IAdvancedUndoableOperation) operation).computeUndoableStatus(monitor);
- if (!status[0].isOK()) {
- StatusManager.getManager().handle(status[0], StatusManager.SHOW);
- }
- } catch (ExecutionException e) {
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
- ProvUI.handleException(e.getCause(), null);
- }
- }
- };
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- public void run() {
- try {
- new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, runnable);
- } catch (InterruptedException e) {
- // don't report thread interruption
- } catch (InvocationTargetException e) {
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
- ProvUI.handleException(e.getCause(), null);
- }
- }
- });
-
- }
- return status[0];
- }
-
- public IStatus proceedRedoing(final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {
- final IStatus[] status = new IStatus[1];
- status[0] = Status.OK_STATUS;
- if (operation.hasContext(provisioningUndoContext) && operation instanceof IAdvancedUndoableOperation) {
- final IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- try {
- status[0] = ((IAdvancedUndoableOperation) operation).computeRedoableStatus(monitor);
- if (!status[0].isOK()) {
- StatusManager.getManager().handle(status[0], StatusManager.SHOW);
- }
- } catch (ExecutionException e) {
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
- ProvUI.handleException(e.getCause(), null);
- }
- }
- };
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- public void run() {
- try {
- new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true, true, runnable);
- } catch (InterruptedException e) {
- // don't report thread interruption
- } catch (InvocationTargetException e) {
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e);
- ProvUI.handleException(e.getCause(), null);
- }
- }
- });
-
- }
- return status[0];
- }
-
- };
-
- }
-
- /**
- * Make an <code>IAdaptable</code> that adapts to the specified shell,
- * suitable for passing for passing to any
- * {@link org.eclipse.core.commands.operations.IUndoableOperation} or
- * {@link org.eclipse.core.commands.operations.IOperationHistory} method
- * that requires an {@link org.eclipse.core.runtime.IAdaptable}
- * <code>uiInfo</code> parameter.
- *
- * @param shell
- * the shell that should be returned by the IAdaptable when asked
- * to adapt a shell. If this parameter is <code>null</code>,
- * the returned shell will also be <code>null</code>.
- *
- * @return an IAdaptable that will return the specified shell.
- */
- private static IAdaptable getUIInfoAdapter(final Shell shell) {
- return new IAdaptable() {
- public Object getAdapter(Class clazz) {
- if (clazz == Shell.class) {
- return shell;
- }
- return null;
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
index 9ffb85872..2ecf34871 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/InstallAction.java
@@ -13,14 +13,14 @@ package org.eclipse.equinox.p2.ui.actions;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.p2.ui.InstallDialog;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
+import org.eclipse.equinox.p2.ui.IProfileChooser;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.dialogs.InstallDialog;
import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -33,24 +33,6 @@ public class InstallAction extends ProfileModificationAction {
setToolTipText(ProvUI.INSTALL_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
- // First validate whether the install can happen
- try {
- ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(ius, targetProfile, monitor);
- IStatus status = plan.getStatus();
- if (status.isOK()) {
- InstallDialog dialog = new InstallDialog(getShell(), ius, targetProfile);
- dialog.open();
- return dialog.getOperation();
- }
- ProvUI.reportStatus(status);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- // fall through and return null
- }
- return null;
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
@@ -76,4 +58,18 @@ public class InstallAction extends ProfileModificationAction {
protected String getTaskName() {
return ProvUIMessages.InstallIUProgress;
}
+
+ protected void performOperation(IInstallableUnit[] ius, Profile targetProfile) {
+ InstallDialog dialog = new InstallDialog(getShell(), ius, targetProfile);
+ dialog.open();
+ }
+
+ protected IStatus validateOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(ius, targetProfile, monitor);
+ return plan.getStatus();
+ } catch (ProvisionException e) {
+ return ProvUI.handleException(e, null);
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
index 20637b1af..2d63bc434 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/ProfileModificationAction.java
@@ -14,26 +14,20 @@ package org.eclipse.equinox.p2.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
-import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
+import org.eclipse.equinox.p2.ui.IProfileChooser;
+import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.statushandlers.StatusManager;
abstract class ProfileModificationAction extends ProvisioningAction {
Profile profile;
IProfileChooser profileChooser;
- private static final int OPERATION_WORK = 1000;
public ProfileModificationAction(String text, ISelectionProvider selectionProvider, Profile profile, IProfileChooser profileChooser, Shell shell) {
super(text, selectionProvider, shell);
@@ -66,67 +60,37 @@ abstract class ProfileModificationAction extends ProvisioningAction {
}
final IInstallableUnit[] ius = (IInstallableUnit[]) iusList.toArray(new IInstallableUnit[iusList.size()]);
- final ProfileModificationOperation[] ops = new ProfileModificationOperation[1];
+ final IStatus[] status = new IStatus[1];
final Profile prof = targetProfile;
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
- ops[0] = validateAndGetOperation(ius, prof, monitor);
+ status[0] = validateOperation(ius, prof, monitor);
}
};
try {
- new ProgressMonitorDialog(getShell()).run(false, false, runnable);
+ new ProgressMonitorDialog(getShell()).run(false, true, runnable);
} catch (InterruptedException e) {
// don't report thread interruption
} catch (InvocationTargetException e) {
ProvUI.handleException(e.getCause(), null);
}
- if (ops[0] == null)
- return;
+ if (status[0].isOK())
+ performOperation(ius, prof);
+ else
+ ProvUI.reportStatus(status[0]);
- final IStatus[] status = new IStatus[1];
- runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- try {
- monitor.beginTask(getTaskName(), OPERATION_WORK);
- status[0] = ProvisioningUndoSupport.execute(ops[0], monitor, getShell());
- if (!status[0].isOK()) {
- StatusManager.getManager().handle(status[0], StatusManager.SHOW | StatusManager.LOG);
- }
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
- } finally {
- monitor.done();
- }
- }
- };
- try {
- new ProgressMonitorDialog(getShell()).run(true, true, runnable);
- // If we updated the running profile, we need to determine whether to restart.
- // TODO for now we pretend restart is optional, we really don't know yet
- if (status[0] != null && status[0].isOK()) {
- try {
- Profile selfProfile = ProvisioningUtil.getProfile(IProfileRegistry.SELF);
- if (selfProfile != null && (selfProfile.getProfileId().equals(targetProfile.getProfileId()))) {
- ProvUI.requestRestart(false, getShell());
- }
- } catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- }
- }
- } catch (InterruptedException e) {
- // don't report thread interruption
- } catch (InvocationTargetException e) {
- ProvUI.handleException(e.getCause(), null);
- }
}
/*
* Validate whether the proposed profile modification operation can run.
- * If so, return an operation representing it. If not, return null.
- * We assume the user has been notified if something couldn't happen.
*/
- protected abstract ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor);
+ protected abstract IStatus validateOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor);
+
+ /*
+ * Run the operation, opening any dialogs, etc.
+ */
+ protected abstract void performOperation(IInstallableUnit[] ius, Profile targetProfile);
protected abstract String getTaskName();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/RollbackAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/RollbackAction.java
index 25364de01..5b6ab38e7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/RollbackAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/RollbackAction.java
@@ -11,8 +11,7 @@
package org.eclipse.equinox.p2.ui.actions;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
@@ -20,8 +19,7 @@ import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.ui.*;
-import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
-import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
+import org.eclipse.equinox.p2.ui.operations.*;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@@ -33,20 +31,28 @@ public class RollbackAction extends ProfileModificationAction {
setToolTipText(ProvUI.ROLLBACK_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] toBecome, Profile targetProfile, IProgressMonitor monitor) {
+ protected IStatus validateOperation(IInstallableUnit[] toBecome, Profile targetProfile, IProgressMonitor monitor) {
if (toBecome.length == 1) {
try {
ProvisioningPlan plan = ProvisioningUtil.getBecomePlan(toBecome[0], targetProfile, monitor);
- IStatus planStatus = plan.getStatus();
- if (planStatus.isOK())
- return new ProfileModificationOperation(ProvUIMessages.RollbackIUOperationLabel, targetProfile.getProfileId(), plan);
- ProvUI.reportStatus(planStatus);
+ return plan.getStatus();
} catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- // fall through and return null
+ return ProvUI.handleException(e, null);
}
}
- return null;
+ // should never happen
+ return Status.OK_STATUS;
+ }
+
+ protected void performOperation(IInstallableUnit[] toBecome, Profile targetProfile) {
+ // TODO bogus because we do this twice...
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getBecomePlan(toBecome[0], targetProfile, null);
+ ProvisioningOperation op = new ProfileModificationOperation(ProvUIMessages.RollbackIUOperationLabel, targetProfile.getProfileId(), plan);
+ ProvisioningOperationRunner.execute(op, getShell(), null);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
index e5a32cd78..a45885cb2 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UninstallAction.java
@@ -14,14 +14,14 @@ package org.eclipse.equinox.p2.ui.actions;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.p2.ui.UninstallDialog;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.IProfileChooser;
+import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.dialogs.UninstallDialog;
import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
-import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -34,24 +34,6 @@ public class UninstallAction extends ProfileModificationAction {
setToolTipText(ProvUI.UNINSTALL_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
- // First validate whether the uninstall can happen
- try {
- ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(ius, targetProfile, monitor);
- IStatus status = plan.getStatus();
- if (status.isOK()) {
- UninstallDialog dialog = new UninstallDialog(getShell(), ius, targetProfile);
- dialog.open();
- return dialog.getOperation();
- }
- ProvUI.reportStatus(status);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- // fall through and return null
- }
- return null;
- }
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
@@ -86,4 +68,19 @@ public class UninstallAction extends ProfileModificationAction {
return ProvUIMessages.UninstallIUProgress;
}
+ protected void performOperation(IInstallableUnit[] ius, Profile targetProfile) {
+ UninstallDialog dialog = new UninstallDialog(getShell(), ius, targetProfile);
+ dialog.open();
+ }
+
+ protected IStatus validateOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(ius, targetProfile, monitor);
+ return plan.getStatus();
+ } catch (ProvisionException e) {
+ return ProvUI.handleException(e, null);
+ }
+
+ }
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
index 234b8b7ba..ab6eef9db 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/actions/UpdateAction.java
@@ -12,17 +12,15 @@
package org.eclipse.equinox.p2.ui.actions;
import java.util.ArrayList;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.p2.ui.UpdateDialog;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.dialogs.UpdateDialog;
import org.eclipse.equinox.p2.ui.model.InstalledIUElement;
-import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@@ -34,26 +32,35 @@ public class UpdateAction extends ProfileModificationAction {
setToolTipText(ProvUI.UPDATE_COMMAND_TOOLTIP);
}
- protected ProfileModificationOperation validateAndGetOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ protected void performOperation(IInstallableUnit[] ius, Profile targetProfile) {
// Collect the replacements for each IU individually so that
// the user can decide what to update
try {
ArrayList iusWithUpdates = new ArrayList();
for (int i = 0; i < ius.length; i++) {
- IInstallableUnit[] replacements = ProvisioningUtil.updatesFor(ius[i], monitor);
+ IInstallableUnit[] replacements = ProvisioningUtil.updatesFor(ius[i], null);
if (replacements.length > 0)
iusWithUpdates.add(ius[i]);
}
if (iusWithUpdates.size() > 0) {
- UpdateDialog dialog = new UpdateDialog(getShell(), (IInstallableUnit[]) iusWithUpdates.toArray(new IInstallableUnit[iusWithUpdates.size()]), targetProfile);
- dialog.open();
- return dialog.getOperation();
+ new UpdateDialog(getShell(), (IInstallableUnit[]) iusWithUpdates.toArray(new IInstallableUnit[iusWithUpdates.size()]), targetProfile).open();
}
- MessageDialog.openInformation(getShell(), ProvUIMessages.UpdateAction_UpdateInformationTitle, ProvUIMessages.UpdateOperation_NothingToUpdate);
} catch (ProvisionException e) {
- // fall through and return null
+ ProvUI.handleException(e, null);
}
- return null;
+ }
+
+ protected IStatus validateOperation(IInstallableUnit[] ius, Profile targetProfile, IProgressMonitor monitor) {
+ try {
+ IInstallableUnit[] updates = ProvisioningUtil.updatesFor(ius, monitor);
+ if (updates.length <= 0) {
+ return new Status(IStatus.INFO, ProvUIActivator.PLUGIN_ID, ProvUIMessages.UpdateOperation_NothingToUpdate);
+ }
+ return Status.OK_STATUS;
+ } catch (ProvisionException e) {
+ return ProvUI.handleException(e, null);
+ }
+
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
index b98ba9376..6695b005a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/AddRepositoryDialog.java
@@ -10,24 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui.dialogs;
-import java.lang.reflect.InvocationTargetException;
import java.net.URL;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.ProvUIActivator;
+import org.eclipse.equinox.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.p2.ui.operations.ProvisioningOperation;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.statushandlers.StatusManager;
/**
* Abstract dialog class for adding repositories of different types. This class
@@ -101,7 +99,7 @@ public abstract class AddRepositoryDialog extends StatusDialog {
String path = dialog.open();
if (path != null) {
lastLocalLocation = path;
- url.setText("file:" + path); //$NON-NLS-1$
+ url.setText("file:" + path.toLowerCase()); //$NON-NLS-1$
}
}
});
@@ -141,31 +139,7 @@ public abstract class AddRepositoryDialog extends StatusDialog {
return false;
}
- final ProvisioningOperation op = getOperation(newURL);
- final IStatus[] status = new IStatus[1];
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- try {
- status[0] = ProvisioningUndoSupport.execute(op, monitor, getShell());
- if (!status[0].isOK()) {
- StatusManager.getManager().handle(status[0], StatusManager.SHOW | StatusManager.LOG);
- }
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, null, null);
- }
- }
- };
- try {
- new ProgressMonitorDialog(getShell()).run(true, true, runnable);
- } catch (InterruptedException e) {
- // don't report thread interruption
- } catch (InvocationTargetException e) {
- ProvUI.handleException(e.getCause(), null);
- status[0] = new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, 0, null, null);
- }
- return status[0].isOK();
-
+ return (ProvisioningOperationRunner.execute(getOperation(newURL), getShell(), null)).getStatus().isOK();
}
protected abstract ProvisioningOperation getOperation(URL repoURL);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ColocatedRepositoryManipulatorGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ColocatedRepositoryManipulatorGroup.java
index 90f64443a..a8ea03999 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ColocatedRepositoryManipulatorGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ColocatedRepositoryManipulatorGroup.java
@@ -11,11 +11,11 @@
package org.eclipse.equinox.p2.ui.dialogs;
import java.util.List;
-import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.p2.ui.*;
+import org.eclipse.equinox.p2.ui.ProvUIActivator;
+import org.eclipse.equinox.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.p2.ui.model.AllMetadataRepositories;
import org.eclipse.equinox.p2.ui.model.MetadataRepositoryContentProvider;
import org.eclipse.equinox.p2.ui.operations.RemoveColocatedRepositoryOperation;
@@ -136,11 +136,7 @@ public class ColocatedRepositoryManipulatorGroup {
repos[i] = (IMetadataRepository) selection.get(i);
}
RemoveColocatedRepositoryOperation op = new RemoveColocatedRepositoryOperation(ProvUIMessages.ColocatedRepositoryManipulatorGroup_Remove, repos);
- try {
- ProvisioningUndoSupport.execute(op, null, getControl().getShell());
- } catch (ExecutionException e) {
- ProvUI.handleException(e.getCause(), null);
- }
+ ProvisioningOperationRunner.execute(op, getControl().getShell(), null);
}
});
return composite;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/InstallDialog.java
index b9369aca7..5f7e0bac9 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/InstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/InstallDialog.java
@@ -8,9 +8,11 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui;
+package org.eclipse.equinox.p2.ui.dialogs;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
@@ -19,37 +21,18 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.p2.ui.operations.*;
-import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
import org.eclipse.swt.widgets.Shell;
-public class InstallDialog extends ProfileModificationDialog {
+public class InstallDialog extends UpdateInstallDialog {
public InstallDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile) {
super(parentShell, ius, profile, ProvUIMessages.InstallIUOperationLabel, ProvUIMessages.InstallDialog_InstallSelectionMessage);
}
- protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor) {
- try {
- IInstallableUnit[] selectedIUs = elementsToIUs(selectedElements);
- ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(selectedIUs, profile, monitor);
- IStatus status = plan.getStatus();
- if (status.isOK())
- return new InstallOperation(ProvUIMessages.InstallIUOperationLabel, profile.getProfileId(), plan, selectedIUs);
- ProvUI.reportStatus(status);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- }
- return null;
- }
-
protected String getOkButtonString() {
return ProvUIMessages.InstallIUOperationLabelWithMnemonic;
}
- protected IUColumnConfig[] getColumnConfig() {
- return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME), new IUColumnConfig(ProvUIMessages.ProvUI_IDColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION), new IUColumnConfig(ProvUIMessages.ProvUI_SizeColumnTitle, IUColumnConfig.COLUMN_SIZE)};
- }
-
protected long getSize(IInstallableUnit iu) {
long size;
try {
@@ -61,4 +44,22 @@ public class InstallDialog extends ProfileModificationDialog {
}
return size;
}
+
+ protected String getOperationLabel() {
+ return ProvUIMessages.InstallIUOperationLabel;
+ }
+
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements) {
+ try {
+ IInstallableUnit[] ius = elementsToIUs(selectedElements);
+ ProvisioningPlan plan = ProvisioningUtil.getInstallPlan(ius, profile, null);
+ IStatus status = plan.getStatus();
+ if (status.isOK())
+ return new InstallOperation(getOperationLabel(), profile.getProfileId(), plan, ius);
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ return null;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ProfileModificationDialog.java
index 5014ccdd4..9ff280508 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProfileModificationDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/ProfileModificationDialog.java
@@ -8,12 +8,15 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui;
+package org.eclipse.equinox.p2.ui.dialogs;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.internal.p2.ui.StaticContentProvider;
import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.ui.ProvUI;
+import org.eclipse.equinox.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
@@ -29,7 +32,7 @@ import org.eclipse.swt.widgets.*;
abstract class ProfileModificationDialog extends TrayDialog {
private static final int DEFAULT_HEIGHT = 20;
- private static final int DEFAULT_WIDTH = 170;
+ private static final int DEFAULT_WIDTH = 120;
private static final int DEFAULT_COLUMN_WIDTH = 50;
private static final int DEFAULT_SMALL_COLUMN_WIDTH = 20;
private String title;
@@ -38,10 +41,10 @@ abstract class ProfileModificationDialog extends TrayDialog {
Profile profile;
CheckboxTableViewer listViewer;
StaticContentProvider contentProvider;
- private ProfileModificationOperation resultOperation;
ProfileModificationDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile, String title, String message) {
super(parentShell);
+ this.setBlockOnOpen(false);
this.title = title;
this.message = message;
this.ius = ius;
@@ -145,17 +148,10 @@ abstract class ProfileModificationDialog extends TrayDialog {
}
protected void okPressed() {
- resultOperation = null;
- // TODO may need progress monitor
- IProgressMonitor monitor = new NullProgressMonitor();
- resultOperation = createProfileModificationOperation(getSelectedElements(), monitor);
+ ProvisioningOperationRunner.execute(createProfileModificationOperation(getSelectedElements()), getShell(), null);
super.okPressed();
}
- public ProfileModificationOperation getOperation() {
- return resultOperation;
- }
-
private Object[] getSelectedElements() {
return listViewer.getCheckedElements();
}
@@ -168,7 +164,7 @@ abstract class ProfileModificationDialog extends TrayDialog {
return theIUs;
}
- protected abstract ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor);
+ protected abstract ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements);
protected abstract String getOkButtonString();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UninstallDialog.java
index 4bd9b31ed..d8b9f984d 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UninstallDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UninstallDialog.java
@@ -8,10 +8,10 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui;
+package org.eclipse.equinox.p2.ui.dialogs;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
@@ -27,9 +27,9 @@ public class UninstallDialog extends ProfileModificationDialog {
super(parentShell, ius, profile, ProvUIMessages.UninstallIUOperationLabel, ProvUIMessages.UninstallDialog_UninstallMessage);
}
- protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor) {
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements) {
try {
- ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(elementsToIUs(selectedElements), profile, monitor);
+ ProvisioningPlan plan = ProvisioningUtil.getUninstallPlan(elementsToIUs(selectedElements), profile, null);
IStatus status = plan.getStatus();
if (status.isOK())
return new ProfileModificationOperation(ProvUIMessages.UninstallIUOperationLabel, profile.getProfileId(), plan);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
index 4649de077..3c9637b48 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateAndInstallGroup.java
@@ -44,7 +44,7 @@ public class UpdateAndInstallGroup {
private static final String BUTTONACTION = "buttonAction"; //$NON-NLS-1$
private static final int DEFAULT_HEIGHT = 240;
- private static final int DEFAULT_WIDTH = 450;
+ private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_COLUMN_WIDTH = 150;
TabFolder tabFolder;
TableViewer installedIUViewer;
@@ -89,7 +89,7 @@ public class UpdateAndInstallGroup {
availableTab.setControl(createAvailableIUsPage(tabFolder, availableIUFilters));
}
- public Control getControl() {
+ public TabFolder getTabFolder() {
return tabFolder;
}
@@ -186,7 +186,7 @@ public class UpdateAndInstallGroup {
Button repoButton = createVerticalButton(composite, repositoryManipulator.getLabel(), false);
repoButton.setData(BUTTONACTION, new Action() {
public void runWithEvent(Event event) {
- if (repositoryManipulator.manipulateRepositories(getControl().getShell())) {
+ if (repositoryManipulator.manipulateRepositories(getTabFolder().getShell())) {
availableIUViewer.setInput(new AllMetadataRepositories());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateDialog.java
index 08775d3cc..748483700 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateDialog.java
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.internal.p2.ui;
+package org.eclipse.equinox.p2.ui.dialogs;
+import java.lang.reflect.InvocationTargetException;
import java.util.*;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.Profile;
@@ -22,47 +24,51 @@ import org.eclipse.equinox.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.p2.ui.model.AvailableUpdateElement;
import org.eclipse.equinox.p2.ui.operations.ProfileModificationOperation;
import org.eclipse.equinox.p2.ui.operations.ProvisioningUtil;
-import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
-public class UpdateDialog extends ProfileModificationDialog {
+public class UpdateDialog extends UpdateInstallDialog {
public UpdateDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile) {
super(parentShell, ius, profile, ProvUIMessages.UpdateAction_UpdatesAvailableTitle, ProvUIMessages.UpdateAction_UpdatesAvailableMessage);
}
- protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements, IProgressMonitor monitor) {
- try {
- ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(getIUsToReplace(selectedElements), elementsToIUs(selectedElements), profile, monitor);
- IStatus status = plan.getStatus();
- if (status.isOK())
- return new ProfileModificationOperation(ProvUIMessages.UpdateIUOperationLabel, profile.getProfileId(), plan);
- ProvUI.reportStatus(status);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, null);
- }
- return null;
- }
-
protected String getOkButtonString() {
return ProvUIMessages.UpdateIUOperationLabelWithMnemonic;
}
- protected IUColumnConfig[] getColumnConfig() {
- return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME), new IUColumnConfig(ProvUIMessages.ProvUI_IDColumnTitle, IUColumnConfig.COLUMN_ID), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION), new IUColumnConfig(ProvUIMessages.ProvUI_SizeColumnTitle, IUColumnConfig.COLUMN_SIZE)};
- }
+ protected AvailableIUElement[] makeElements(final IInstallableUnit[] ius) {
+ final List elements = new ArrayList();
- protected AvailableIUElement[] makeElements(IInstallableUnit[] ius) {
- List elements = new ArrayList();
- for (int i = 0; i < ius.length; i++) {
- try {
- IInstallableUnit[] replacementIUs = ProvisioningUtil.updatesFor(new IInstallableUnit[] {ius[i]}, profile, null);
- for (int j = 0; j < replacementIUs.length; j++) {
- elements.add(new AvailableUpdateElement(replacementIUs[j], getSize(ius[i], replacementIUs[j]), ius[i]));
+ IRunnableWithProgress runnable = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(ProvUIMessages.UpdateDialog_AssemblingUpdatesProgress, ius.length);
+ for (int i = 0; i < ius.length; i++) {
+ if (monitor.isCanceled())
+ close();
+ try {
+ IInstallableUnit[] replacementIUs = ProvisioningUtil.updatesFor(new IInstallableUnit[] {ius[i]}, null);
+ SubMonitor loopMonitor = SubMonitor.convert(monitor, 100 / ius.length);
+ loopMonitor.setWorkRemaining(replacementIUs.length);
+ for (int j = 0; j < replacementIUs.length; j++) {
+ elements.add(new AvailableUpdateElement(replacementIUs[j], getSize(ius[i], replacementIUs[j], loopMonitor.newChild(1)), ius[i]));
+ if (monitor.isCanceled())
+ close();
+ }
+ } catch (ProvisionException e) {
+ break;
+ }
}
- } catch (ProvisionException e) {
- break;
}
+ };
+
+ try {
+ new ProgressMonitorDialog(getShell()).run(false, true, runnable);
+ } catch (InterruptedException e) {
+ // don't report thread interruption
+ } catch (InvocationTargetException e) {
+ ProvUI.handleException(e.getCause(), null);
}
return (AvailableIUElement[]) elements.toArray(new AvailableIUElement[elements.size()]);
}
@@ -77,15 +83,32 @@ public class UpdateDialog extends ProfileModificationDialog {
return (IInstallableUnit[]) iusToReplace.toArray(new IInstallableUnit[iusToReplace.size()]);
}
- protected long getSize(IInstallableUnit iuToRemove, IInstallableUnit iuToAdd) {
+ protected long getSize(IInstallableUnit iuToRemove, IInstallableUnit iuToAdd, IProgressMonitor monitor) {
long size;
try {
- ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(new IInstallableUnit[] {iuToRemove}, new IInstallableUnit[] {iuToAdd}, profile, new NullProgressMonitor());
- Sizing info = ProvisioningUtil.getSizeInfo(plan, profile, new NullProgressMonitor());
+ ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(new IInstallableUnit[] {iuToRemove}, new IInstallableUnit[] {iuToAdd}, profile, monitor);
+ Sizing info = ProvisioningUtil.getSizeInfo(plan, profile, monitor);
size = info.getDiskSize();
} catch (ProvisionException e) {
size = AvailableIUElement.SIZE_UNKNOWN;
}
return size;
}
+
+ protected String getOperationLabel() {
+ return ProvUIMessages.UpdateIUOperationLabel;
+ }
+
+ protected ProfileModificationOperation createProfileModificationOperation(Object[] selectedElements) {
+ try {
+ ProvisioningPlan plan = ProvisioningUtil.getReplacePlan(getIUsToReplace(selectedElements), elementsToIUs(selectedElements), profile, null);
+ IStatus status = plan.getStatus();
+ if (status.isOK())
+ return new ProfileModificationOperation(getOperationLabel(), profile.getProfileId(), plan);
+ ProvUI.reportStatus(status);
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null);
+ }
+ return null;
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateInstallDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateInstallDialog.java
new file mode 100644
index 000000000..6d3ed03b2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/dialogs/UpdateInstallDialog.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.ui.dialogs;
+
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.ui.viewers.IUColumnConfig;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class UpdateInstallDialog extends ProfileModificationDialog {
+ UpdateInstallDialog(Shell parentShell, IInstallableUnit[] ius, Profile profile, String title, String message) {
+ super(parentShell, ius, profile, title, message);
+ }
+
+ protected abstract String getOperationLabel();
+
+ protected IUColumnConfig[] getColumnConfig() {
+ return new IUColumnConfig[] {new IUColumnConfig(ProvUIMessages.ProvUI_NameColumnTitle, IUColumnConfig.COLUMN_NAME), new IUColumnConfig(ProvUIMessages.ProvUI_VersionColumnTitle, IUColumnConfig.COLUMN_VERSION), new IUColumnConfig(ProvUIMessages.ProvUI_SizeColumnTitle, IUColumnConfig.COLUMN_SIZE)};
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/DownloadPhaseSet.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/DownloadPhaseSet.java
new file mode 100644
index 000000000..1c91ce585
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/DownloadPhaseSet.java
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package org.eclipse.equinox.p2.ui.operations;
+
+import org.eclipse.equinox.p2.engine.Phase;
+import org.eclipse.equinox.p2.engine.PhaseSet;
+import org.eclipse.equinox.p2.engine.phases.Collect;
+
+public class DownloadPhaseSet extends PhaseSet {
+ public DownloadPhaseSet() {
+ super(new Phase[] {new Collect(10)});
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallAndConfigurePhaseSet.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallAndConfigurePhaseSet.java
new file mode 100644
index 000000000..db18a4953
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/InstallAndConfigurePhaseSet.java
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package org.eclipse.equinox.p2.ui.operations;
+
+import org.eclipse.equinox.p2.engine.Phase;
+import org.eclipse.equinox.p2.engine.PhaseSet;
+import org.eclipse.equinox.p2.engine.phases.*;
+
+public class InstallAndConfigurePhaseSet extends PhaseSet {
+ public InstallAndConfigurePhaseSet() {
+ super(new Phase[] {new Unconfigure(10), new Uninstall(10), new Install(10), new Configure(10)});
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
index 7ce64ba92..e696c77d4 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProfileModificationOperation.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.ui.operations;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
-import org.eclipse.equinox.p2.engine.Profile;
+import org.eclipse.equinox.p2.engine.*;
/**
* Class representing a provisioning profile plan
@@ -24,11 +24,22 @@ public class ProfileModificationOperation extends ProvisioningOperation {
ProvisioningPlan plan;
String profileId;
+ PhaseSet phaseSet;
+ boolean isUser = true;
public ProfileModificationOperation(String label, String id, ProvisioningPlan plan) {
+ this(label, id, plan, null, true);
+ }
+
+ public ProfileModificationOperation(String label, String id, ProvisioningPlan plan, PhaseSet set, boolean isUser) {
super(label);
this.plan = plan;
this.profileId = id;
+ this.isUser = isUser;
+ if (set == null)
+ phaseSet = new DefaultPhaseSet();
+ else
+ phaseSet = set;
}
public String getProfileId() {
@@ -44,6 +55,14 @@ public class ProfileModificationOperation extends ProvisioningOperation {
}
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException {
- return ProvisioningUtil.performProvisioningPlan(plan, getProfile(), ProvisioningUtil.PERFORM_ALL, monitor);
+ return ProvisioningUtil.performProvisioningPlan(plan, phaseSet, getProfile(), monitor);
+ }
+
+ public boolean runInBackground() {
+ return true;
+ }
+
+ public boolean isUser() {
+ return isUser;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
index cf8c20f42..a09734b16 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningOperation.java
@@ -76,8 +76,12 @@ public abstract class ProvisioningOperation {
return label;
}
- protected boolean runInBackground() {
+ public boolean runInBackground() {
return false;
}
+ public boolean isUser() {
+ return true;
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
index 88a4a1147..f99743b70 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/ProvisioningUtil.java
@@ -23,7 +23,7 @@ import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.p2.director.IPlanner;
import org.eclipse.equinox.p2.director.ProvisioningPlan;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.engine.phases.*;
+import org.eclipse.equinox.p2.engine.phases.Sizing;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
@@ -40,34 +40,6 @@ import org.eclipse.osgi.util.NLS;
*/
public class ProvisioningUtil {
- public static final int PERFORM_DOWNLOAD_ONLY = 1;
- public static final int PERFORM_INSTALL_AND_CONFIGURE = 2;
- public static final int PERFORM_ALL = 3;
-
- private static final class SizingPhaseSet extends PhaseSet {
- static Sizing sizing;
-
- SizingPhaseSet() {
- super(new Phase[] {sizing = new Sizing(100, "Compute sizes")}); //$NON-NLS-1$
- }
-
- Sizing getSizing() {
- return sizing;
- }
- }
-
- private static final class DownloadPhaseSet extends PhaseSet {
- DownloadPhaseSet() {
- super(new Phase[] {new Collect(10)});
- }
- }
-
- private static final class ReplaceAndConfigurePhaseSet extends PhaseSet {
- ReplaceAndConfigurePhaseSet() {
- super(new Phase[] {new Unconfigure(10), new Uninstall(10), new Install(10), new Configure(10)});
- }
- }
-
public static IMetadataRepository addMetadataRepository(URL location, IProgressMonitor monitor) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null)
@@ -241,8 +213,7 @@ public class ProvisioningUtil {
* See what updates might be available for the specified IU's.
* Useful for bulk update that can be directly passed to the engine.
*/
- public static IInstallableUnit[] updatesFor(IInstallableUnit[] toUpdate, Profile profile, IProgressMonitor monitor) throws ProvisionException {
- Assert.isNotNull(profile);
+ public static IInstallableUnit[] updatesFor(IInstallableUnit[] toUpdate, IProgressMonitor monitor) throws ProvisionException {
Assert.isNotNull(toUpdate);
IPlanner planner = getPlanner();
@@ -293,7 +264,7 @@ public class ProvisioningUtil {
try {
SubMonitor sub = SubMonitor.convert(monitor, taskMessage, 100);
monitor.beginTask(taskMessage, 100);
- IStatus engineResult = performProvisioningPlan(plan, profile, PERFORM_ALL, sub.newChild(100));
+ IStatus engineResult = performProvisioningPlan(plan, new DefaultPhaseSet(), profile, sub.newChild(100));
if (engineResult.isOK()) {
// mark the roots as such
for (int i = 0; i < installRoots.length; i++)
@@ -305,14 +276,12 @@ public class ProvisioningUtil {
}
}
- public static IStatus performProvisioningPlan(ProvisioningPlan plan, Profile profile, int phases, IProgressMonitor monitor) throws ProvisionException {
+ public static IStatus performProvisioningPlan(ProvisioningPlan plan, PhaseSet phaseSet, Profile profile, IProgressMonitor monitor) throws ProvisionException {
PhaseSet set;
- if (phases == PERFORM_ALL)
+ if (phaseSet == null)
set = new DefaultPhaseSet();
- else if (phases == PERFORM_DOWNLOAD_ONLY)
- set = new DownloadPhaseSet();
else
- set = new ReplaceAndConfigurePhaseSet();
+ set = phaseSet;
return getEngine().perform(profile, set, plan.getOperands(), monitor);
}
@@ -324,7 +293,7 @@ public class ProvisioningUtil {
return engine;
}
- private static IPlanner getPlanner() throws ProvisionException {
+ public static IPlanner getPlanner() throws ProvisionException {
IPlanner planner = (IPlanner) ServiceHelper.getService(ProvUIActivator.getContext(), IPlanner.class.getName());
if (planner == null) {
throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoPlannerFound);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/SizingPhaseSet.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/SizingPhaseSet.java
new file mode 100644
index 000000000..b85562320
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/SizingPhaseSet.java
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package org.eclipse.equinox.p2.ui.operations;
+
+import org.eclipse.equinox.p2.engine.Phase;
+import org.eclipse.equinox.p2.engine.PhaseSet;
+import org.eclipse.equinox.p2.engine.phases.Sizing;
+
+public class SizingPhaseSet extends PhaseSet {
+ private static Sizing sizing;
+
+ SizingPhaseSet() {
+ super(new Phase[] {sizing = new Sizing(100, "Compute sizes")});
+ }
+
+ Sizing getSizing() {
+ return sizing;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UndoableProvisioningOperation.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UndoableProvisioningOperation.java
index e84c2426a..f7eed30f7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UndoableProvisioningOperation.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/operations/UndoableProvisioningOperation.java
@@ -17,8 +17,8 @@ import org.eclipse.core.commands.operations.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.ui.ProvUI;
import org.eclipse.equinox.p2.ui.ProvUIActivator;
-import org.eclipse.equinox.p2.ui.ProvisioningUndoSupport;
import org.eclipse.osgi.util.NLS;
/**
@@ -33,7 +33,7 @@ abstract class UndoableProvisioningOperation extends ProvisioningOperation imple
UndoableProvisioningOperation(String label) {
super(label);
- addContext(ProvisioningUndoSupport.getProvisioningUndoContext());
+ addContext(ProvUI.getProvisioningUndoContext());
}
/**
@@ -154,7 +154,7 @@ abstract class UndoableProvisioningOperation extends ProvisioningOperation imple
*/
public boolean runInBackground() {
- return true;
+ return false;
}
/*

Back to the top