Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 3979
Collapse All | Expand All

(-)plugin.xml (-1 / +3 lines)
Lines 733-739 Link Here
733
         point="org.eclipse.ui.decorators">
733
         point="org.eclipse.ui.decorators">
734
      <decorator
734
      <decorator
735
            lightweight="true"
735
            lightweight="true"
736
            objectClass="org.eclipse.core.resources.IResource"
737
            adaptable="true"
736
            adaptable="true"
738
            location="BOTTOM_RIGHT"
737
            location="BOTTOM_RIGHT"
739
            label="%DecoratorStandard.name"
738
            label="%DecoratorStandard.name"
Lines 743-748 Link Here
743
         <description>
742
         <description>
744
            %DecoratorStandard.desc
743
            %DecoratorStandard.desc
745
         </description>
744
         </description>
745
         <enablement>
746
             <objectClass name="org.eclipse.core.internal.resources.mapping.ResourceMapping"/> 
747
         </enablement>
746
      </decorator>
748
      </decorator>
747
   </extension>
749
   </extension>
748
<!-- *************** View Actions **************** -->
750
<!-- *************** View Actions **************** -->
(-)src/org/eclipse/team/internal/ccvs/ui/CVSDecoration.java (-17 / +77 lines)
Lines 77-84 Link Here
77
	private String fileFormatter;
77
	private String fileFormatter;
78
	private String folderFormatter;
78
	private String folderFormatter;
79
	private String projectFormatter;
79
	private String projectFormatter;
80
	private String dirtyTextIndicator;
81
	private String addedTextIndicator;
82
	private String resourceName;
80
	private String resourceName;
83
	
81
	
84
	//	Images cached for better performance
82
	//	Images cached for better performance
Lines 252-273 Link Here
252
		}	
250
		}	
253
		bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, getResourceName());
251
		bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, getResourceName());
254
		bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, getKeywordSubstitution());
252
		bindings.put(CVSDecoratorConfiguration.FILE_KEYWORD, getKeywordSubstitution());
255
		if (resourceType != IResource.FILE && location != null) {
253
		if (resourceType != IResource.FILE) {
256
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_HOST, location.getHost());
254
            if (location != null) {
257
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_METHOD, location.getMethod().getName());
255
    			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_HOST, location.getHost());
258
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, location.getUsername());
256
    			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_METHOD, location.getMethod().getName());
259
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory());
257
    			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_USER, location.getUsername());
260
			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository);
258
    			bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_ROOT, location.getRootDirectory());
261
259
    
262
            RepositoryManager repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager();
260
                RepositoryManager repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager();
263
            RepositoryRoot root = repositoryManager.getRepositoryRootFor(location);
261
                RepositoryRoot root = repositoryManager.getRepositoryRootFor(location);
264
            CVSUIPlugin.getPlugin().getRepositoryManager();
262
                CVSUIPlugin.getPlugin().getRepositoryManager();
265
            String label = root.getName();
263
                String label = root.getName();
266
            if (label == null) {
264
                if (label == null) {
267
              label = location.getLocation(true);
265
                  label = location.getLocation(true);
266
                }
267
                bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, label);
268
            }
268
            }
269
            bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_LABEL, label);
269
            if (repository != null) {
270
		}
270
                bindings.put(CVSDecoratorConfiguration.REMOTELOCATION_REPOSITORY, repository);
271
            }
272
        }
273
271
		CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings);
274
		CVSDecoratorConfiguration.decorate(this, getTextFormatter(), bindings);
272
	}
275
	}
273
276
Lines 430-433 Link Here
430
	public void setVirtualFolder(boolean virtualFolder) {
433
	public void setVirtualFolder(boolean virtualFolder) {
431
		this.virtualFolder = virtualFolder;
434
		this.virtualFolder = virtualFolder;
432
	}
435
	}
436
    
437
    public ICVSRepositoryLocation getLocation() {
438
        return location;
439
    }
440
    
441
    public void combine(CVSDecoration resourceDecoration) {
442
        // dirty if any are dirty
443
        if (resourceDecoration.isDirty())
444
            setDirty(true);
445
        // ignored only if all are ignored
446
        if (isIgnored() && !resourceDecoration.isIgnored())
447
            setIgnored(false);
448
        // added only if all are added
449
        if (isAdded() && !resourceDecoration.isAdded())
450
            setAdded(false);
451
        // remote if any have a remote
452
        if (resourceDecoration.isHasRemote())
453
            setHasRemote(true);
454
        // Only new if all are new
455
        if (isNewResource() && !resourceDecoration.isNewResource())
456
            setNewResource(false);
457
        // Only watch-edit enabled if all are
458
        if (isWatchEditEnabled() && !resourceDecoration.isWatchEditEnabled())
459
            setWatchEditEnabled(false);
460
        // Only read-only if all are
461
        if (isReadOnly() && !resourceDecoration.isReadOnly())
462
            setReadOnly(false);
463
        // Only virtual if all are
464
        if (isVirtualFolder() && !resourceDecoration.isVirtualFolder())
465
            setVirtualFolder(false);
466
        // TODO what about needsMerge
467
        // Can only have a revision for a direct mapping to a single file
468
        if (getRevision() != null) {
469
            revision = null;
470
        }
471
        // Can only have a keyword substitution mode for a direct mapping to a single file
472
        if (getKeywordSubstitution() != null) {
473
            keywordSubstitution = null;
474
        }
475
        // Will only show the tag if it is the same for all
476
        if (getTag() != null) {
477
            if (resourceDecoration.getTag() == null || !getTag().equals(resourceDecoration.getTag())) {
478
                setTag(null);
479
            }
480
        }
481
        // Can only have a repository path for a single folder
482
        if (repository != null)
483
            repository = null;
484
        if (getLocation() != null) {
485
            if (resourceDecoration.getLocation() == null || !getLocation().equals(resourceDecoration.getLocation())) {
486
                setLocation(null);
487
            }
488
        }
489
        // Assume the folder type for multiple resource mappings
490
        resourceType = IResource.FOLDER;
491
        
492
    }
433
}
493
}
(-)src/org/eclipse/team/internal/ccvs/ui/CVSLightweightDecorator.java (-18 / +88 lines)
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) {
(-)src/org/eclipse/team/internal/ccvs/ui/subscriber/CVSParticipantLabelDecorator.java (-1 / +6 lines)
Lines 11-16 Link Here
11
package org.eclipse.team.internal.ccvs.ui.subscriber;
11
package org.eclipse.team.internal.ccvs.ui.subscriber;
12
12
13
import org.eclipse.core.resources.IResource;
13
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jface.util.IPropertyChangeListener;
15
import org.eclipse.jface.util.IPropertyChangeListener;
15
import org.eclipse.jface.util.PropertyChangeEvent;
16
import org.eclipse.jface.util.PropertyChangeEvent;
16
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.viewers.*;
Lines 67-73 Link Here
67
     * @return
68
     * @return
68
     */
69
     */
69
    protected CVSDecoration getDecoration(IResource resource) throws CVSException {
70
    protected CVSDecoration getDecoration(IResource resource) throws CVSException {
70
        return CVSLightweightDecorator.decorate(resource, false /* do not include dirty check */);
71
        try {
72
            return CVSLightweightDecorator.decorate(resource, IResource.DEPTH_ZERO, false /* do not include dirty check */);
73
        } catch (CoreException e) {
74
            throw CVSException.wrapException(e);
75
        }
71
    }
76
    }
72
77
73
    public Image decorateImage(Image base, Object element) {
78
    public Image decorateImage(Image base, Object element) {

Return to bug 3979