Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2016-06-08 13:25:55 -0400
committerPascal Rapicault2016-09-27 14:23:57 -0400
commitaeb345776d36877dd5026e9152d5217e17fdfea9 (patch)
treed6e80b58c5152e522fd8d5ba8d1df7614566c060
parenta7b241bbc77416c8f40d8767a78e0cb0ef3bc357 (diff)
downloadrt.equinox.p2-aeb345776d36877dd5026e9152d5217e17fdfea9.tar.gz
rt.equinox.p2-aeb345776d36877dd5026e9152d5217e17fdfea9.tar.xz
rt.equinox.p2-aeb345776d36877dd5026e9152d5217e17fdfea9.zip
Bug 495726 - API: InstallWizardPage ui elements do not respect policy
P2 UI Wizard pages do not respect provisioning ui which is passed to them when it comes to querying elements, because IUElementListRoot which is the root of all elements does not extend QueriedElement so getProvisioningUI() on the elments defaults to ProvisioningUI.getDefaultUI() Fix is to add an API to accept ProvisioningUI as an argument. All places that were creating IUElementListRoot now pass appropriate ui to the constructor. For backward compatibility if ui is not set or set to null it will return default UI as before. Change-Id: I1d8d87339812c874eeee7127e762731b600cb4bf Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UninstallWizard.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/IUElementListRoot.java27
9 files changed, 37 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
index 0c6f8763f..9d446d270 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java
@@ -689,7 +689,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
protected Object getInput() {
- IUElementListRoot root = new IUElementListRoot();
+ IUElementListRoot root = new IUElementListRoot(ui);
List<AvailableIUElement> elements = new ArrayList<AvailableIUElement>(unitsToMigrate.size());
for (IInstallableUnit unit : unitsToMigrate) {
elements.add(new AvailableIUElement(root, unit, toImportFrom.getProfileId(), false));
@@ -756,10 +756,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis
// Both checkedElements and checkedElementsUpdates and the logic inside the getCheckedIUElements method
// are used to prevent unnecessary call to getUpdates method due to computational cost.
- @SuppressWarnings("rawtypes")
- private Set checkedElements;
- @SuppressWarnings("rawtypes")
- private Set checkedElementsUpdates;
+ @SuppressWarnings("rawtypes") private Set checkedElements;
+ @SuppressWarnings("rawtypes") private Set checkedElementsUpdates;
private boolean getUpdatesCanceled;
public Object[] getCheckedIUElements() {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java
index dce1d523b..b94b06a7e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java
@@ -63,7 +63,7 @@ public class InstallWizard extends WizardWithLicenses {
protected void initializeResolutionModelElements(Object[] selectedElements) {
if (selectedElements == null)
return;
- root = new IUElementListRoot();
+ root = new IUElementListRoot(ui);
if (operation instanceof RemediationOperation) {
AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy(), true);
root.setChildren(elements);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
index 8c1dcb9e8..83f09d7f0 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
@@ -61,7 +61,7 @@ public class PreselectedIUInstallWizard extends WizardWithLicenses {
}
protected void initializeResolutionModelElements(Object[] selectedElements) {
- root = new IUElementListRoot();
+ root = new IUElementListRoot(ui);
ArrayList<AvailableIUElement> list = new ArrayList<AvailableIUElement>(selectedElements.length);
ArrayList<AvailableIUElement> selected = new ArrayList<AvailableIUElement>(selectedElements.length);
for (int i = 0; i < selectedElements.length; i++) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
index 86777edbb..4920d4ff2 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
@@ -59,7 +59,7 @@ public abstract class ResolutionResultsWizardPage extends ResolutionStatusPage {
super("ResolutionPage", ui, wizard); //$NON-NLS-1$
this.resolvedOperation = operation;
if (input == null)
- this.input = new IUElementListRoot();
+ this.input = new IUElementListRoot(ui);
else
this.input = input;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java
index a2bddf191..93cec8be5 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java
@@ -59,7 +59,7 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
super("IUSelectionPage", ui, wizard); //$NON-NLS-1$
this.root = root;
if (root == null)
- root = new IUElementListRoot();
+ root = new IUElementListRoot(ui);
if (initialSelections == null)
this.initialSelections = new IInstallableUnit[0];
else
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UninstallWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UninstallWizard.java
index 9743c96f8..bfcb6334f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UninstallWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UninstallWizard.java
@@ -48,7 +48,7 @@ public class UninstallWizard extends ProvisioningOperationWizard {
}
protected void initializeResolutionModelElements(Object[] selectedElements) {
- root = new IUElementListRoot();
+ root = new IUElementListRoot(ui);
ArrayList<InstalledIUElement> list = new ArrayList<InstalledIUElement>(selectedElements.length);
ArrayList<InstalledIUElement> selections = new ArrayList<InstalledIUElement>(selectedElements.length);
for (int i = 0; i < selectedElements.length; i++) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
index 1f6c53449..fa252f22c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java
@@ -116,7 +116,7 @@ public class UpdateWizard extends WizardWithLicenses {
protected void initializeResolutionModelElements(Object[] selectedElements) {
if (selectedElements == null)
return;
- root = new IUElementListRoot();
+ root = new IUElementListRoot(ui);
if (operation instanceof RemediationOperation) {
AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy(), false);
root.setChildren(elements);
@@ -176,7 +176,7 @@ public class UpdateWizard extends WizardWithLicenses {
private IUElementListRoot getAllPossibleUpdatesRoot() {
if (firstPageRoot == null) {
- firstPageRoot = new IUElementListRoot();
+ firstPageRoot = new IUElementListRoot(ui);
if (operation != null && operation instanceof UpdateOperation) {
Update[] updates;
if (getPolicy().getShowLatestVersionsOnly()) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
index 255bef63e..366bcc552 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java
@@ -129,12 +129,13 @@ public class ElementUtils {
if (remedy == null)
return new AvailableIUElement[0];
ArrayList<AvailableIUElement> temp = new ArrayList<AvailableIUElement>();
- IUElementListRoot root = new IUElementListRoot();
+ ProvisioningUI ui = ProvisioningUI.getDefaultUI();
+ IUElementListRoot root = new IUElementListRoot(ui);
for (Iterator<RemedyIUDetail> iterator = remedy.getIusDetails().iterator(); iterator.hasNext();) {
RemedyIUDetail iuDetail = iterator.next();
if (iuDetail.getStatus() == RemedyIUDetail.STATUS_NOT_ADDED)
continue;
- AvailableIUElement element = new AvailableIUElement(root, iuDetail.getIu(), ProvisioningUI.getDefaultUI().getProfileId(), true);
+ AvailableIUElement element = new AvailableIUElement(root, iuDetail.getIu(), ui.getProfileId(), true);
if (iuDetail.getBeingInstalledVersion() != null && iuDetail.getRequestedVersion() != null && iuDetail.getBeingInstalledVersion().compareTo(iuDetail.getRequestedVersion()) < 0 && !installMode)
element.setImageOverlayId(ProvUIImages.IMG_INFO);
else if (iuDetail.getStatus() == RemedyIUDetail.STATUS_REMOVED)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/IUElementListRoot.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/IUElementListRoot.java
index efe0cc92b..99897e4ba 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/IUElementListRoot.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/IUElementListRoot.java
@@ -10,7 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.model;
-
+import org.eclipse.equinox.p2.ui.Policy;
+import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
* Element class representing a fixed set of IU's. This element should
@@ -18,9 +19,9 @@ package org.eclipse.equinox.internal.p2.ui.model;
*
* @since 3.5
*/
-public class IUElementListRoot extends ProvElement {
-
+public class IUElementListRoot extends QueriedElement {
Object[] children;
+ private ProvisioningUI ui;
public IUElementListRoot(Object[] children) {
super(null);
@@ -31,6 +32,11 @@ public class IUElementListRoot extends ProvElement {
this(new Object[0]);
}
+ public IUElementListRoot(ProvisioningUI ui) {
+ this(new Object[0]);
+ this.ui = ui;
+ }
+
public void setChildren(Object[] children) {
this.children = children;
}
@@ -54,4 +60,19 @@ public class IUElementListRoot extends ProvElement {
public Object[] getChildren(Object o) {
return children;
}
+
+ @Override
+ protected int getDefaultQueryType() {
+ throw new UnsupportedOperationException();
+ }
+
+ public Policy getPolicy() {
+ return getProvisioningUI().getPolicy();
+ }
+
+ public ProvisioningUI getProvisioningUI() {
+ if (ui != null)
+ return ui;
+ return super.getProvisioningUI();
+ }
}

Back to the top