1 11 package org.eclipse.update.standalone; 12 import java.io.*; 13 14 import org.eclipse.core.runtime.*; 15 import org.eclipse.update.configuration.*; 16 import org.eclipse.update.core.*; 17 import org.eclipse.update.internal.core.*; 18 import org.eclipse.update.operations.*; 19 20 21 31 public class RemoveSiteCommand extends ScriptedCommand { 32 private IConfiguredSite csite; 33 private File sitePath; 34 35 38 public RemoveSiteCommand(String toSite) throws Exception { 39 try { 40 if (toSite != null) { 41 sitePath = new File(toSite); 42 if (!sitePath.getName().equals("eclipse")) sitePath = new File(sitePath, "eclipse"); if (!sitePath.exists()) 45 throw new Exception (Messages.Standalone_noSite + toSite); 46 47 IConfiguredSite[] csites = SiteManager.getLocalSite().getCurrentConfiguration().getConfiguredSites(); 48 for (int i=0; i<csites.length; i++) { 49 File f = new File(csites[i].getSite().getURL().getFile()); 50 if (f.equals(sitePath)) { 51 csite = csites[i]; 52 break; 53 } 54 } 55 56 if (csite == null) 57 throw new Exception (Messages.Standalone_noConfiguredSite + toSite); 58 } else { 59 throw new Exception (Messages.Standalone_noSite3); 60 } 61 62 } catch (Exception e) { 63 throw e; 64 } 65 } 66 67 69 public boolean run(IProgressMonitor monitor) { 70 IStatus status = OperationsManager.getValidator().validatePlatformConfigValid(); 72 if (status != null) { 73 UpdateCore.log(status); 74 return false; 75 } 76 try { 77 getConfiguration().removeConfiguredSite(csite); 78 getConfiguration().getConfiguredSites(); 80 SiteManager.getLocalSite().save(); 81 return true; 82 } catch (CoreException e) { 83 UpdateCore.log(e); 84 return false; 85 } 86 } 87 } 88 | Popular Tags |