1 11 package org.eclipse.team.core.mapping.provider; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.resources.mapping.ResourceMapping; 15 import org.eclipse.core.resources.mapping.ResourceTraversal; 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.team.core.ICache; 18 import org.eclipse.team.core.mapping.*; 19 import org.eclipse.team.internal.core.Cache; 20 import org.eclipse.team.internal.core.Policy; 21 22 29 public abstract class SynchronizationContext extends PlatformObject implements ISynchronizationContext { 30 31 private final int type; 32 private final IResourceDiffTree diffTree; 33 private Cache cache; 34 private final ISynchronizationScopeManager manager; 35 36 42 protected SynchronizationContext(ISynchronizationScopeManager manager, int type, IResourceDiffTree diffTree) { 43 this.manager = manager; 44 this.type = type; 45 this.diffTree = diffTree; 46 } 47 48 51 public ISynchronizationScope getScope() { 52 return getScopeManager().getScope(); 53 } 54 55 59 public ISynchronizationScopeManager getScopeManager() { 60 return manager; 61 } 62 63 66 public int getType() { 67 return type; 68 } 69 70 73 public void dispose() { 74 if (cache != null) { 75 cache.dispose(); 76 } 77 manager.dispose(); 78 } 79 80 83 public synchronized ICache getCache() { 84 if (cache == null) { 85 cache = new Cache(); 86 } 87 return cache; 88 } 89 90 93 public IResourceDiffTree getDiffTree() { 94 return diffTree; 95 } 96 97 100 public void refresh(ResourceMapping[] mappings, IProgressMonitor monitor) throws CoreException { 101 monitor.beginTask(null, 100); 102 ISynchronizationScopeManager manager = getScopeManager(); 103 if (manager == null) { 104 refresh(getScope().getTraversals(), IResource.NONE, Policy.subMonitorFor(monitor, 50)); 106 } else { 107 ResourceTraversal[] traversals = manager.refresh(mappings, Policy.subMonitorFor(monitor, 50)); 108 if (traversals.length > 0) 109 refresh(traversals, IResource.NONE, Policy.subMonitorFor(monitor, 50)); 110 } 111 monitor.done(); 112 } 113 114 } 115 | Popular Tags |