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 public class ToggleSiteOperation 19 extends Operation 20 implements IToggleSiteOperation { 21 22 private IConfiguredSite site; 23 24 public ToggleSiteOperation(IConfiguredSite site) { 25 super(); 26 this.site = site; 27 } 28 29 32 public boolean execute( 33 IProgressMonitor monitor, 34 IOperationListener listener) 35 throws CoreException { 36 if (site == null) 37 return false; 38 boolean oldValue = site.isEnabled(); 39 site.setEnabled(!oldValue); 40 IStatus status = OperationsManager.getValidator().validateCurrentState(); 41 if (status != null) { 42 site.setEnabled(oldValue); 44 throw new CoreException(status); 45 } else { 46 try { 47 boolean restartNeeded = SiteManager.getLocalSite().save(); 48 OperationsManager.fireObjectChanged(site, ""); return restartNeeded; } catch (CoreException e) { 51 site.setEnabled(oldValue); 53 UpdateUtils.logException(e); 54 throw e; 55 } 56 } 57 } 58 } 59 | Popular Tags |