1 11 package org.eclipse.update.internal.operations; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.update.configuration.*; 15 import org.eclipse.update.core.*; 16 import org.eclipse.update.operations.*; 17 18 22 public class UnconfigOperation 23 extends FeatureOperation 24 implements IUnconfigFeatureOperation { 25 26 public UnconfigOperation( 27 IConfiguredSite site, 28 IFeature feature) { 29 super(site, feature); 30 } 31 32 public boolean execute(IProgressMonitor pm, IOperationListener listener) 33 throws CoreException { 34 35 IStatus status = 36 OperationsManager.getValidator().validatePendingUnconfig(feature); 37 if (status != null && status.getCode() == IStatus.ERROR) { 38 throw new CoreException(status); 39 } 40 41 PatchCleaner cleaner = new PatchCleaner(targetSite, feature); 42 targetSite.unconfigure(feature); 43 cleaner.dispose(); 44 45 try { 46 boolean restartNeeded = false; 48 49 IOperation pendingOperation = 51 OperationsManager.findPendingOperation(feature); 52 53 if (pendingOperation instanceof IConfigFeatureOperation) { 54 OperationsManager.removePendingOperation(pendingOperation); 56 } else { 57 OperationsManager.addPendingOperation(this); 58 restartNeeded = true; 59 } 60 61 markProcessed(); 62 if (listener != null) 63 listener.afterExecute(this, null); 64 65 restartNeeded = SiteManager.getLocalSite().save() && restartNeeded; 66 67 OperationsManager.fireObjectChanged(feature, null); 69 70 return restartNeeded; 71 } catch (CoreException e) { 72 undo(); 73 UpdateUtils.logException(e); 74 throw e; 75 } 76 } 77 78 public void undo() throws CoreException { 79 targetSite.configure(feature); 80 } 81 82 } 83 | Popular Tags |