diff options
3 files changed, 50 insertions, 20 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java index aded17899..275e65ef9 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/IProfile.java @@ -131,6 +131,15 @@ public interface IProfile extends IQueryable<IInstallableUnit> { public static final String PROP_INSTALL_FEATURES = "org.eclipse.update.install.features"; //$NON-NLS-1$ /** + * Profile state meta property key. Can be used to mark a profile state that the UI should hide. + * The value of the property is not relevant as the property's existence is enough. Although <code>true</code> + * would be a typical value. + * + * @since 2.1 + */ + public static final String PROP_HIDDEN = "org.eclipse.equinox.p2.state.hidden"; //$NON-NLS-1$ + + /** * Returns the provisioning agent that manages this profile * @return A provisioning agent. */ diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java index 1658c87a4..da500f44f 100644 --- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java +++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. All rights reserved. + * Copyright (c) 2007, 2011 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 @@ -131,7 +131,23 @@ public class ProfileSynchronizer { // write out the new timestamps (for caching) and apply the configuration writeTimestamps(); - return applyConfiguration(false); + IStatus applyResult = applyConfiguration(false); + + // Mark the state update as hidden so it does not appear in the Installation History UI list + // TODO We need to determine if it is ok to use this copy of the profile. + // See https://bugs.eclipse.org/334670 + IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); + if (profileRegistry != null) { + IStatus result = profileRegistry.setProfileStateProperty(profile.getProfileId(), profile.getTimestamp(), IProfile.PROP_HIDDEN, Boolean.TRUE.toString()); + if (!result.isOK()) { + // we don't get here but if we do, we will ignore the problem and continue. We + // still want the install operation to succeed. The consequence of this failure is the + // profile state appears in the UI in the Install History page, which isn't horrible. + LogHelper.log(result); + } + } + + return applyResult; } /* 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 index 12a24b5b8..f58d67e4e 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2011 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 @@ -10,9 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.model; +import java.util.*; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.equinox.internal.p2.ui.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfileRegistry; import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; import org.eclipse.ui.progress.IElementCollector; @@ -38,27 +41,29 @@ public class ProfileSnapshots extends ProvElement implements IDeferredWorkbenchA * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) */ public Object[] getChildren(Object o) { - long[] timestamps = ProvUI.getProfileRegistry(ProvUIActivator.getDefault().getSession()).listProfileTimestamps(profileId); - RollbackProfileElement[] elements = new RollbackProfileElement[timestamps.length]; - boolean skipFirst = false; + IProfileRegistry registry = ProvUI.getProfileRegistry(ProvUIActivator.getDefault().getSession()); + long[] timestamps = registry.listProfileTimestamps(profileId); + + // find out which profile states we should hide + Map<String, String> hidden = registry.getProfileStateProperties(profileId, IProfile.PROP_HIDDEN); + List<RollbackProfileElement> elements = new ArrayList<RollbackProfileElement>(); + for (int i = 0; i < timestamps.length; i++) { - elements[i] = new RollbackProfileElement(this, profileId, timestamps[i]); + if (hidden.containsKey(String.valueOf(timestamps[i]))) + continue; + RollbackProfileElement element = new RollbackProfileElement(this, profileId, timestamps[i]); + elements.add(element); + // 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 (i == timestamps.length - 1) { - elements[i].setIsCurrentProfile(true); - } - } - if (skipFirst) { - RollbackProfileElement[] elementsWithoutFirst = new RollbackProfileElement[elements.length - 1]; - System.arraycopy(elements, 1, elementsWithoutFirst, 0, elements.length - 1); - return elementsWithoutFirst; + // revert to. Just reset the list since it only has one element. + if (i == 0 && element.getChildren(element).length == 0) + elements.clear(); } - return elements; + // current profile is the last one in the list + if (elements.size() > 0) + elements.get(elements.size() - 1).setIsCurrentProfile(true); + return elements.toArray(new RollbackProfileElement[elements.size()]); } /* (non-Javadoc) |