*** empty log message ***
diff --git a/update/org.eclipse.update.core/srcnew/org/eclipse/update/internal/operations/RevertConfigurationOperation.java b/update/org.eclipse.update.core/srcnew/org/eclipse/update/internal/operations/RevertConfigurationOperation.java
new file mode 100644
index 0000000..fdb28f7
--- /dev/null
+++ b/update/org.eclipse.update.core/srcnew/org/eclipse/update/internal/operations/RevertConfigurationOperation.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.update.internal.operations;
+
+import java.lang.reflect.*;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.update.configuration.*;
+import org.eclipse.update.core.*;
+import org.eclipse.update.operations.*;
+
+public class RevertConfigurationOperation extends Operation {
+
+ private static final String KEY_INSTALLING = "OperationsManager.installing";
+ private IInstallConfiguration config;
+ private IProblemHandler problemHandler;
+
+ public RevertConfigurationOperation(
+ IInstallConfiguration config,
+ IProblemHandler problemHandler,
+ IOperationListener listener) {
+ super(listener);
+ this.config = config;
+ this.problemHandler = problemHandler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.update.operations.IOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public boolean execute(IProgressMonitor monitor)
+ throws CoreException, InvocationTargetException {
+ IStatus status =
+ UpdateManager.getValidator().validatePendingRevert(config);
+ if (status != null) {
+ throw new CoreException(status);
+ }
+
+ try {
+ ILocalSite localSite = SiteManager.getLocalSite();
+ localSite.revertTo(config, monitor, problemHandler);
+ localSite.save();
+ return true;
+ } catch (CoreException e) {
+ UpdateManager.logException(e);
+ throw e;
+ }
+ }
+}
diff --git a/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/RevertConfigurationWizardPage.java b/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/RevertConfigurationWizardPage.java
index ff333da..a8cf778 100644
--- a/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/RevertConfigurationWizardPage.java
+++ b/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/RevertConfigurationWizardPage.java
@@ -45,6 +45,8 @@
import org.eclipse.update.configuration.ILocalSite;
import org.eclipse.update.core.SiteManager;
import org.eclipse.update.core.Utilities;
+import org.eclipse.update.core.model.*;
+import org.eclipse.update.internal.operations.*;
import org.eclipse.update.internal.operations.UpdateManager;
import org.eclipse.update.internal.ui.UpdateLabelProvider;
import org.eclipse.update.internal.ui.UpdateUI;
@@ -53,21 +55,31 @@
import org.eclipse.update.internal.ui.parts.DefaultContentProvider;
public class RevertConfigurationWizardPage extends WizardPage {
-
- private static final String KEY_CONFIGURE = "InstallConfigurationPage.ActivitySection.action.configure";
- private static final String KEY_FEATURE_INSTALL = "InstallConfigurationPage.ActivitySection.action.featureInstall";
- private static final String KEY_FEATURE_REMOVE = "InstallConfigurationPage.ActivitySection.action.featureRemove";
- private static final String KEY_SITE_INSTALL = "InstallConfigurationPage.ActivitySection.action.siteInstall";
- private static final String KEY_SITE_REMOVE = "InstallConfigurationPage.ActivitySection.action.siteRemove";
- private static final String KEY_UNCONFIGURE = "InstallConfigurationPage.ActivitySection.action.unconfigure";
- private static final String KEY_UNKNOWN = "InstallConfigurationPage.ActivitySection.action.unknown";
- private static final String KEY_REVERT = "InstallConfigurationPage.ActivitySection.action.revert";
- private static final String KEY_RECONCILIATION = "InstallConfigurationPage.ActivitySection.action.reconcile";
- private static final String KEY_ADD_PRESERVED = "InstallConfigurationPage.ActivitySection.action.addpreserved";
-
+
+ private static final String KEY_CONFIGURE =
+ "InstallConfigurationPage.ActivitySection.action.configure";
+ private static final String KEY_FEATURE_INSTALL =
+ "InstallConfigurationPage.ActivitySection.action.featureInstall";
+ private static final String KEY_FEATURE_REMOVE =
+ "InstallConfigurationPage.ActivitySection.action.featureRemove";
+ private static final String KEY_SITE_INSTALL =
+ "InstallConfigurationPage.ActivitySection.action.siteInstall";
+ private static final String KEY_SITE_REMOVE =
+ "InstallConfigurationPage.ActivitySection.action.siteRemove";
+ private static final String KEY_UNCONFIGURE =
+ "InstallConfigurationPage.ActivitySection.action.unconfigure";
+ private static final String KEY_UNKNOWN =
+ "InstallConfigurationPage.ActivitySection.action.unknown";
+ private static final String KEY_REVERT =
+ "InstallConfigurationPage.ActivitySection.action.revert";
+ private static final String KEY_RECONCILIATION =
+ "InstallConfigurationPage.ActivitySection.action.reconcile";
+ private static final String KEY_ADD_PRESERVED =
+ "InstallConfigurationPage.ActivitySection.action.addpreserved";
+
private TableViewer activitiesViewer;
private TableViewer configViewer;
-
+
class ActivitiesContentProvider
extends DefaultContentProvider
implements IStructuredContentProvider {
@@ -76,61 +88,63 @@
}
}
- class ActivitiesLabelProvider extends LabelProvider implements ITableLabelProvider {
+ class ActivitiesLabelProvider
+ extends LabelProvider
+ implements ITableLabelProvider {
public Image getColumnImage(Object element, int columnIndex) {
if (columnIndex == 0) {
- UpdateLabelProvider provider = UpdateUI.getDefault().getLabelProvider();
- switch (((IActivity)element).getStatus()) {
- case IActivity.STATUS_OK:
+ UpdateLabelProvider provider =
+ UpdateUI.getDefault().getLabelProvider();
+ switch (((IActivity) element).getStatus()) {
+ case IActivity.STATUS_OK :
return provider.get(UpdateUIImages.DESC_OK_ST_OBJ, 0);
- case IActivity.STATUS_NOK:
+ case IActivity.STATUS_NOK :
return provider.get(UpdateUIImages.DESC_ERR_ST_OBJ, 0);
- }
+ }
}
return null;
}
public String getColumnText(Object element, int columnIndex) {
IActivity activity = (IActivity) element;
- switch(columnIndex) {
- case 1:
+ switch (columnIndex) {
+ case 1 :
return Utilities.format(activity.getDate());
- case 2:
+ case 2 :
return activity.getLabel();
- case 3:
+ case 3 :
return getActionLabel(activity);
}
return "";
}
-
+
private String getActionLabel(IActivity activity) {
int action = activity.getAction();
switch (action) {
- case IActivity.ACTION_CONFIGURE:
+ case IActivity.ACTION_CONFIGURE :
return UpdateUI.getString(KEY_CONFIGURE);
- case IActivity.ACTION_FEATURE_INSTALL:
+ case IActivity.ACTION_FEATURE_INSTALL :
return UpdateUI.getString(KEY_FEATURE_INSTALL);
- case IActivity.ACTION_FEATURE_REMOVE:
+ case IActivity.ACTION_FEATURE_REMOVE :
return UpdateUI.getString(KEY_FEATURE_REMOVE);
- case IActivity.ACTION_SITE_INSTALL:
+ case IActivity.ACTION_SITE_INSTALL :
return UpdateUI.getString(KEY_SITE_INSTALL);
- case IActivity.ACTION_SITE_REMOVE:
+ case IActivity.ACTION_SITE_REMOVE :
return UpdateUI.getString(KEY_SITE_REMOVE);
- case IActivity.ACTION_UNCONFIGURE:
+ case IActivity.ACTION_UNCONFIGURE :
return UpdateUI.getString(KEY_UNCONFIGURE);
- case IActivity.ACTION_REVERT:
+ case IActivity.ACTION_REVERT :
return UpdateUI.getString(KEY_REVERT);
- case IActivity.ACTION_RECONCILIATION:
- return UpdateUI.getString(KEY_RECONCILIATION);
- case IActivity.ACTION_ADD_PRESERVED:
- return UpdateUI.getString(KEY_ADD_PRESERVED);
- default:
- return UpdateUI.getString(KEY_UNKNOWN);
+ case IActivity.ACTION_RECONCILIATION :
+ return UpdateUI.getString(KEY_RECONCILIATION);
+ case IActivity.ACTION_ADD_PRESERVED :
+ return UpdateUI.getString(KEY_ADD_PRESERVED);
+ default :
+ return UpdateUI.getString(KEY_UNKNOWN);
}
}
}
-
public RevertConfigurationWizardPage() {
super("RevertConfiguration");
setTitle("Revert to a Previous Configuration");
@@ -140,37 +154,39 @@
public void createControl(Composite parent) {
SashForm composite = new SashForm(parent, SWT.VERTICAL);
composite.setLayout(new GridLayout());
-
+
createConfigurationsSection(composite);
createActivitiesSection(composite);
setControl(composite);
-
+
Object element = configViewer.getElementAt(0);
if (element != null)
configViewer.setSelection(new StructuredSelection(element));
Dialog.applyDialogFont(composite);
}
-
+
private void createConfigurationsSection(Composite parent) {
Composite tableContainer = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = layout.marginWidth = 0;
tableContainer.setLayout(layout);
-
+
Label label = new Label(tableContainer, SWT.NONE);
label.setText("&Past configurations:");
-
- Table table = new Table(tableContainer, SWT.BORDER|SWT.V_SCROLL);
+
+ Table table = new Table(tableContainer, SWT.BORDER | SWT.V_SCROLL);
table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
+
configViewer = new TableViewer(table);
configViewer.setLabelProvider(new LabelProvider() {
public Image getImage(Object element) {
- UpdateLabelProvider provider = UpdateUI.getDefault().getLabelProvider();
+ UpdateLabelProvider provider =
+ UpdateUI.getDefault().getLabelProvider();
return provider.get(UpdateUIImages.DESC_CONFIG_OBJ, 0);
}
public String getText(Object element) {
- return Utilities.format(((IInstallConfiguration)element).getCreationDate());
+ return Utilities.format(
+ ((IInstallConfiguration) element).getCreationDate());
}
});
@@ -178,7 +194,8 @@
public Object[] getElements(Object element) {
ArrayList result = new ArrayList();
ILocalSite localSite = (ILocalSite) element;
- IInstallConfiguration current = localSite.getCurrentConfiguration();
+ IInstallConfiguration current =
+ localSite.getCurrentConfiguration();
long currTimeline = current.getTimeline();
IInstallConfiguration[] configurations =
localSite.getConfigurationHistory();
@@ -194,26 +211,36 @@
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(
+ Viewer viewer,
+ Object oldInput,
+ Object newInput) {
}
});
- configViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ configViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
- IStructuredSelection ssel = (IStructuredSelection)e.getSelection();
- activitiesViewer.setInput(((IInstallConfiguration)ssel.getFirstElement()));
+ IStructuredSelection ssel =
+ (IStructuredSelection) e.getSelection();
+ activitiesViewer.setInput(
+ ((IInstallConfiguration) ssel.getFirstElement()));
}
});
-
+
configViewer.setSorter(new ViewerSorter() {
public int compare(Viewer viewer, Object e1, Object e2) {
- IInstallConfiguration config1 = (IInstallConfiguration)e1;
- IInstallConfiguration config2 = (IInstallConfiguration)e2;
- if (config1.getCreationDate().before(config2.getCreationDate())) {
+ IInstallConfiguration config1 = (IInstallConfiguration) e1;
+ IInstallConfiguration config2 = (IInstallConfiguration) e2;
+ if (config1
+ .getCreationDate()
+ .before(config2.getCreationDate())) {
return 1;
}
- if (config1.getCreationDate().after(config2.getCreationDate())) {
+ if (config1
+ .getCreationDate()
+ .after(config2.getCreationDate())) {
return -1;
}
return 0;
@@ -225,53 +252,53 @@
} catch (CoreException e1) {
}
}
-
+
private void createActivitiesSection(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = gridLayout.marginWidth = 0;
composite.setLayout(gridLayout);
-
+
GridData gd = new GridData(GridData.FILL_BOTH);
composite.setLayoutData(gd);
-
- Label line = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL );
+
+ Label line = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.widthHint = 1;
line.setLayoutData(gd);
-
+
Label label = new Label(composite, SWT.NONE);
- label.setText("&Activities that caused the creation of this configuration:");
-
+ label.setText(
+ "&Activities that caused the creation of this configuration:");
+
Table table = new Table(composite, SWT.BORDER);
table.setLayoutData(new GridData(GridData.FILL_VERTICAL));
table.setHeaderVisible(true);
-
+
TableColumn column = new TableColumn(table, SWT.NONE);
-
+
column = new TableColumn(table, SWT.NONE);
column.setText("Date");
-
+
column = new TableColumn(table, SWT.NONE);
column.setText("Target");
-
+
column = new TableColumn(table, SWT.NONE);
column.setText("Action");
-
-
+
TableLayout layout = new TableLayout();
- layout.addColumnData(new ColumnWeightData(20,20,false));
- layout.addColumnData(new ColumnWeightData(20,160,false));
- layout.addColumnData(new ColumnWeightData(20,183,false));
- layout.addColumnData(new ColumnWeightData(20,100,false));
+ layout.addColumnData(new ColumnWeightData(20, 20, false));
+ layout.addColumnData(new ColumnWeightData(20, 160, false));
+ layout.addColumnData(new ColumnWeightData(20, 183, false));
+ layout.addColumnData(new ColumnWeightData(20, 100, false));
table.setLayout(layout);
-
+
activitiesViewer = new TableViewer(table);
activitiesViewer.setLabelProvider(new ActivitiesLabelProvider());
activitiesViewer.setContentProvider(new ActivitiesContentProvider());
}
-
+
public boolean performFinish() {
Shell shell = getContainer().getShell();
boolean result =
@@ -281,51 +308,63 @@
"This operation requires restarting the workbench. Would you like to proceed?");
if (!result)
return false;
-
+
boolean finish = performRevert();
if (finish) {
- PlatformUI.getWorkbench().restart();
+ PlatformUI.getWorkbench().restart();
}
return finish;
}
-
+
public boolean performRevert() {
- IStructuredSelection ssel = (IStructuredSelection) configViewer.getSelection();
+ IStructuredSelection ssel =
+ (IStructuredSelection) configViewer.getSelection();
final IInstallConfiguration target =
(IInstallConfiguration) ssel.getFirstElement();
- IStatus status = UpdateManager.getValidator().validatePendingRevert(target);
+ IStatus status =
+ UpdateManager.getValidator().validatePendingRevert(target);
if (status != null) {
- ErrorDialog.openError(UpdateUI.getActiveWorkbenchShell(), null, null, status);
+ ErrorDialog.openError(
+ UpdateUI.getActiveWorkbenchShell(),
+ null,
+ null,
+ status);
return false;
}
- final boolean[] result = new boolean[] {false};
IRunnableWithProgress operation = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- boolean success = false;
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException {
+ RevertConfigurationOperation revertOperation =
+ new RevertConfigurationOperation(
+ target,
+ new UIProblemHandler(),
+ null);
try {
- ILocalSite localSite = SiteManager.getLocalSite();
- localSite.revertTo(target, monitor, new UIProblemHandler());
- localSite.save();
- success = true;
+ revertOperation.execute(monitor);
} catch (CoreException e) {
- UpdateUI.logException(e);
+ throw new InvocationTargetException(e);
} finally {
monitor.done();
- result[0] = success;
}
}
};
try {
getContainer().run(false, true, operation);
+ return true;
} catch (InvocationTargetException e) {
- UpdateUI.logException(e);
+ Throwable targetException = e.getTargetException();
+ if (targetException instanceof InstallAbortedException) {
+ return true;
+ } else {
+ UpdateUI.logException(e);
+ }
+ return false;
} catch (InterruptedException e) {
+ return false;
}
- return result[0];
}
-
}
diff --git a/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/UnifiedInstallWizard.java b/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/UnifiedInstallWizard.java
index 7eeaaf9..a6dd93d 100644
--- a/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/UnifiedInstallWizard.java
+++ b/update/org.eclipse.update.ui/srcnew/org/eclipse/update/internal/ui/wizards/UnifiedInstallWizard.java
@@ -113,6 +113,8 @@
installOperation.execute(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
}
}
};