KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > operations > RevertConfigurationOperation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.operations;
12
13 import java.lang.reflect.*;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.update.configuration.*;
17 import org.eclipse.update.core.*;
18 import org.eclipse.update.operations.*;
19
20 public class RevertConfigurationOperation extends Operation implements IRevertConfigurationOperation {
21
22     private IInstallConfiguration config;
23     private IProblemHandler problemHandler;
24
25     public RevertConfigurationOperation(
26         IInstallConfiguration config,
27         IProblemHandler problemHandler) {
28         super();
29         this.config = config;
30         this.problemHandler = problemHandler;
31     }
32
33     /* (non-Javadoc)
34      * @see org.eclipse.update.operations.IOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
35      */

36     public boolean execute(IProgressMonitor monitor, IOperationListener listener)
37         throws CoreException, InvocationTargetException {
38         IStatus status =
39             OperationsManager.getValidator().validatePendingRevert(config);
40         if (status != null && status.getCode() == IStatus.ERROR) {
41             throw new CoreException(status);
42         }
43
44         try {
45             ILocalSite localSite = SiteManager.getLocalSite();
46             localSite.revertTo(config, monitor, problemHandler);
47             localSite.save();
48             return true;
49         } catch (CoreException e) {
50             UpdateUtils.logException(e);
51             throw e;
52         }
53     }
54 }
55
Popular Tags