Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizardPage.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/actions/InstallAction.java37
2 files changed, 30 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizardPage.java
index f293a12b4..a405e5158 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizardPage.java
@@ -13,10 +13,9 @@ package org.eclipse.equinox.internal.p2.ui.dialogs;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
+import org.eclipse.equinox.internal.provisional.p2.ui.actions.InstallAction;
public class InstallWizardPage extends UpdateOrInstallWizardPage {
@@ -32,12 +31,7 @@ public class InstallWizardPage extends UpdateOrInstallWizardPage {
protected ProvisioningPlan computeProvisioningPlan(Object[] selectedElements, IProgressMonitor monitor) throws ProvisionException {
IInstallableUnit[] selected = elementsToIUs(selectedElements);
- ProfileChangeRequest changeRequest = ProfileChangeRequest.createByProfileId(getProfileId());
- changeRequest.addInstallableUnits(selected);
- for (int i = 0; i < selected.length; i++) {
- changeRequest.setInstallableUnitProfileProperty(selected[i], IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true));
- }
- ProvisioningPlan plan = ProvisioningUtil.getProvisioningPlan(changeRequest, getProvisioningContext(), monitor);
+ ProvisioningPlan plan = InstallAction.computeProvisioningPlan(selected, getProfileId(), monitor);
computeSizing(plan, getProfileId());
return plan;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/actions/InstallAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/actions/InstallAction.java
index d1316882a..08827fbc7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/actions/InstallAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/actions/InstallAction.java
@@ -15,10 +15,12 @@ import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan;
+import org.eclipse.equinox.internal.provisional.p2.director.*;
+import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.ui.IProfileChooser;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.InstallWizard;
@@ -31,6 +33,29 @@ import org.eclipse.swt.widgets.Shell;
public class InstallAction extends ProfileModificationAction {
+ public static ProvisioningPlan computeProvisioningPlan(IInstallableUnit[] ius, String targetProfileId, IProgressMonitor monitor) throws ProvisionException {
+ ProfileChangeRequest request = ProfileChangeRequest.createByProfileId(targetProfileId);
+ request.addInstallableUnits(ius);
+ IProfile profile = ProvisioningUtil.getProfile(targetProfileId);
+ IInstallableUnit[] installedIUs = (IInstallableUnit[]) profile.query(new InstallableUnitQuery(null), new Collector(), null).toArray(IInstallableUnit.class);
+ for (int i = 0; i < ius.length; i++) {
+ // If the user is installing a patch, we mark it optional. This allows
+ // the patched IU to be updated later by removing the patch.
+ if (Boolean.toString(true).equals(ius[i].getProperty(IInstallableUnit.PROP_TYPE_PATCH)))
+ request.setInstallableUnitInclusionRules(ius[i], PlannerHelper.createOptionalInclusionRule(ius[i]));
+ // If the iu is replacing something already installed, request the removal of the one in the profile
+ for (int j = 0; j < installedIUs.length; j++)
+ if (installedIUs[j].getId().equals(ius[i].getId())) {
+ request.removeInstallableUnits(new IInstallableUnit[] {installedIUs[j]});
+ break;
+ }
+ // Mark everything we are installing as a root
+ request.setInstallableUnitProfileProperty(ius[i], IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true));
+ }
+ ProvisioningPlan plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), monitor);
+ return plan;
+ }
+
public InstallAction(ISelectionProvider selectionProvider, String profileId, IProfileChooser chooser, Policies policies, Shell shell) {
super(ProvUI.INSTALL_COMMAND_LABEL, selectionProvider, profileId, chooser, policies, shell);
setToolTipText(ProvUI.INSTALL_COMMAND_TOOLTIP);
@@ -64,12 +89,6 @@ public class InstallAction extends ProfileModificationAction {
}
protected ProvisioningPlan getProvisioningPlan(IInstallableUnit[] ius, String targetProfileId, IProgressMonitor monitor) throws ProvisionException {
- ProfileChangeRequest request = ProfileChangeRequest.createByProfileId(targetProfileId);
- request.addInstallableUnits(ius);
- for (int i = 0; i < ius.length; i++) {
- request.setInstallableUnitProfileProperty(ius[i], IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true));
- }
- ProvisioningPlan plan = ProvisioningUtil.getProvisioningPlan(request, new ProvisioningContext(), monitor);
- return plan;
+ return computeProvisioningPlan(ius, targetProfileId, monitor);
}
}

Back to the top