Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/DefaultQueryProvider.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java94
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties1
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java104
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackRepositoryElement.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/RollbackIUCollector.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java34
10 files changed, 173 insertions, 293 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
index a14d3dc9c..1935c0475 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoriesView.java
@@ -11,28 +11,22 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.admin;
-import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.admin.dialogs.AddMetadataRepositoryDialog;
import org.eclipse.equinox.internal.p2.ui.admin.preferences.PreferenceConstants;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepositoryManager;
-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.*;
+import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.internal.provisional.p2.ui.actions.InstallAction;
import org.eclipse.equinox.internal.provisional.p2.ui.model.IRepositoryElement;
import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.*;
import org.eclipse.equinox.internal.provisional.p2.ui.viewers.IUDragAdapter;
import org.eclipse.equinox.internal.provisional.p2.ui.viewers.StructuredViewerProvisioningListener;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.PluginTransfer;
@@ -45,65 +39,7 @@ import org.eclipse.ui.statushandlers.StatusManager;
*/
public class MetadataRepositoriesView extends RepositoriesView {
- private class RevertAction extends Action {
-
- RevertAction() {
- setText(ProvUI.REVERT_COMMAND_LABEL);
- setToolTipText(ProvUI.REVERT_COMMAND_TOOLTIP);
- setImageDescriptor(ProvUIImages.getImageDescriptor(ProvUIImages.IMG_PROFILE));
- }
-
- public void run() {
- IInstallableUnit[] ius = getSelectedIUs();
- String targetProfileId = ProvAdminUIActivator.getDefault().getPolicy().getProfileChooser().getProfileId(getShell());
- ProvisioningPlan plan = getProvisioningPlan(ius);
- if (ProvAdminUIActivator.getDefault().getPolicy().getPlanValidator().continueWorkingWithPlan(plan, getShell())) {
- ProvisioningOperation op = new ProfileModificationOperation(ProvAdminUIMessages.MetadataRepositoriesView_RevertLabel, targetProfileId, plan);
- ProvisioningOperationRunner.schedule(op, StatusManager.SHOW | StatusManager.LOG);
- }
- }
-
- protected IInstallableUnit[] getSelectedIUs() {
- ISelection selection = viewer.getSelection();
- if (!(selection instanceof IStructuredSelection))
- return new IInstallableUnit[0];
- List elements = ((IStructuredSelection) selection).toList();
- List iusList = new ArrayList(elements.size());
-
- for (int i = 0; i < elements.size(); i++) {
- IInstallableUnit iu = (IInstallableUnit) ProvUI.getAdapter(elements.get(i), IInstallableUnit.class);
- if (iu != null && !ProvisioningUtil.isCategory(iu))
- iusList.add(iu);
- }
- return (IInstallableUnit[]) iusList.toArray(new IInstallableUnit[iusList.size()]);
- }
-
- private ProvisioningPlan getProvisioningPlan(final IInstallableUnit[] ius) {
- final ProvisioningPlan[] plan = new ProvisioningPlan[1];
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- try {
- if (ius.length == 1)
- plan[0] = ProvisioningUtil.getRevertPlan(ius[0], monitor);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, ProvAdminUIMessages.MetadataRepositoriesView_UnexpectedRevertError, StatusManager.BLOCK | StatusManager.LOG);
- }
- }
- };
- try {
- new ProgressMonitorDialog(getShell()).run(true, true, runnable);
- } catch (InterruptedException e) {
- // don't report thread interruption
- } catch (InvocationTargetException e) {
- ProvUI.handleException(e.getCause(), ProvAdminUIMessages.MetadataRepositoriesView_UnexpectedRevertError, StatusManager.BLOCK | StatusManager.LOG);
- }
- return plan[0];
- }
-
- }
-
private InstallAction installAction;
- private RevertAction revertAction;
/**
* The constructor.
@@ -144,14 +80,12 @@ public class MetadataRepositoriesView extends RepositoriesView {
protected void makeActions() {
super.makeActions();
installAction = new InstallAction(ProvAdminUIActivator.getDefault().getPolicy(), viewer, null);
- revertAction = new RevertAction();
}
protected void fillContextMenu(IMenuManager manager) {
if (installAction.isEnabled()) {
manager.add(new Separator());
manager.add(installAction);
- manager.add(revertAction);
}
super.fillContextMenu(manager);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/DefaultQueryProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/DefaultQueryProvider.java
index 06d0a7fbb..d55043614 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/DefaultQueryProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/DefaultQueryProvider.java
@@ -18,7 +18,6 @@ import org.eclipse.equinox.internal.provisional.p2.director.IUProfilePropertyQue
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IUPropertyQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.internal.provisional.p2.query.*;
import org.eclipse.equinox.internal.provisional.p2.ui.*;
import org.eclipse.equinox.internal.provisional.p2.ui.model.MetadataRepositories;
@@ -67,6 +66,7 @@ public class DefaultQueryProvider extends QueryProvider {
return true;
}
});
+
case QueryProvider.AVAILABLE_IUS :
// Things get more complicated if the user wants to filter out installed items.
// This involves setting up a secondary query for installed content that the various
@@ -85,14 +85,6 @@ public class DefaultQueryProvider extends QueryProvider {
}
}
- // Showing children of a rollback element
- if (element instanceof RollbackRepositoryElement) {
- Query profileIdQuery = new InstallableUnitQuery(((RollbackRepositoryElement) element).getProfileId());
- Query rollbackIUQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_PROFILE, Boolean.toString(true));
- availableIUCollector = new RollbackIUCollector(queryable, element.getParent(element));
- return new ElementQueryDescriptor(queryable, new CompoundQuery(new Query[] {profileIdQuery, rollbackIUQuery}, true), availableIUCollector);
- }
-
Query topLevelQuery = new IUPropertyQuery(context.getVisibleAvailableIUProperty(), Boolean.TRUE.toString());
Query categoryQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true));
@@ -133,6 +125,7 @@ public class DefaultQueryProvider extends QueryProvider {
return new ElementQueryDescriptor(queryable, new CompoundQuery(new Query[] {topLevelQuery, meetsAnyRequirementQuery}, true), availableIUCollector);
}
return null;
+
case QueryProvider.AVAILABLE_UPDATES :
IProfile profile;
IInstallableUnit[] toUpdate = null;
@@ -160,6 +153,7 @@ public class DefaultQueryProvider extends QueryProvider {
else
collector = new Collector();
return new ElementQueryDescriptor(updateQueryable, allQuery, collector);
+
case QueryProvider.INSTALLED_IUS :
// Querying of IU's. We are drilling down into the requirements.
if (element instanceof IIUElement && context.getShowInstallChildren()) {
@@ -170,13 +164,8 @@ public class DefaultQueryProvider extends QueryProvider {
profile = (IProfile) ProvUI.getAdapter(element, IProfile.class);
if (profile == null)
return null;
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=229352
- // Rollback profiles are specialized/temporary instances so we must use a query that uses the profile instance, not the id.
- if (element instanceof RollbackProfileElement)
- return new ElementQueryDescriptor(profile, new IUProfilePropertyQuery(profile, context.getVisibleInstalledIUProperty(), Boolean.toString(true)), new InstalledIUCollector(profile, element));
-
- // Just a normal query of the installed IU's, query the profile and look for the visible ones
return new ElementQueryDescriptor(profile, new IUProfilePropertyQuery(profile, context.getVisibleInstalledIUProperty(), Boolean.toString(true)), new InstalledIUCollector(profile, element));
+
case QueryProvider.METADATA_REPOS :
if (element instanceof MetadataRepositories) {
if (queryable == null) {
@@ -186,6 +175,7 @@ public class DefaultQueryProvider extends QueryProvider {
return new ElementQueryDescriptor(element.getQueryable(), null, new MetadataRepositoryElementCollector(element.getQueryable(), element));
}
return null;
+
case QueryProvider.PROFILES :
queryable = new QueryableProfileRegistry();
return new ElementQueryDescriptor(queryable, new Query() {
@@ -193,6 +183,7 @@ public class DefaultQueryProvider extends QueryProvider {
return ProvUI.getAdapter(candidate, IProfile.class) != null;
}
}, new ProfileElementCollector(null, element));
+
default :
return null;
}
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 19b3303a9..c4ea14790 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
@@ -69,6 +69,7 @@ public class ProvUIMessages extends NLS {
public static String ProfileModificationWizardPage_NothingSelected;
public static String ProfileModificationWizardPage_ResolutionOperationLabel;
public static String ProfileModificationWizardPage_UnexpectedError;
+ public static String ProfileSnapshots_Label;
// utility error messages
public static String ProvisioningUtil_NoRepositoryManager;
public static String ProvisioningUtil_LoadRepositoryFailure;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
index fb9d15c64..b1ba13871 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RevertProfileWizardPage.java
@@ -11,17 +11,15 @@
package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
-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.internal.p2.ui.model.ProfileSnapshots;
import org.eclipse.equinox.internal.p2.ui.model.RollbackProfileElement;
-import org.eclipse.equinox.internal.p2.ui.model.RollbackRepositoryElement;
import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryContentProvider;
import org.eclipse.equinox.internal.p2.ui.viewers.IUDetailsLabelProvider;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvisioningOperationRunner;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.*;
@@ -32,7 +30,6 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.*;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -91,15 +88,18 @@ public class RevertProfileWizardPage extends WizardPage {
configsViewer.setLabelProvider(new ProvElementLabelProvider());
configsViewer.setComparator(new ViewerComparator() {
// We override the ViewerComparator so that we don't get the labels of the elements
- // for comparison, but rather get the version numbers and compare them.
+ // for comparison, but rather get the timestamps and compare them.
// Reverse sorting is used so that newest is first.
public int compare(Viewer viewer, Object o1, Object o2) {
- IInstallableUnit iu1 = (IInstallableUnit) ProvUI.getAdapter(o1, IInstallableUnit.class);
- IInstallableUnit iu2 = (IInstallableUnit) ProvUI.getAdapter(o2, IInstallableUnit.class);
- if (iu1 == null || iu2 == null)
- // this is naive (doesn't consult the label provider), but shouldn't happen
- return o2.toString().compareTo(o1.toString());
- return iu2.getVersion().compareTo(iu1.getVersion());
+ if (o1 instanceof RollbackProfileElement && o2 instanceof RollbackProfileElement) {
+ long timestamp1 = ((RollbackProfileElement) o1).getTimestamp();
+ long timestamp2 = ((RollbackProfileElement) o2).getTimestamp();
+ if (timestamp1 > timestamp2)
+ return -1;
+ return 1;
+ }
+ // this is naive (doesn't consult the label provider), but shouldn't happen
+ return o2.toString().compareTo(o1.toString());
}
});
configsViewer.setInput(getInput());
@@ -140,34 +140,17 @@ public class RevertProfileWizardPage extends WizardPage {
}
private Object getInput() {
- try {
- RollbackRepositoryElement element = new RollbackRepositoryElement(ProvisioningUtil.getRollbackRepositoryURL(), profileId);
- return element;
- } catch (ProvisionException e) {
- ProvUI.handleException(e, ProvUIMessages.RevertProfileWizardPage_ErrorRetrievingHistory, StatusManager.BLOCK | StatusManager.LOG);
- return null;
- }
+ ProfileSnapshots element = new ProfileSnapshots(profileId);
+ return element;
}
void handleSelectionChanged(IStructuredSelection selection) {
if (!selection.isEmpty()) {
final Object selected = selection.getFirstElement();
if (selected instanceof RollbackProfileElement) {
- final IProfile[] snapshot = new IProfile[1];
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- public void run() {
- try {
- snapshot[0] = ((RollbackProfileElement) selected).getProfileSnapshot(null);
- } catch (ProvisionException e) {
- ProvUI.handleException(e, ProvUIMessages.RollbackProfileElement_InvalidSnapshot, StatusManager.LOG | StatusManager.SHOW);
- }
- }
- });
- if (snapshot[0] != null) {
- configContentsViewer.setInput(selected);
- setPageComplete(true);
- return;
- }
+ configContentsViewer.setInput(selected);
+ setPageComplete(true);
+ return;
}
}
configContentsViewer.setInput(null);
@@ -185,10 +168,14 @@ public class RevertProfileWizardPage extends WizardPage {
}
}
- private IInstallableUnit getSelectedIU() {
+ private IProfile getSelectedSnapshot() {
Object selected = ((IStructuredSelection) configsViewer.getSelection()).getFirstElement();
if (selected != null && selected instanceof RollbackProfileElement)
- return ((RollbackProfileElement) selected).getIU();
+ try {
+ return ((RollbackProfileElement) selected).getProfileSnapshot(new NullProgressMonitor());
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null, StatusManager.LOG);
+ }
return null;
}
@@ -206,16 +193,27 @@ public class RevertProfileWizardPage extends WizardPage {
}
private boolean revert() {
- final IInstallableUnit iu = getSelectedIU();
- if (iu == null)
+ final IProfile snapshot = getSelectedSnapshot();
+ if (snapshot == null)
return false;
- final ProvisioningPlan[] plan = new ProvisioningPlan[1];
+ final boolean[] reverted = new boolean[1];
+ reverted[0] = false;
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
- plan[0] = ProvisioningUtil.getRevertPlan(iu, monitor);
+ IProfile currentProfile = ProvisioningUtil.getProfile(profileId);
+ ProvisioningPlan plan = ProvisioningUtil.getRevertPlan(currentProfile, snapshot, monitor);
+ if (plan != null) {
+ if (plan.getStatus().isOK()) {
+ ProvisioningOperation op = new ProfileModificationOperation(ProvUIMessages.RevertDialog_RevertOperationLabel, profileId, plan);
+ ProvisioningOperationRunner.run(op, StatusManager.SHOW | StatusManager.LOG);
+ reverted[0] = true;
+ } else if (plan.getStatus().getSeverity() != IStatus.CANCEL) {
+ ProvUI.reportStatus(plan.getStatus(), StatusManager.LOG);
+ setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, IMessageProvider.ERROR);
+ }
+ }
} catch (ProvisionException e) {
- plan[0] = null;
ProvUI.handleException(e.getCause(), ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, StatusManager.LOG);
setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, IMessageProvider.ERROR);
}
@@ -223,24 +221,12 @@ public class RevertProfileWizardPage extends WizardPage {
};
try {
getContainer().run(true, true, runnable);
- if (plan[0] != null) {
- if (plan[0].getStatus().isOK()) {
- ProvisioningOperation op = new ProfileModificationOperation(ProvUIMessages.RevertDialog_RevertOperationLabel, profileId, plan[0]);
- ProvisioningOperationRunner.run(op, StatusManager.SHOW | StatusManager.LOG);
- return true;
- }
- // If user cancelled, do not report an error
- if (plan[0].getStatus().getSeverity() == IStatus.CANCEL)
- return false;
- ProvUI.reportStatus(plan[0].getStatus(), StatusManager.LOG);
- setMessage(ProvUIMessages.ProfileModificationWizardPage_UnexpectedError, IMessageProvider.ERROR);
- }
} catch (InterruptedException e) {
// don't report thread interruption
} catch (InvocationTargetException e) {
ProvUI.handleException(e.getCause(), ProvUIMessages.RevertDialog_RevertError, StatusManager.LOG);
setMessage(ProvUIMessages.RevertDialog_RevertError, IMessageProvider.ERROR);
}
- return false;
+ return reverted[0];
}
}
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 41f5b47be..0203e302b 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
@@ -18,6 +18,7 @@ ProfileModificationWizardPage_DetailsLabel=Details
ProfileModificationWizardPage_NothingSelected=You must check some items in order to continue.
ProfileModificationWizardPage_ResolutionOperationLabel=Calculating Requirements
ProfileModificationWizardPage_UnexpectedError=An unexpected error occurred. This wizard is no longer valid with the current selections.
+ProfileSnapshots_Label=Installation History
ProvisioningUtil_NoRepositoryManager=No repository manager was found
ProvisioningUtil_LoadRepositoryFailure=Unable to load the repository {0}
ProvisioningUtil_NoProfileRegistryFound=No profile registry was found
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java
new file mode 100644
index 000000000..2663a743f
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 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.model;
+
+import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
+
+/**
+ * Element class for profile snapshots
+ *
+ * @since 3.5
+ */
+public class ProfileSnapshots extends ProvElement {
+
+ String profileId;
+
+ public ProfileSnapshots(String profileId) {
+ super(null);
+ this.profileId = profileId;
+ }
+
+ public String getProfileId() {
+ return profileId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object o) {
+ try {
+ long[] timestamps = ProvisioningUtil.getProfileTimestamps(profileId);
+ // eliminate the last in the list (latest) because that is the current
+ // profile.
+ RollbackProfileElement[] elements = new RollbackProfileElement[timestamps.length - 1];
+ boolean skipFirst = false;
+ for (int i = 0; i < timestamps.length - 1; i++) {
+ elements[i] = new RollbackProfileElement(this, profileId, timestamps[i]);
+ // Eliminate the first in the list (earliest) if there was no content at all.
+ // This doesn't always happen, but can, and we don't want to offer the user an empty profile to
+ // revert to.
+ if (i == 0) {
+ skipFirst = elements[0].getChildren(elements[0]).length == 0;
+ }
+ }
+ if (skipFirst) {
+ RollbackProfileElement[] elementsWithoutFirst = new RollbackProfileElement[elements.length - 1];
+ System.arraycopy(elements, 1, elementsWithoutFirst, 0, elements.length - 1);
+ return elementsWithoutFirst;
+ }
+ return elements;
+ } catch (ProvisionException e) {
+ handleException(e, null);
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+ */
+ public String getLabel(Object o) {
+ return ProvUIMessages.ProfileSnapshots_Label;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java
index 9252581f2..1f2e9622e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java
@@ -13,35 +13,30 @@ package org.eclipse.equinox.internal.p2.ui.model;
import com.ibm.icu.text.DateFormat;
import java.util.Date;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.rollback.FormerState;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
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.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUIImages;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.QueryProvider;
/**
- * Element wrapper class for an IU that represents a profile snapshot
- * from a rollback repository. It has characteristics of an IU element,
- * in that it is stored as an IU and can be adapted to its IU. But
- * conceptually, it is more like a profile, in that its children are the
- * IU's that represent the content of the profile when it was snapshotted.
+ * Element class for a profile snapshot
*
* @since 3.4
*/
-public class RollbackProfileElement extends RemoteQueriedElement implements IIUElement {
+public class RollbackProfileElement extends RemoteQueriedElement {
- private IInstallableUnit iu;
+ private String profileId;
+ private long timestamp;
private IProfile snapshot;
- public RollbackProfileElement(Object parent, IInstallableUnit iu) {
+ public RollbackProfileElement(Object parent, String profileId, long timestamp) {
super(parent);
- this.iu = iu;
+ this.timestamp = timestamp;
+ this.profileId = profileId;
}
/*
@@ -54,94 +49,49 @@ public class RollbackProfileElement extends RemoteQueriedElement implements IIUE
}
public String getLabel(Object o) {
- return DateFormat.getInstance().format(new Date(Long.decode(iu.getVersion().getQualifier()).longValue()));
+ return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date(timestamp));
}
public Object getAdapter(Class adapter) {
- if (adapter == IInstallableUnit.class)
- return iu;
if (adapter == IProfile.class)
try {
- return getProfileSnapshot(null);
+ return getProfileSnapshot(new NullProgressMonitor());
} catch (ProvisionException e) {
handleException(e, ProvUIMessages.RollbackProfileElement_InvalidSnapshot);
}
return super.getAdapter(adapter);
}
- public IInstallableUnit getIU() {
- return iu;
- }
-
- public long getSize() {
- return SIZE_UNKNOWN;
- }
-
- public boolean shouldShowSize() {
- return false;
- }
-
- public boolean shouldShowVersion() {
- return false;
- }
-
- public void computeSize(IProgressMonitor monitor) {
- // Should never be called, since shouldShowSize() returns false
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#getDefaultQueryType()
- */
- protected int getDefaultQueryType() {
- return QueryProvider.INSTALLED_IUS;
- }
-
- /*
- * overridden to lazily fetch profile
- * (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#getQueryable()
- */
- public IQueryable getQueryable() {
- if (queryable == null)
- try {
- queryable = getProfileSnapshot(null);
- } catch (ProvisionException e) {
- handleException(e, ProvUIMessages.RollbackProfileElement_InvalidSnapshot);
- }
- return queryable;
- }
-
public IProfile getProfileSnapshot(IProgressMonitor monitor) throws ProvisionException {
if (snapshot == null) {
- IProfile profile = ProvisioningUtil.getProfile(iu.getId());
- snapshot = FormerState.IUToProfile(iu, profile, new ProvisioningContext(), monitor);
+ snapshot = ProvisioningUtil.getProfile(profileId, timestamp);
setQueryable(snapshot);
}
return snapshot;
}
- /*
- * overridden to check whether snapshot IU is specified rather
- * than loading the profile via getQueryable()
- * (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.p2.ui.query.QueriedElement#knowsQueryable()
- */
- public boolean knowsQueryable() {
- return iu != null;
+ public long getTimestamp() {
+ return timestamp;
}
/* (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.model.IUElement#getRequirements()
+ * @see org.eclipse.equinox.internal.p2.ui.model.QueriedElement#getDefaultQueryType()
*/
- public IRequiredCapability[] getRequirements() {
- return iu.getRequiredCapabilities();
+ protected int getDefaultQueryType() {
+ return QueryProvider.INSTALLED_IUS;
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.model.IIUElement#shouldShowChildren()
+ /*
+ * The queryable is the profile snapshot
+ * (non-Javadoc)
+ * @see org.eclipse.equinox.internal.p2.ui.model.QueriedElement#getQueryable()
*/
- public boolean shouldShowChildren() {
- return false;
+ public IQueryable getQueryable() {
+ try {
+ return getProfileSnapshot(new NullProgressMonitor());
+ } catch (ProvisionException e) {
+ handleException(e, null);
+ return null;
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackRepositoryElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackRepositoryElement.java
deleted file mode 100644
index d43cea39d..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackRepositoryElement.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.model;
-
-import java.net.URI;
-
-/**
- * Element wrapper class for a rollback repository.
- *
- * @since 3.4
- */
-public class RollbackRepositoryElement extends MetadataRepositoryElement {
-
- String profileId;
-
- public RollbackRepositoryElement(URI location, String profileId) {
- super(null, location);
- this.profileId = profileId;
- }
-
- public String getProfileId() {
- return profileId;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/RollbackIUCollector.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/RollbackIUCollector.java
deleted file mode 100644
index 38fd7733c..000000000
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/RollbackIUCollector.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.query;
-
-import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
-import org.eclipse.equinox.internal.p2.ui.model.RollbackProfileElement;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
-
-/**
- * Collector that examines available IU's and wraps them in an
- * element representing either a category an IU.
- *
- * @since 3.4
- */
-public class RollbackIUCollector extends AvailableIUCollector {
-
- public RollbackIUCollector(IQueryable queryable, Object parent) {
- super(queryable, parent, false, true);
- }
-
- protected IIUElement makeDefaultElement(IInstallableUnit iu) {
- return new RollbackProfileElement(parent, iu);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
index 909c99ed0..a077c8a15 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/operations/ProvisioningUtil.java
@@ -85,14 +85,6 @@ public class ProvisioningUtil {
return manager.validateRepositoryLocation(location, monitor);
}
- public static URI getRollbackRepositoryURL() throws ProvisionException {
- IDirector director = getDirector();
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
- if (manager == null)
- throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoRepositoryManager);
- return director.getRollbackRepositoryLocation();
- }
-
public static void removeMetadataRepository(URI location) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null) {
@@ -174,6 +166,15 @@ public class ProvisioningUtil {
return profileRegistry.getProfiles();
}
+ public static long[] getProfileTimestamps(String id) throws ProvisionException {
+ IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
+ if (profileRegistry == null) {
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoProfileRegistryFound);
+ }
+ return profileRegistry.listProfileTimestamps(id);
+
+ }
+
public static IProfile getProfile(String id) throws ProvisionException {
IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
if (profileRegistry == null) {
@@ -182,6 +183,14 @@ public class ProvisioningUtil {
return profileRegistry.getProfile(id);
}
+ public static IProfile getProfile(String id, long timestamp) throws ProvisionException {
+ IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
+ if (profileRegistry == null) {
+ throw new ProvisionException(ProvUIMessages.ProvisioningUtil_NoProfileRegistryFound);
+ }
+ return profileRegistry.getProfile(id, timestamp);
+ }
+
public static URI[] getMetadataRepositories(int flags) throws ProvisionException {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName());
if (manager == null) {
@@ -232,11 +241,12 @@ public class ProvisioningUtil {
}
/*
- * Get a plan for becoming
+ * Get a plan for reverting to a specified profile snapshot
*/
- public static ProvisioningPlan getRevertPlan(IInstallableUnit profileIU, IProgressMonitor monitor) throws ProvisionException {
- Assert.isNotNull(profileIU);
- return getPlanner().getRevertPlan(profileIU, new ProvisioningContext(), monitor);
+ public static ProvisioningPlan getRevertPlan(IProfile currentProfile, IProfile snapshot, IProgressMonitor monitor) throws ProvisionException {
+ Assert.isNotNull(currentProfile);
+ Assert.isNotNull(snapshot);
+ return getPlanner().getRevertPlan(currentProfile, snapshot, new ProvisioningContext(), monitor);
}
/*

Back to the top