summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (JBoss)2013-04-28 00:18:00 (EDT)
committerPascal Rapicault2013-04-28 00:18:00 (EDT)
commit19b4797066d7d68231678bef73ffa79e6fba62b1 (patch)
treeeca7e22a57d24f8a3f5781c8b526def36e3e0f59
parent5cff3990a07387effa11f97594609aa758398198 (diff)
downloadrt.equinox.p2-19b4797066d7d68231678bef73ffa79e6fba62b1.zip
rt.equinox.p2-19b4797066d7d68231678bef73ffa79e6fba62b1.tar.gz
rt.equinox.p2-19b4797066d7d68231678bef73ffa79e6fba62b1.tar.bz2
Move code around
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java (renamed from bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationComposite.java)36
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationPage.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/UpdateWizard.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ElementUtils.java34
6 files changed, 68 insertions, 40 deletions
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 57949d8..e22b513 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
@@ -65,9 +65,9 @@ public class InstallWizard extends WizardWithLicenses {
return;
root = new IUElementListRoot();
if (operation instanceof RemediationOperation) {
- ArrayList<AvailableIUElement> list = remediationPage.transformIUstoIUElements();
- root.setChildren(list.toArray());
- planSelections = list.toArray();
+ AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy());
+ root.setChildren(elements);
+ planSelections = elements;
} else {
ArrayList<AvailableIUElement> list = new ArrayList<AvailableIUElement>(selectedElements.length);
ArrayList<AvailableIUElement> selections = new ArrayList<AvailableIUElement>(selectedElements.length);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
index 56535b4..1309efd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
@@ -143,7 +143,7 @@ public abstract class ProvisioningOperationWizard extends Wizard {
couldNotResolve(null);
}
operation = remediationOperation;
- initializeResolutionModelElements(remediationPage.transformIUstoIUElements().toArray());
+ initializeResolutionModelElements(ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy()));
planChanged();
return resolutionPage;
} else if (page == mainPage || page == errorPage) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationComposite.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java
index 2d9f205..8ae7a95 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationComposite.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java
@@ -21,24 +21,25 @@ import org.eclipse.equinox.p2.operations.RemediationOperation;
import org.eclipse.equinox.p2.operations.Remedy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
-public class RemediationComposite {
+public class RemediationGroup {
final int ALLOWPARTIALINSTALL_INDEX = 0;
final int ALLOWDIFFERENTVERSION_INDEX = 1;
final int ALLOWINSTALLEDUPDATE_INDEX = 2;
final int ALLOWINSTALLEDREMOVAL_INDEX = 3;
private RemediationOperation remediationOperation;
- private Composite remediationComposite;
+ Composite remediationComposite;
private Button bestBeingInstalledRelaxedButton;
private Button bestInstalledRelaxedButton;
Button buildMyOwnSolution;
- final ArrayList<Button> checkboxes;
+ final ArrayList<Button> checkboxes = new ArrayList<Button>();
private Composite resultFoundComposite;
private Composite resultComposite;
private Composite resultNotFoundComposite;
@@ -52,8 +53,15 @@ public class RemediationComposite {
Composite checkBoxesComposite;
private IUDetailsGroup iuDetailsGroup;
- public RemediationComposite() {
- checkboxes = new ArrayList<Button>();
+ HashMap<String, String[]> CONSTRAINTS;
+ private WizardPage containerPage;
+
+ public RemediationGroup(WizardPage page) {
+ CONSTRAINTS = new HashMap<String, String[]>();
+ CONSTRAINTS.put(ProvUIMessages.RemediationPage_BeingInstalledSection, new String[] {ProvUIMessages.RemediationPage_BeingInstalledSection_AllowPartialInstall, ProvUIMessages.RemediationPage_BeingInstalledSection_AllowDifferentVersion});
+ CONSTRAINTS.put(ProvUIMessages.RemediationPage_InstalledSection, new String[] {ProvUIMessages.RemediationPage_InstalledSection_AllowInstalledUpdate, ProvUIMessages.RemediationPage_InstalledSection_AllowInstalledRemoval});
+
+ containerPage = page;
}
public Composite getComposite() {
@@ -61,18 +69,10 @@ public class RemediationComposite {
}
public void createRemediationControl(Composite container) {
-
remediationComposite = new Composite(container, SWT.NONE);
remediationComposite.setLayout(new GridLayout());
Listener bestSolutionlistener;
- final HashMap<String, String[]> CONSTRAINTS = new HashMap<String, String[]>() {
- {
- put(ProvUIMessages.RemediationPage_BeingInstalledSection, new String[] {ProvUIMessages.RemediationPage_BeingInstalledSection_AllowPartialInstall, ProvUIMessages.RemediationPage_BeingInstalledSection_AllowDifferentVersion});
- put(ProvUIMessages.RemediationPage_InstalledSection, new String[] {ProvUIMessages.RemediationPage_InstalledSection_AllowInstalledUpdate, ProvUIMessages.RemediationPage_InstalledSection_AllowInstalledRemoval});
- }
- };
-
Label descriptionLabel = new Label(remediationComposite, SWT.NONE);
descriptionLabel.setText(ProvUIMessages.RemediationPage_SubDescription);
@@ -95,7 +95,7 @@ public class RemediationComposite {
checkBoxesComposite.setVisible(false);
((GridData) checkBoxesComposite.getLayoutData()).exclude = true;
}
- refreshRemediationResultComposite();
+ refresh();
remediationComposite.layout(false);
}
};
@@ -114,7 +114,7 @@ public class RemediationComposite {
Listener relaxedConstraintlistener = new Listener() {
public void handleEvent(Event e) {
- refreshRemediationResultComposite();
+ refresh();
}
};
checkBoxesComposite = new Composite(remediationComposite, SWT.NONE);
@@ -221,14 +221,13 @@ public class RemediationComposite {
buildMyOwnSolution.setData(remediationOperation.getRemedies().get(0));
buildMyOwnSolution.notifyListeners(SWT.Selection, new Event());
}
-
}
private boolean isContraintOK(int btnIndex, boolean value) {
return (checkboxes.get(btnIndex).getSelection() && value) || (!checkboxes.get(btnIndex).getSelection() && !value);
}
- public void refreshRemediationResultComposite() {
+ void refresh() {
resultComposite.setVisible(true);
remediationOperation.setCurrentRemedy(null);
Remedy currentRemedy = null;
@@ -263,9 +262,10 @@ public class RemediationComposite {
}
}
resultComposite.layout();
+ containerPage.setPageComplete(currentRemedy != null);
}
- public ArrayList<AvailableIUElement> transformIUstoIUElements() {
+ private ArrayList<AvailableIUElement> transformIUstoIUElements() {
ArrayList<AvailableIUElement> temp = new ArrayList<AvailableIUElement>();
ArrayList<String> updateIds = new ArrayList<String>();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationPage.java
index 0e9ea97..7b35684 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationPage.java
@@ -10,10 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.dialogs;
-import java.util.ArrayList;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement;
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
@@ -28,7 +26,7 @@ import org.eclipse.swt.widgets.Control;
public class RemediationPage extends ResolutionStatusPage {
- private RemediationComposite remediationComposite;
+ private RemediationGroup remediationGroup;
private Composite mainComposite;
protected RemediationPage(ProvisioningUI ui, ProvisioningOperationWizard wizard, IUElementListRoot input, ProfileChangeOperation operation) {
@@ -46,28 +44,24 @@ public class RemediationPage extends ResolutionStatusPage {
mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setLayout(new GridLayout());
- remediationComposite = new RemediationComposite();
- remediationComposite.createRemediationControl(mainComposite);
- Composite innerComposite = remediationComposite.getComposite();
- setMessage(remediationComposite.getMessage(), IStatus.WARNING);
+ remediationGroup = new RemediationGroup(this);
+ remediationGroup.createRemediationControl(mainComposite);
+ Composite remediationComposite = remediationGroup.getComposite();
+ setMessage(remediationGroup.getMessage(), IStatus.WARNING);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- innerComposite.setLayoutData(gd);
+ remediationComposite.setLayoutData(gd);
setControl(mainComposite);
setPageComplete(false);
Dialog.applyDialogFont(mainComposite);
}
- public ArrayList<AvailableIUElement> transformIUstoIUElements() {
- return remediationComposite.transformIUstoIUElements();
- }
-
public boolean canFlipToNextPage() {
- return isPageComplete();
+ return isPageComplete() && ((ProvisioningOperationWizard) getWizard()).getRemediationOperation().getCurrentRemedy() != null;
}
public void updateStatus(IUElementListRoot newRoot, ProfileChangeOperation operation, Object[] planSelections) {
- remediationComposite.update(((ProvisioningOperationWizard) getWizard()).getRemediationOperation());
+ remediationGroup.update(((ProvisioningOperationWizard) getWizard()).getRemediationOperation());
setDetailText(operation);
}
@@ -83,7 +77,7 @@ public class RemediationPage extends ResolutionStatusPage {
@Override
protected IUDetailsGroup getDetailsGroup() {
- return remediationComposite.getDetailsGroup();
+ return remediationGroup.getDetailsGroup();
}
@Override
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 835b482..d608286 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
@@ -118,9 +118,9 @@ public class UpdateWizard extends WizardWithLicenses {
return;
root = new IUElementListRoot();
if (operation instanceof RemediationOperation) {
- ArrayList<AvailableIUElement> list = remediationPage.transformIUstoIUElements();
- root.setChildren(list.toArray());
- planSelections = list.toArray();
+ AvailableIUElement[] elements = ElementUtils.requestToElement(((RemediationOperation) operation).getCurrentRemedy());
+ root.setChildren(elements);
+ planSelections = elements;
} else {
ArrayList<AvailableUpdateElement> list = new ArrayList<AvailableUpdateElement>(selectedElements.length);
ArrayList<AvailableUpdateElement> selected = new ArrayList<AvailableUpdateElement>(selectedElements.length);
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 3ad63b4..1a663af 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
@@ -17,6 +17,7 @@ import java.util.*;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.operations.Remedy;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
@@ -123,4 +124,37 @@ public class ElementUtils {
return true;
return false;
}
+
+ public static AvailableIUElement[] requestToElement(Remedy remedy) {
+ if (remedy == null)
+ return new AvailableIUElement[0];
+ ArrayList<AvailableIUElement> temp = new ArrayList<AvailableIUElement>();
+
+ ArrayList<String> updateIds = new ArrayList<String>();
+ IUElementListRoot root = new IUElementListRoot();
+ for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) {
+ AvailableIUElement element = new AvailableIUElement(root, addedIU, ProvisioningUI.getDefaultUI().getProfileId(), true);
+ for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) {
+ if (removedIU.getId().equals(addedIU.getId())) {
+ int addedComparedToRemoved = addedIU.getVersion().compareTo(removedIU.getVersion());
+ element.setBeingDowngraded(addedComparedToRemoved < 0);
+ element.setBeingUpgraded(addedComparedToRemoved > 0);
+ updateIds.add(addedIU.getId());
+ break;
+ }
+ }
+ if (!updateIds.contains(addedIU.getId())) {
+ element.setBeingAdded(true);
+ }
+ temp.add(element);
+ }
+ for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) {
+ if (!updateIds.contains(removedIU.getId())) {
+ AvailableIUElement element = new AvailableIUElement(root, removedIU, ProvisioningUI.getDefaultUI().getProfileId(), false);
+ element.setBeingRemoved(true);
+ temp.add(element);
+ }
+ }
+ return temp.toArray(new AvailableIUElement[temp.size()]);
+ }
}