1 11 package org.eclipse.update.internal.operations; 12 13 import org.eclipse.core.runtime.*; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.update.configuration.*; 16 import org.eclipse.update.core.*; 17 import org.eclipse.update.internal.core.Messages; 18 import org.eclipse.update.operations.*; 19 20 24 public class UninstallOperation extends FeatureOperation implements IUninstallFeatureOperation{ 25 26 public UninstallOperation(IConfiguredSite site, IFeature feature) { 27 super(site, feature); 28 } 29 30 public void setTargetSite(IConfiguredSite targetSite) { 31 this.targetSite = targetSite; 32 } 33 34 public boolean execute(IProgressMonitor pm, IOperationListener listener) throws CoreException { 35 36 if (targetSite == null) 37 targetSite = UpdateUtils.getConfigSite(feature, SiteManager.getLocalSite().getCurrentConfiguration()); 38 39 boolean restartNeeded = false; 41 42 if (targetSite != null) { 43 if (targetSite.isConfigured(feature)) { 45 IStatus status = OperationsManager.getValidator().validatePendingUnconfig(feature); 46 if (status != null && status.getCode() == IStatus.ERROR) 47 throw new CoreException(status); 48 if (unconfigure(feature, targetSite)) 49 restartNeeded = true; 50 else 51 throw Utilities.newCoreException(NLS.bind(Messages.OperationsManager_error_uninstall, (new String [] { feature.getVersionedIdentifier().toString() })), null); 52 } 53 targetSite.remove(feature, pm); 54 } else { 55 String message = 57 NLS.bind(Messages.OperationsManager_error_uninstall, (new String [] { feature.getLabel() })); 58 IStatus status = 59 new Status( 60 IStatus.ERROR, 61 UpdateUtils.getPluginId(), 62 IStatus.OK, 63 message, 64 null); 65 throw new CoreException(status); 66 } 67 68 markProcessed(); 69 if (listener != null) 70 listener.afterExecute(this, null); 71 72 restartNeeded = SiteManager.getLocalSite().save() && restartNeeded; 73 74 OperationsManager.fireObjectChanged(feature, UNINSTALL); 76 77 return restartNeeded; 78 } 79 80 } 81 | Popular Tags |