KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > CVSLightweightDecorator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui;
12
13
14 import com.ibm.icu.text.SimpleDateFormat;
15 import java.util.ArrayList JavaDoc;
16 import java.util.Date JavaDoc;
17 import java.util.HashSet JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Locale JavaDoc;
20 import java.util.Set JavaDoc;
21
22 import org.eclipse.core.resources.*;
23 import org.eclipse.core.resources.mapping.*;
24 import org.eclipse.core.runtime.*;
25 import org.eclipse.jface.preference.IPreferenceStore;
26 import org.eclipse.jface.util.IPropertyChangeListener;
27 import org.eclipse.jface.util.PropertyChangeEvent;
28 import org.eclipse.jface.viewers.*;
29 import org.eclipse.swt.widgets.Display;
30 import org.eclipse.team.core.RepositoryProvider;
31 import org.eclipse.team.core.diff.IDiff;
32 import org.eclipse.team.core.diff.IThreeWayDiff;
33 import org.eclipse.team.internal.ccvs.core.*;
34 import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
35 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
36 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
37 import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
38 import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
39 import org.eclipse.team.internal.ccvs.core.util.ResourceStateChangeListeners;
40 import org.eclipse.team.internal.core.ExceptionCollector;
41 import org.eclipse.team.internal.ui.Utils;
42 import org.eclipse.team.ui.TeamUI;
43 import org.eclipse.team.ui.mapping.SynchronizationStateTester;
44 import org.eclipse.ui.PlatformUI;
45 import org.eclipse.ui.themes.ITheme;
46 import org.osgi.framework.Bundle;
47
48 public class CVSLightweightDecorator extends LabelProvider implements ILightweightLabelDecorator, IResourceStateChangeListener, IPropertyChangeListener {
49
50     // Decorator id as defined in the decorator extension point
51
public final static String JavaDoc ID = "org.eclipse.team.cvs.ui.decorator"; //$NON-NLS-1$
52

53     private static ExceptionCollector exceptions = new ExceptionCollector(CVSUIMessages.CVSDecorator_exceptionMessage, CVSUIPlugin.ID, IStatus.ERROR, CVSUIPlugin.getPlugin().getLog()); //;
54

55     private static String JavaDoc DECORATOR_FORMAT = "yyyy/MM/dd HH:mm:ss"; //$NON-NLS-1$
56
private static SimpleDateFormat decorateFormatter = new SimpleDateFormat(DECORATOR_FORMAT, Locale.getDefault());
57     
58     private static String JavaDoc[] fonts = new String JavaDoc[] {
59             CVSDecoratorConfiguration.IGNORED_FONT,
60             CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT};
61     
62     private static String JavaDoc[] colors = new String JavaDoc[] {
63              CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR,
64              CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR,
65              CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR,
66              CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR};
67     
68     private static final SynchronizationStateTester DEFAULT_TESTER = new SynchronizationStateTester();
69
70     public CVSLightweightDecorator() {
71         ResourceStateChangeListeners.getListener().addResourceStateChangeListener(this);
72         TeamUI.addPropertyChangeListener(this);
73         CVSUIPlugin.addPropertyChangeListener(this);
74         
75         // This is an optimization to ensure that while decorating our fonts and colors are
76
// pre-created and decoration can occur without having to syncExec.
77
ensureFontAndColorsCreated(fonts, colors);
78         
79         PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().addPropertyChangeListener(this);
80         CVSProviderPlugin.broadcastDecoratorEnablementChanged(true /* enabled */);
81     }
82     
83     /**
84      * This method will ensure that the fonts and colors used by the decorator
85      * are cached in the registries. This avoids having to syncExec when
86      * decorating since we ensure that the fonts and colors are pre-created.
87      *
88      * @param fonts fonts ids to cache
89      * @param colors color ids to cache
90      */

91     private void ensureFontAndColorsCreated(final String JavaDoc[] fonts, final String JavaDoc[] colors) {
92         CVSUIPlugin.getStandardDisplay().syncExec(new Runnable JavaDoc() {
93             public void run() {
94                 ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
95                 for (int i = 0; i < colors.length; i++) {
96                     theme.getColorRegistry().get(colors[i]);
97                     
98                 }
99                 for (int i = 0; i < fonts.length; i++) {
100                     theme.getFontRegistry().get(fonts[i]);
101                 }
102             }
103         });
104     }
105
106     public static boolean isDirty(final ICVSResource resource) throws CVSException {
107         return getSubscriber().isDirty(resource, null);
108     }
109
110     public static boolean isDirty(IResource resource) {
111         try {
112             return getSubscriber().isDirty(resource, null);
113         } catch (CVSException e) {
114             handleException(resource, e);
115             return true;
116         }
117     }
118     
119     /*
120      * Answers null if a provider does not exist or the provider is not a CVS provider. These resources
121      * will be ignored by the decorator.
122      */

123     private static CVSTeamProvider getCVSProviderFor(IResource resource) {
124         if (resource == null) return null;
125         RepositoryProvider p =
126             RepositoryProvider.getProvider(
127                 resource.getProject(),
128                 CVSProviderPlugin.getTypeId());
129         if (p == null) {
130             return null;
131         }
132         return (CVSTeamProvider) p;
133     }
134     
135     /**
136      * This method should only be called by the decorator thread.
137      *
138      * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
139      */

140     public void decorate(Object JavaDoc element, IDecoration decoration) {
141         
142         // Don't decorate the workspace root
143
IResource resource = getResource(element);
144         if (resource != null && resource.getType() == IResource.ROOT)
145             return;
146         
147         // Get the mapping for the object and ensure it overlaps with CVS projects
148
ResourceMapping mapping = Utils.getResourceMapping(element);
149         if (mapping == null)
150             return;
151         if (!isMappedToCVS(mapping))
152             return;
153         
154         // Get the sync state tester from the context
155
IDecorationContext context = decoration.getDecorationContext();
156         SynchronizationStateTester tester = DEFAULT_TESTER;
157         Object JavaDoc property = context.getProperty(SynchronizationStateTester.PROP_TESTER);
158         if (property instanceof SynchronizationStateTester) {
159             tester = (SynchronizationStateTester) property;
160         }
161         
162         // Calculate and apply the decoration
163
try {
164             if (tester.isDecorationEnabled(element)) {
165                 CVSDecoration cvsDecoration = decorate(element, tester);
166                 cvsDecoration.apply(decoration);
167             }
168         } catch(CoreException e) {
169             handleException(element, e);
170         } catch (IllegalStateException JavaDoc e) {
171             // This is thrown by Core if the workspace is in an illegal state
172
// If we are not active, ignore it. Otherwise, propagate it.
173
// (see bug 78303)
174
if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) {
175                 throw e;
176             }
177         }
178     }
179
180     private static IResource getResource(Object JavaDoc element) {
181         if (element instanceof ResourceMapping) {
182             element = ((ResourceMapping) element).getModelObject();
183         }
184         return Utils.getResource(element);
185     }
186
187     /*
188      * Return whether any of the projects of the mapping are mapped to CVS
189      */

