|
Lines 14-19
Link Here
|
| 14 |
import java.text.SimpleDateFormat; |
14 |
import java.text.SimpleDateFormat; |
| 15 |
import java.util.*; |
15 |
import java.util.*; |
| 16 |
|
16 |
|
|
|
17 |
import org.eclipse.core.internal.resources.mapping.ResourceMapping; |
| 18 |
import org.eclipse.core.internal.resources.mapping.ResourceTraversal; |
| 17 |
import org.eclipse.core.resources.*; |
19 |
import org.eclipse.core.resources.*; |
| 18 |
import org.eclipse.core.runtime.*; |
20 |
import org.eclipse.core.runtime.*; |
| 19 |
import org.eclipse.jface.preference.IPreferenceStore; |
21 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
Lines 70-76
Link Here
|
| 70 |
|
72 |
|
| 71 |
/** |
73 |
/** |
| 72 |
* This method will ensure that the fonts and colors used by the decorator |
74 |
* This method will ensure that the fonts and colors used by the decorator |
| 73 |
* are cached in the registries. This avoids having to syncExec when |
75 |
* are cached in the registry. This avoids having to syncExec when |
| 74 |
* decorating since we ensure that the fonts and colors are pre-created. |
76 |
* decorating since we ensure that the fonts and colors are pre-created. |
| 75 |
* |
77 |
* |
| 76 |
* @param fonts fonts ids to cache |
78 |
* @param fonts fonts ids to cache |
|
Lines 137-149
Link Here
|
| 137 |
* @param object the object to find the resource for |
139 |
* @param object the object to find the resource for |
| 138 |
* @return the resource for the given object, or null |
140 |
* @return the resource for the given object, or null |
| 139 |
*/ |
141 |
*/ |
| 140 |
private IResource getResource(Object object) { |
142 |
private ResourceMapping getResourceMapping(Object object) { |
| 141 |
if (object instanceof IResource) { |
143 |
if (object instanceof ResourceMapping) { |
| 142 |
return (IResource) object; |
144 |
return (ResourceMapping) object; |
| 143 |
} |
145 |
} |
| 144 |
if (object instanceof IAdaptable) { |
146 |
if (object instanceof IAdaptable) { |
| 145 |
return (IResource) ((IAdaptable) object).getAdapter( |
147 |
Object adapter = ((IAdaptable) object).getAdapter( |
| 146 |
IResource.class); |
148 |
ResourceMapping.class); |
|
|
149 |
if (adapter instanceof ResourceMapping) |
| 150 |
return (ResourceMapping) adapter; |
| 147 |
} |
151 |
} |
| 148 |
return null; |
152 |
return null; |
| 149 |
} |
153 |
} |
|
Lines 154-176
Link Here
|
| 154 |
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) |
158 |
* @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) |
| 155 |
*/ |
159 |
*/ |
| 156 |
public void decorate(Object element, IDecoration decoration) { |
160 |
public void decorate(Object element, IDecoration decoration) { |
| 157 |
IResource resource = getResource(element); |
161 |
ResourceMapping mapping = getResourceMapping(element); |
| 158 |
if (resource == null || resource.getType() == IResource.ROOT) |
162 |
if (mapping == null) |
| 159 |
return; |
163 |
return; |
| 160 |
|
164 |
|
| 161 |
CVSTeamProvider cvsProvider = getCVSProviderFor(resource); |
165 |
if (!isMappedToCVS(mapping)) |
| 162 |
if (cvsProvider == null) |
|
|
| 163 |
return; |
166 |
return; |
| 164 |
|
167 |
|
| 165 |
try { |
168 |
try { |
| 166 |
CVSDecoration cvsDecoration = decorate(resource, true /* include dirty check */); |
169 |
CVSDecoration cvsDecoration = decorate(mapping); |
| 167 |
cvsDecoration.setWatchEditEnabled(cvsProvider.isWatchEditEnabled()); |
170 |
// cvsDecoration.setWatchEditEnabled(cvsProvider.isWatchEditEnabled()); TODO: |
| 168 |
cvsDecoration.apply(decoration); |
171 |
if (cvsDecoration != null) |
| 169 |
} catch(CVSException e) { |
172 |
cvsDecoration.apply(decoration); |
|
|
173 |
} catch(CoreException e) { |
| 170 |
handleException(e); |
174 |
handleException(e); |
| 171 |
} catch (IllegalStateException e) { |
175 |
} catch (IllegalStateException e) { |
| 172 |
// This is thrown by Core if the workspace is in an illegal state |
176 |
// This is thrown by Core if the workspace is in an illegal state |
| 173 |
// If we are not active, ignore it. Otherwise, propogate it. |
177 |
// If we are not active, ignore it. Otherwise, propagate it. |
| 174 |
// (see bug 78303) |
178 |
// (see bug 78303) |
| 175 |
if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { |
179 |
if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { |
| 176 |
throw e; |
180 |
throw e; |
|
Lines 178-184
Link Here
|
| 178 |
} |
182 |
} |
| 179 |
} |
183 |
} |
| 180 |
|
184 |
|
| 181 |
public static CVSDecoration decorate(IResource resource, boolean includeDirtyCheck) throws CVSException { |
185 |
private boolean isMappedToCVS(ResourceMapping mapping) { |
|
|
186 |
IProject[] projects = mapping.getProjects(); |
| 187 |
boolean mappedProjectFound = false; |
| 188 |
for (int i = 0; i < projects.length; i++) { |
| 189 |
IProject project = projects[i]; |
| 190 |
if (getCVSProviderFor(project) == null) { |
| 191 |
// We do not handle the case where the mapping is mapped to CVS and another provider |
| 192 |
if (RepositoryProvider.isShared(project)) |
| 193 |
return false; |
| 194 |
} else { |
| 195 |
mappedProjectFound = true; |
| 196 |
} |
| 197 |
} |
| 198 |
return mappedProjectFound; |
| 199 |
} |
| 200 |
|
| 201 |
private boolean isMappedToCVS(IResource resource) { |
| 202 |
return getCVSProviderFor(resource.getProject()) != null; |
| 203 |
} |
| 204 |
|
| 205 |
private CVSDecoration decorate(ResourceMapping mapping) throws CoreException { |
| 206 |
CVSDecoration result = null; |
| 207 |
ResourceTraversal[] traversals = mapping.getTraversals(null, null); |
| 208 |
for (int i = 0; i < traversals.length; i++) { |
| 209 |
ResourceTraversal traversal = traversals[i]; |
| 210 |
IResource[] resources = traversal.getResources(); |
| 211 |
for (int j = 0; j < resources.length; j++) { |
| 212 |
IResource resource = resources[j]; |
| 213 |
if (resource != null && isMappedToCVS(resource)) { |
| 214 |
CVSDecoration resourceDecoration = decorate(resource, traversal.getDepth(), true /* include dirty check */); |
| 215 |
if (result == null) { |
| 216 |
result = resourceDecoration; |
| 217 |
} else { |
| 218 |
result.combine(resourceDecoration); |
| 219 |
} |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
return result; |
| 224 |
} |
| 225 |
|
| 226 |
public static CVSDecoration decorate(IResource resource) throws CVSException { |
| 227 |
try { |
| 228 |
return decorate(resource, IResource.DEPTH_INFINITE, true); |
| 229 |
} catch (CoreException e) { |
| 230 |
throw CVSException.wrapException(e); |
| 231 |
} |
| 232 |
} |
| 233 |
|
| 234 |
public static CVSDecoration decorate(IResource resource, int depth, boolean includeDirtyCheck) throws CoreException { |
| 182 |
IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); |
235 |
IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); |
| 183 |
ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); |
236 |
ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); |
| 184 |
CVSDecoration cvsDecoration = new CVSDecoration(resource.getName()); |
237 |
CVSDecoration cvsDecoration = new CVSDecoration(resource.getName()); |
|
Lines 193-199
Link Here
|
| 193 |
boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); |
246 |
boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY); |
| 194 |
int type = resource.getType(); |
247 |
int type = resource.getType(); |
| 195 |
if (type == IResource.FILE || computeDeepDirtyCheck) { |
248 |
if (type == IResource.FILE || computeDeepDirtyCheck) { |
| 196 |
cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource)); |
249 |
cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource, depth)); |
| 197 |
} |
250 |
} |
| 198 |
} |
251 |
} |
| 199 |
// Tag |
252 |
// Tag |
|
Lines 232-238
Link Here
|
| 232 |
return cvsDecoration; |
285 |
return cvsDecoration; |
| 233 |
} |
286 |
} |
| 234 |
|
287 |
|
| 235 |
private static void extractContainerProperties(IContainer resource, CVSDecoration cvsDecoration) throws CVSException { |
288 |
private static boolean isDirty(IResource resource, int depth) throws CoreException { |
|
|
289 |
if (depth == IResource.DEPTH_INFINITE || resource.getType() == IResource.FILE) { |
| 290 |
return CVSLightweightDecorator.isDirty(resource); |
| 291 |
} |
| 292 |
if (depth == IResource.DEPTH_ONE && resource.getType() != IResource.FILE) { |
| 293 |
IContainer container = (IContainer)resource; |
| 294 |
IResource[] members = container.members(); |
| 295 |
for (int i = 0; i < members.length; i++) { |
| 296 |
IResource member = members[i]; |
| 297 |
if (member.getType() == IResource.FILE && CVSLightweightDecorator.isDirty(member)) { |
| 298 |
return true; |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
return false; |
| 303 |
} |
| 304 |
|
| 305 |
private static void extractContainerProperties(IContainer resource, CVSDecoration cvsDecoration) throws CVSException { |
| 236 |
ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource); |
306 |
ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource); |
| 237 |
FolderSyncInfo folderInfo = folder.getFolderSyncInfo(); |
307 |
FolderSyncInfo folderInfo = folder.getFolderSyncInfo(); |
| 238 |
if (folderInfo != null) { |
308 |
if (folderInfo != null) { |