Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2009-09-08 23:46:41 +0000
committerSusan Franklin2009-09-08 23:46:41 +0000
commitfb152d69c2aa9bac5710de9a2516ca0c8c02faac (patch)
treed182936ff4ff1f75680f3c492568631eedc0980f /bundles/org.eclipse.equinox.p2.ui/src
parentfbf145f3f1c299dc558f57e79efd5190186bd0f8 (diff)
downloadrt.equinox.p2-fb152d69c2aa9bac5710de9a2516ca0c8c02faac.tar.gz
rt.equinox.p2-fb152d69c2aa9bac5710de9a2516ca0c8c02faac.tar.xz
rt.equinox.p2-fb152d69c2aa9bac5710de9a2516ca0c8c02faac.zip
Bug 284798 - [ui] user management of profile snapshots
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.ui/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvUIMessages.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/messages.properties5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/ProfileSnapshots.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/RevertProfilePage.java92
4 files changed, 92 insertions, 13 deletions
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 0b604ba0c..4ad793fe1 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
@@ -42,6 +42,11 @@ public class ProvUIMessages extends NLS {
public static String ColocatedRepositoryManipulator_GotoPrefs;
public static String ColocatedRepositoryManipulator_ManageSites;
public static String ColocatedRepositoryManipulator_RemoveSiteOperationLabel;
+ public static String RevertProfilePage_ConfirmDeleteMultipleConfigs;
+ public static String RevertProfilePage_ConfirmDeleteSingleConfig;
+ public static String RevertProfilePage_Delete;
+ public static String RevertProfilePage_DeleteMultipleConfigurationsTitle;
+ public static String RevertProfilePage_DeleteSingleConfigurationTitle;
public static String RevertProfilePage_NoProfile;
public static String RevertProfilePage_RevertLabel;
public static String RevertProfilePage_RevertTooltip;
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 95e15f960..a0e061ff5 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
@@ -154,6 +154,11 @@ ColocatedRepositoryManipulator_AddSiteOperationLabel=Add Site
ColocatedRepositoryManipulator_GotoPrefs=Go to the <a>Available Software Sites</a> preferences
ColocatedRepositoryManipulator_ManageSites=&Manage Sites...
ColocatedRepositoryManipulator_RemoveSiteOperationLabel=Remove Site
+RevertProfilePage_ConfirmDeleteMultipleConfigs=Deleting the selected configurations from the installation history will free up the disk space used to store the configurations. However, you will no longer be able to revert your installation to these configurations. Are you sure you want to delete the configurations?
+RevertProfilePage_ConfirmDeleteSingleConfig=Deleting the configuration from the installation history will free up the disk space used to store it. However, you will no longer be able to revert your installation to this configuration. Are you sure you want to delete it?
+RevertProfilePage_Delete=&Delete
+RevertProfilePage_DeleteMultipleConfigurationsTitle=Delete Configurations
+RevertProfilePage_DeleteSingleConfigurationTitle=Delete Configuration
RevertProfilePage_NoProfile=This installation has not been configured properly for accessing the installation history. See the error log for details.
RevertProfilePage_RevertLabel=Re&vert
RevertProfilePage_RevertTooltip=Revert to the selected install configuration.
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 0c17ddfa6..de66eb5fd 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
@@ -47,7 +47,8 @@ public class ProfileSnapshots extends ProvElement {
// revert to.
if (i == 0) {
skipFirst = elements[0].getChildren(elements[0]).length == 0;
- } else if (i == timestamps.length - 1) {
+ }
+ if (i == timestamps.length - 1) {
elements[i].setIsCurrentProfile(true);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/RevertProfilePage.java
index 90726a750..40ec373fd 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/provisional/p2/ui/dialogs/RevertProfilePage.java
@@ -11,7 +11,10 @@
package org.eclipse.equinox.internal.provisional.p2.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.ui.ProvUIActivator;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.dialogs.CopyUtils;
import org.eclipse.equinox.internal.p2.ui.dialogs.ICopyable;
@@ -48,11 +51,12 @@ import org.eclipse.ui.statushandlers.StatusManager;
public class RevertProfilePage extends InstallationPage implements ICopyable {
private static final int REVERT_ID = IDialogConstants.CLIENT_ID;
+ private static final int DELETE_ID = IDialogConstants.CLIENT_ID + 1;
TableViewer configsViewer;
TreeViewer configContentsViewer;
IUDetailsLabelProvider labelProvider;
IAction revertAction;
- Button revertButton;
+ Button revertButton, deleteButton;
String profileId;
AbstractContributionFactory factory;
Text detailsArea;
@@ -61,6 +65,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
public void createPageButtons(Composite parent) {
if (profileId == null)
return;
+ deleteButton = createButton(parent, DELETE_ID, ProvUIMessages.RevertProfilePage_Delete);
+ deleteButton.setEnabled(computeDeleteEnablement());
revertButton = createButton(parent, REVERT_ID, revertAction.getText());
revertButton.setEnabled(revertAction.isEnabled());
}
@@ -109,7 +115,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
Label label = new Label(composite, SWT.NONE);
label.setText(ProvUIMessages.RevertDialog_ConfigsLabel);
- configsViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ configsViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
configsViewer.setContentProvider(new RepositoryContentProvider());
configsViewer.setLabelProvider(new ProvElementLabelProvider());
configsViewer.setComparator(new ViewerComparator() {
@@ -195,28 +201,63 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
case REVERT_ID :
revertAction.run();
break;
+ case DELETE_ID :
+ deleteSelectedSnapshots();
+ break;
}
}
void handleSelectionChanged(IStructuredSelection selection) {
if (!selection.isEmpty()) {
- final Object selected = selection.getFirstElement();
- if (selected instanceof RollbackProfileElement) {
- Object[] elements = configContentsViewer.getExpandedElements();
- configContentsViewer.getTree().setRedraw(false);
- configContentsViewer.setInput(selected);
- configContentsViewer.setExpandedElements(elements);
- configContentsViewer.getTree().setRedraw(true);
- revertAction.setEnabled(!((RollbackProfileElement) selected).isCurrentProfile());
- if (revertButton != null)
- revertButton.setEnabled(revertAction.isEnabled());
+ if (selection.size() == 1) {
+ final Object selected = selection.getFirstElement();
+ if (selected instanceof RollbackProfileElement) {
+ Object[] elements = configContentsViewer.getExpandedElements();
+ configContentsViewer.getTree().setRedraw(false);
+ configContentsViewer.setInput(selected);
+ configContentsViewer.setExpandedElements(elements);
+ configContentsViewer.getTree().setRedraw(true);
+ boolean isNotCurrentProfile = !((RollbackProfileElement) selected).isCurrentProfile();
+ revertAction.setEnabled(isNotCurrentProfile);
+ if (revertButton != null)
+ revertButton.setEnabled(isNotCurrentProfile);
+ if (deleteButton != null)
+ deleteButton.setEnabled(isNotCurrentProfile);
+ return;
+ }
+ } else {
+ // multiple selections, can't revert or look at details
+ revertAction.setEnabled(false);
+ if (revertButton != null) {
+ revertButton.setEnabled(false);
+ }
+ configContentsViewer.setInput(null);
+ deleteButton.setEnabled(computeDeleteEnablement());
return;
}
}
+ // Nothing is selected
configContentsViewer.setInput(null);
revertAction.setEnabled(false);
if (revertButton != null)
revertButton.setEnabled(false);
+ if (deleteButton != null)
+ deleteButton.setEnabled(computeDeleteEnablement());
+ }
+
+ boolean computeDeleteEnablement() {
+ // delete is permitted if none of the selected elements are the current profile
+ boolean okToDelete = true;
+ Iterator iter = ((IStructuredSelection) configsViewer.getSelection()).iterator();
+ while (iter.hasNext()) {
+ Object selected = iter.next();
+ // If it's not a recognized element or if it is the current profile, we can't delete. Stop iterating.
+ if (!(selected instanceof RollbackProfileElement) || ((RollbackProfileElement) selected).isCurrentProfile()) {
+ okToDelete = false;
+ break;
+ }
+ }
+ return okToDelete;
}
private void setTreeColumns(Tree tree) {
@@ -312,4 +353,31 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
clipboard.setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
clipboard.dispose();
}
+
+ void deleteSelectedSnapshots() {
+ IStructuredSelection selection = (IStructuredSelection) configsViewer.getSelection();
+ if (selection.isEmpty())
+ return;
+ String title = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_DeleteSingleConfigurationTitle : ProvUIMessages.RevertProfilePage_DeleteMultipleConfigurationsTitle;
+ String confirmMessage = selection.size() == 1 ? ProvUIMessages.RevertProfilePage_ConfirmDeleteSingleConfig : ProvUIMessages.RevertProfilePage_ConfirmDeleteMultipleConfigs;
+ if (MessageDialog.openConfirm(configsViewer.getControl().getShell(), title, confirmMessage)) {
+ Iterator iter = selection.iterator();
+ while (iter.hasNext()) {
+ Object selected = iter.next();
+ // If it is a recognized element and it is not the current profile, then it can be deleted.
+ if (selected instanceof RollbackProfileElement && !((RollbackProfileElement) selected).isCurrentProfile()) {
+ RollbackProfileElement snapshot = (RollbackProfileElement) selected;
+ IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(ProvUIActivator.getContext(), IProfileRegistry.class.getName());
+ if (registry != null) {
+ try {
+ registry.removeProfile(profileId, snapshot.getTimestamp());
+ configsViewer.refresh();
+ } catch (ProvisionException e) {
+ ProvUI.handleException(e, null, StatusManager.SHOW | StatusManager.LOG);
+ }
+ }
+ }
+ }
+ }
+ }
}

Back to the top