190     private boolean isMappedToCVS(ResourceMapping mapping) {
191         IProject[] projects = mapping.getProjects();
192         boolean foundOne = false;
193         for (int i = 0; i < projects.length; i++) {
194             IProject project = projects[i];
195             if (project != null) {
196                 RepositoryProvider provider = RepositoryProvider.getProvider(project);
197                 if (provider instanceof CVSTeamProvider) {
198                     foundOne = true;
199                 } else if (provider != null) {
200                     return false;
201                 }
202             }
203         }
204         return foundOne;
205     }
206     
207     public static CVSDecoration decorate(Object JavaDoc element, SynchronizationStateTester tester) throws CoreException {
208         IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
209         CVSDecoration result = new CVSDecoration();
210         
211         // First, decorate the synchronization state
212
int state = IDiff.NO_CHANGE;
213         if (isSupervised(element)) {
214             // TODO: Not quite right
215
result.setHasRemote(true);
216             state = tester.getState(element,
217                     store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY)
218                         ? IDiff.ADD | IDiff.REMOVE | IDiff.CHANGE | IThreeWayDiff.OUTGOING
219                         : 0,
220                     new NullProgressMonitor());
221             result.setStateFlags(state);
222         } else {
223             result.setIgnored(true);
224         }
225         // Tag
226
if (!result.isIgnored()) {
227             CVSTag tag = getTagToShow(element);
228             if (tag != null) {
229                 String JavaDoc name = tag.getName();
230                 if (tag.getType() == CVSTag.DATE) {
231                     Date JavaDoc date = tag.asDate();
232                     if (date != null) {
233                         name = decorateFormatter.format(date);
234                     }
235                 }
236                 result.setTag(name);
237             }
238         }
239         
240         // If the element adapts to a single resource, add additional decorations
241
IResource resource = getResource(element);
242         if (resource == null) {
243             result.setResourceType(CVSDecoration.MODEL);
244         } else {
245             decorate(resource, result);
246         }
247         tester.elementDecorated(element, result.asTeamStateDescription(null));
248         return result;
249     }
250     
251     private static boolean isSupervised(Object JavaDoc element) throws CoreException {
252         IResource[] resources = getTraversalRoots(element);
253         for (int i = 0; i < resources.length; i++) {
254             IResource resource = resources[i];
255             if (getSubscriber().isSupervised(resource))
256                 return true;
257         }
258         return false;
259     }
260     
261     private static IResource[] getTraversalRoots(Object JavaDoc element) throws CoreException {
262         Set JavaDoc result = new HashSet JavaDoc();
263         ResourceMapping mapping = Utils.getResourceMapping(element);
264         if (mapping != null) {
265             ResourceTraversal[] traversals = mapping.getTraversals(ResourceMappingContext.LOCAL_CONTEXT, null);
266             for (int i = 0; i < traversals.length; i++) {
267                 ResourceTraversal traversal = traversals[i];
268                 IResource[] resources = traversal.getResources();
269                 for (int j = 0; j < resources.length; j++) {
270                     IResource resource = resources[j];
271                     result.add(resource);
272                 }
273             }
274         }
275         return (IResource[]) result.toArray(new IResource[result.size()]);
276     }
277
278     private static void decorate(IResource resource, CVSDecoration cvsDecoration) throws CVSException {
279         IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
280         ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
281         cvsDecoration.setResourceType(resource.getType());
282         
283         cvsDecoration.setHasRemote(hasRemote(cvsResource));
284         if (cvsResource.isIgnored()) {
285             cvsDecoration.setIgnored(true);
286         }
287         if (!cvsDecoration.isIgnored()) {
288             // Dirty: Only decorate dirty state if we're not set to decorate models
289
boolean decorateModel = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
290             if (!decorateModel) {
291                 // Dirty
292
try {
293                     IDiff node = getSubscriber().getDiff(resource);
294                     if (node != null) {
295                         if (node instanceof IThreeWayDiff) {
296                             IThreeWayDiff twd = (IThreeWayDiff) node;
297                             cvsDecoration.setDirty(twd.getDirection() == IThreeWayDiff.OUTGOING
298                                 || twd.getDirection() == IThreeWayDiff.CONFLICTING);
299                         }
300                     }
301                 } catch (CoreException e) {
302                     handleException(resource, e);
303                 }
304                 // Has a remote
305
//cvsDecoration.setHasRemote(CVSWorkspaceRoot.hasRemote(resource));
306
}
307             // Is a new resource
308
if (store.getBoolean(ICVSUIConstants.PREF_SHOW_NEWRESOURCE_DECORATION)) {
309                 if (cvsResource.exists()) {
310                     if (cvsResource.isFolder()) {
311                         if (!((ICVSFolder) cvsResource).isCVSFolder()) {
312                             cvsDecoration.setNewResource(true);
313                         }
314                     } else if (!cvsResource.isManaged()) {
315                         cvsDecoration.setNewResource(true);
316                     }
317                 }
318             }
319             // Extract type specific properties
320
if (resource.getType() == IResource.FILE) {
321                 extractFileProperties((IFile) resource, cvsDecoration);
322             } else {
323                 extractContainerProperties((IContainer) resource, cvsDecoration);
324             }
325         }
326     }
327
328     private static boolean hasRemote(ICVSResource cvsResource) {
329         try {
330             return (cvsResource.isManaged() || cvsResource.isFolder() && ((ICVSFolder)cvsResource).isCVSFolder());
331         } catch (CVSException e) {
332             return false;
333         }
334     }
335
336     public static CVSDecoration decorate(IResource resource, boolean includeDirtyCheck) throws CVSException {
337         IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
338         ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
339         CVSDecoration cvsDecoration = new CVSDecoration();
340         cvsDecoration.setResourceType(resource.getType());
341         
342         if (cvsResource.isIgnored()) {
343             cvsDecoration.setIgnored(true);
344         }
345         if (!cvsDecoration.isIgnored()) {
346             // Dirty
347
if (includeDirtyCheck) {
348                 boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
349                 int type = resource.getType();
350                 if (type == IResource.FILE || computeDeepDirtyCheck) {
351                     cvsDecoration.setDirty(CVSLightweightDecorator.isDirty(resource));
352                 }
353             }
354         }
355         decorate(resource, cvsDecoration);
356         return cvsDecoration;
357     }
358
359     private static void extractContainerProperties(IContainer resource, CVSDecoration cvsDecoration) throws CVSException {
360         ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(resource);
361         FolderSyncInfo folderInfo = folder.getFolderSyncInfo();
362         if (folderInfo != null) {
363             cvsDecoration.setLocation(KnownRepositories.getInstance().getRepository(folderInfo.getRoot()));
364             cvsDecoration.setRepository(folderInfo.getRepository());
365             cvsDecoration.setVirtualFolder(folderInfo.isVirtualDirectory());
366         }
367     }
368
369     private static void extractFileProperties(IFile resource, CVSDecoration cvsDecoration) throws CVSException {
370         ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(resource);
371         ResourceSyncInfo fileInfo = file.getSyncInfo();
372         KSubstOption option = KSubstOption.fromFile(resource);
373         if (fileInfo != null) {
374             cvsDecoration.setAdded(fileInfo.isAdded());
375             cvsDecoration.setRevision(fileInfo.getRevision());
376             cvsDecoration.setReadOnly(file.isReadOnly());
377             cvsDecoration.setNeedsMerge(fileInfo.isNeedsMerge(file.getTimeStamp()));
378             option = fileInfo.getKeywordMode();
379         }
380         cvsDecoration.setKeywordSubstitution(option.getShortDisplayText());
381         CVSTeamProvider provider = getCVSProviderFor(resource);
382         if (provider != null)
383             cvsDecoration.setWatchEditEnabled(provider.isWatchEditEnabled());
384     }
385
386     protected static CVSTag getTagToShow(Object JavaDoc element) throws CoreException {
387         IResource r = getResource(element);
388         if (r != null)
389             return getTagToShow(r);
390         IResource[] resources = getTraversalRoots(element);
391         boolean first = true;
392         CVSTag tag = null;
393         for (int i = 0; i < resources.length; i++) {
394             IResource resource = resources[i];
395             if (getSubscriber().isSupervised(resource)) {
396                 CVSTag nextTag = getTagToShow(resource);
397                 if (first) {
398                     tag = nextTag;
399                     first = false;
400                 } else if (!equals(tag, nextTag)) {
401                     return null;
402                 }
403                 
404             }
405         }
406         return tag;
407     }
408     
409     private static boolean equals(CVSTag tag, CVSTag nextTag) {
410         if (tag == nextTag)
411             return true;
412         if (tag == null || nextTag == null)
413             return false;
414         return tag.getName().equals(nextTag.getName());
415     }
416
417     /**
418      * Only show the tag if the resources tag is different than the parents. Or else, tag
419      * names will clutter the text decorations.
420      */

