1 11 package org.eclipse.core.internal.resources; 12 13 import org.eclipse.core.internal.utils.Messages; 14 import org.eclipse.core.internal.utils.Policy; 15 import org.eclipse.core.resources.ISaveContext; 16 import org.eclipse.core.resources.ResourcesPlugin; 17 import org.eclipse.core.runtime.*; 18 import org.eclipse.core.runtime.jobs.Job; 19 20 23 public class DelayedSnapshotJob extends Job { 24 25 private static final String MSG_SNAPSHOT = Messages.resources_snapshot; 26 private SaveManager saveManager; 27 28 public DelayedSnapshotJob(SaveManager manager) { 29 super(MSG_SNAPSHOT); 30 this.saveManager = manager; 31 setRule(ResourcesPlugin.getWorkspace().getRoot()); 32 setSystem(true); 33 } 34 35 38 public IStatus run(IProgressMonitor monitor) { 39 if (monitor.isCanceled()) 40 return Status.CANCEL_STATUS; 41 if (ResourcesPlugin.getWorkspace() == null) 42 return Status.OK_STATUS; 43 try { 44 return saveManager.save(ISaveContext.SNAPSHOT, null, Policy.monitorFor(null)); 45 } catch (CoreException e) { 46 return e.getStatus(); 47 } finally { 48 saveManager.operationCount = 0; 49 saveManager.snapshotRequested = false; 50 } 51 } 52 } 53 | Popular Tags |