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 17 22 23 public class PatchCleaner { 24 private IConfiguredSite csite; 25 private SiteListener listener; 26 class SiteListener implements IConfiguredSiteChangedListener { 27 public void featureInstalled(IFeature feature) { 28 } 29 public void featureRemoved(IFeature feature) { 30 cleanSavedConfigs(feature); 31 } 32 public void featureConfigured(IFeature feature) { 33 } 34 public void featureUnconfigured(IFeature feature) { 35 cleanSavedConfigs(feature); 36 } 37 } 38 public PatchCleaner(IConfiguredSite csite, IFeature root) { 39 this.csite = csite; 40 listener = new SiteListener(); 41 csite.addConfiguredSiteChangedListener(listener); 42 } 43 44 public void dispose() { 45 csite.removeConfiguredSiteChangedListener(listener); 46 } 47 private void cleanSavedConfigs(IFeature feature) { 48 if (feature.isPatch()) { 49 IInstallConfiguration backupConfig = UpdateUtils.getBackupConfigurationFor(feature); 50 if (backupConfig!=null) { 51 remove(backupConfig); 53 } 54 } 55 } 56 private void remove(IInstallConfiguration config) { 57 try { 58 ILocalSite localSite = SiteManager.getLocalSite(); 59 localSite.removeFromPreservedConfigurations(config); 60 } 61 catch (CoreException e) { 62 } 63 } 64 } 65 | Popular Tags |