421     protected static CVSTag getTagToShow(IResource resource) throws CVSException {
422         ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
423         CVSTag tag = null;
424
425         // for unmanaged resources don't show a tag since they will be added in
426
// the context of their parents tag. For managed resources only show tags
427
// if different than parent.
428
boolean managed = false;
429
430         if(cvsResource.isFolder()) {
431             FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo();
432             if(folderInfo != null) {
433                 tag = folderInfo.getTag();
434                 managed = true;
435             }
436         } else {
437             ResourceSyncInfo info = ((ICVSFile)cvsResource).getSyncInfo();
438             if(info != null) {
439                 tag = info.getTag();
440                 managed = true;
441             }
442         }
443
444         ICVSFolder parent = cvsResource.getParent();
445         if(parent != null && managed) {
446             FolderSyncInfo parentInfo = parent.getFolderSyncInfo();
447             if(parentInfo != null) {
448                 CVSTag parentTag = parentInfo.getTag();
449                 parentTag = (parentTag == null ? CVSTag.DEFAULT : parentTag);
450                 tag = (tag == null ? CVSTag.DEFAULT : tag);
451                 // must compare tags by name because CVS doesn't do a good job of
452
// using T and N prefixes for folders and files.
453
if( parentTag.getName().equals(tag.getName())) {
454                     tag = null;
455                 }
456             }
457         }
458         return tag;
459     }
460
461     /*
462      * Add resource and its parents to the List
463      */

