Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2011-03-19 03:03:21 +0000
committerPascal Rapicault2011-03-19 03:03:21 +0000
commit3fefc7d4aff6785c7ae144853b622cd8266db53d (patch)
tree1dfcd89fce12b25bb0e809abd28dd9acc3920fdf /bundles
parent8b070277b9acc59692f7860043bd2fe9c6c810e7 (diff)
downloadrt.equinox.p2-3fefc7d4aff6785c7ae144853b622cd8266db53d.tar.gz
rt.equinox.p2-3fefc7d4aff6785c7ae144853b622cd8266db53d.tar.xz
rt.equinox.p2-3fefc7d4aff6785c7ae144853b622cd8266db53d.zip
Bug 337178 - [ui] Allow for the user to set tag in the installation history dialog
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/RollbackProfileElement.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java66
2 files changed, 66 insertions, 8 deletions
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 3db57f9f2..e957823e6 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
@@ -84,10 +84,18 @@ public class RollbackProfileElement extends RemoteQueriedElement {
return isCurrent;
}
+ public String getProfileId() {
+ return profileId;
+ }
+
public String getProfileTag() {
return profileTag;
}
+ public void setProfileTag(String profileTag) {
+ this.profileTag = profileTag;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.p2.ui.model.QueriedElement#getDefaultQueryType()
*/
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index 072136c32..d85252c02 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.equinox.p2.ui;
-import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
import java.util.Iterator;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.*;
@@ -68,6 +67,52 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
InstalledIUGroup installedIUGroup;
ProvisioningUI ui;
+ private static class TagEditingSuport extends EditingSupport {
+
+ private ProvisioningUI ui;
+
+ public TagEditingSuport(TableViewer viewer, ProvisioningUI ui) {
+ super(viewer);
+ this.ui = ui;
+ }
+
+ protected CellEditor getCellEditor(Object element) {
+ return new TextCellEditor(((TableViewer) getViewer()).getTable());
+ }
+
+ protected boolean canEdit(Object element) {
+ return element instanceof RollbackProfileElement;
+ }
+
+ protected Object getValue(Object element) {
+ if (element instanceof RollbackProfileElement) {
+ return ((RollbackProfileElement) element).getProfileTag() != null ? ((RollbackProfileElement) element).getProfileTag() : ""; //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ protected void setValue(Object element, Object value) {
+ if (element instanceof RollbackProfileElement && value instanceof String) {
+ RollbackProfileElement ele = ((RollbackProfileElement) element);
+ ele.setProfileTag((String) value);
+ // save
+ IProfileRegistry registry = ProvUI.getProfileRegistry(ui.getSession());
+ if (registry != null) {
+ IStatus status;
+ if (((String) value).length() > 0) {
+ status = registry.setProfileStateProperty(ele.getProfileId(), ele.getTimestamp(), IProfile.STATE_PROP_TAG, (String) value);
+ } else {
+ status = registry.removeProfileStateProperties(ele.getProfileId(), ele.getTimestamp(), Collections.singleton(IProfile.STATE_PROP_TAG));
+ }
+ if (!status.isOK()) {
+ StatusManager.getManager().handle(status);
+ }
+ }
+ getViewer().update(element, null);
+ }
+ }
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.about.InstallationPage#createPageButtons(org.eclipse.swt.widgets.Composite)
@@ -128,7 +173,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.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+ configsViewer = new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
ProvElementContentProvider provider = new ProvElementContentProvider() {
protected void finishedFetchingElements(Object o) {
Object element = configsViewer.getElementAt(0);
@@ -136,7 +181,8 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
configsViewer.setSelection(new StructuredSelection(element));
}
};
- setTableColumns(configsViewer.getTable());
+ setConfigsColumns(configsViewer);
+
// Use deferred fetch because getting snapshots is expensive.
provider.setFetchInBackground(true);
configsViewer.setContentProvider(provider);
@@ -170,17 +216,21 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
configsViewer.getControl().setLayoutData(gd);
}
- private void setTableColumns(Table table) {
- table.setHeaderVisible(true);
- TableColumn tc = new TableColumn(table, SWT.NONE, 0);
+ private void setConfigsColumns(TableViewer tableViewer) {
+ tableViewer.getTable().setHeaderVisible(true);
+ TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
+ TableColumn tc = column.getColumn();
tc.setResizable(true);
tc.setText(ProvUIMessages.RevertProfilePage_ProfileTimestampColumn);
tc.setWidth(175);
- tc = new TableColumn(table, SWT.NONE, 1);
+ column = new TableViewerColumn(tableViewer, SWT.NONE);
+ tc = column.getColumn();
tc.setResizable(true);
tc.setText(ProvUIMessages.RevertProfilePage_ProfileTagColumn);
tc.setWidth(200);
+
+ column.setEditingSupport(new TagEditingSuport(tableViewer, ui));
}
private void createContentsSection(Composite parent) {

Back to the top