464      
465     private void addWithParents(IResource resource, Set JavaDoc resources) {
466         IResource current = resource;
467
468         while (current.getType() != IResource.ROOT) {
469             resources.add(current);
470             current = current.getParent();
471         }
472     }
473     
474     /*
475     * Perform a blanket refresh of all CVS decorations
476     */

477     public static void refresh() {
478         CVSUIPlugin.getPlugin().getWorkbench().getDecoratorManager().update(CVSUIPlugin.DECORATOR_ID);
479     }
480
481     /*
482      * Update the decorators for every resource in project
483      */

484      
485     public void refresh(IProject project) {
486         final List JavaDoc resources = new ArrayList JavaDoc();
487         try {
488             project.accept(new IResourceVisitor() {
489                 public boolean visit(IResource resource) {
490                     resources.add(resource);
491                     return true;
492                 }
493             });
494             postLabelEvent(new LabelProviderChangedEvent(this, resources.toArray()));
495         } catch (CoreException e) {
496             handleException(project, e);
497         }
498     }
499     
500     /* (non-Javadoc)
501      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceSyncInfoChanged(org.eclipse.core.resources.IResource[])
502      */

503     public void resourceSyncInfoChanged(IResource[] changedResources) {
504         resourceStateChanged(changedResources);
505     }
506     
507     /* (non-Javadoc)
508      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#externalSyncInfoChange(org.eclipse.core.resources.IResource[])
509      */

510     public void externalSyncInfoChange(IResource[] changedResources) {
511         resourceStateChanged(changedResources);
512     }
513     
514     /* (non-Javadoc)
515      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceModificationStateChanged(org.eclipse.core.resources.IResource[])
516      */

517     public void resourceModified(IResource[] changedResources) {
518         resourceStateChanged(changedResources);
519     }
520
521     /**
522      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#resourceStateChanged(org.eclipse.core.resources.IResource[])
523      */

524     public void resourceStateChanged(IResource[] changedResources) {
525         // add depth first so that update thread processes parents first.
526
//System.out.println(">> State Change Event");
527
Set JavaDoc resourcesToUpdate = new HashSet JavaDoc();
528
529         IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
530         boolean showingDeepDirtyIndicators = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
531
532         for (int i = 0; i < changedResources.length; i++) {
533             IResource resource = changedResources[i];
534
535             if(showingDeepDirtyIndicators) {
536                 addWithParents(resource, resourcesToUpdate);
537             } else {
538                 resourcesToUpdate.add(resource);
539             }
540         }
541
542         postLabelEvent(new LabelProviderChangedEvent(this, resourcesToUpdate.toArray()));
543     }
544     
545     /**
546      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectConfigured(org.eclipse.core.resources.IProject)
547      */

548     public void projectConfigured(IProject project) {
549         refresh(project);
550     }
551     /**
552      * @see org.eclipse.team.internal.ccvs.core.IResourceStateChangeListener#projectDeconfigured(org.eclipse.core.resources.IProject)
553      */

554     public void projectDeconfigured(IProject project) {
555         refresh(project);
556     }
557
558     /**
559      * Post the label event to the UI thread
560      *
561      * @param events the events to post
562      */

563     private void postLabelEvent(final LabelProviderChangedEvent event) {
564         Display.getDefault().asyncExec(new Runnable JavaDoc() {
565             public void run() {
566                 fireLabelProviderChanged(event);
567             }
568         });
569     }
570     
571     /* (non-Javadoc)
572      * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
573      */

574     public void dispose() {
575         super.dispose();
576         PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().removePropertyChangeListener(this);
577         CVSProviderPlugin.broadcastDecoratorEnablementChanged(false /* disabled */);
578         TeamUI.removePropertyChangeListener(this);
579         CVSUIPlugin.removePropertyChangeListener(this);
580     }
581     
582     /**
583      * Handle exceptions that occur in the decorator.
584      * Exceptions are only logged for resources that
585      * are accessible (i.e. exist in an open project).
586      */

587     private static void handleException(IResource resource, CoreException e) {
588         if (resource == null || resource.isAccessible())
589             exceptions.handleException(e);
590     }
591     
592     /**
593      * Handle exceptions that occur in the decorator.
594      * Exceptions are only logged for resources that
595      * are accessible (i.e. exist in an open project).
596      */

597     private void handleException(Object JavaDoc element, CoreException e) {
598         IResource resource = Utils.getResource(element);
599         if (resource != null) {
600             handleException(resource, e);
601         }
602         ResourceMapping mapping = Utils.getResourceMapping(element);
603         IProject[] projects = mapping.getProjects();
604         for (int i = 0; i < projects.length; i++) {
605             IProject project = projects[i];
606             if (!project.isAccessible()) {
607                 return;
608             }
609         }
610         exceptions.handleException(e);
611     }
612
613     /* (non-Javadoc)
614      * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
615      */

616     public void propertyChange(PropertyChangeEvent event) {
617         if (isEventOfInterest(event)) {
618             ensureFontAndColorsCreated(fonts, colors);
619             refresh();
620         }
621     }
622
623     private boolean isEventOfInterest(PropertyChangeEvent event) {
624         String JavaDoc prop = event.getProperty();
625         return prop.equals(TeamUI.GLOBAL_IGNORES_CHANGED)
626             || prop.equals(TeamUI.GLOBAL_FILE_TYPES_CHANGED)
627             || prop.equals(CVSUIPlugin.P_DECORATORS_CHANGED)
628             || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR)
629             || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR)
630             || prop.equals(CVSDecoratorConfiguration.OUTGOING_CHANGE_FONT)
631             || prop.equals(CVSDecoratorConfiguration.IGNORED_FOREGROUND_COLOR)
632             || prop.equals(CVSDecoratorConfiguration.IGNORED_BACKGROUND_COLOR)
633             || prop.equals(CVSDecoratorConfiguration.IGNORED_FONT);
634     }
635     
636     private static CVSWorkspaceSubscriber getSubscriber() {
637         return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
638     }
639 }
640
Popular Tags