List of usage examples for org.eclipse.jface.viewers IDecorationContext getProperty
Object getProperty(String property);
null if the property does not exist in this context. From source file:org.eclipse.jst.servlet.ui.internal.navigator.CompressedJavaProjectCVSDecorator.java
License:Open Source License
protected SynchronizationStateTester getTester(IDecoration decoration) { IDecorationContext context = decoration.getDecorationContext(); SynchronizationStateTester tester = DEFAULT_TESTER; Object property = context.getProperty(SynchronizationStateTester.PROP_TESTER); if (property instanceof SynchronizationStateTester) { tester = (SynchronizationStateTester) property; }/* ww w .j a v a2 s. c om*/ return tester; }
From source file:org.eclipse.team.internal.ccvs.ui.CVSLightweightDecorator.java
License:Open Source License
/** * This method should only be called by the decorator thread. * //w w w.ja v a2 s.co m * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration) */ public void decorate(Object element, IDecoration decoration) { // Don't decorate the workspace root IResource resource = getResource(element); if (resource != null && resource.getType() == IResource.ROOT) return; // Get the mapping for the object and ensure it overlaps with CVS projects ResourceMapping mapping = Utils.getResourceMapping(element); if (mapping == null) return; if (!isMappedToCVS(mapping)) return; // Get the sync state tester from the context IDecorationContext context = decoration.getDecorationContext(); SynchronizationStateTester tester = DEFAULT_TESTER; Object property = context.getProperty(SynchronizationStateTester.PROP_TESTER); if (property instanceof SynchronizationStateTester) { tester = (SynchronizationStateTester) property; } // Calculate and apply the decoration try { if (tester.isDecorationEnabled(element)) { CVSDecoration cvsDecoration = decorate(element, tester); cvsDecoration.apply(decoration); } } catch (CoreException e) { handleException(element, e); } catch (IllegalStateException e) { // This is thrown by Core if the workspace is in an illegal state // If we are not active, ignore it. Otherwise, propagate it. // (see bug 78303) if (Platform.getBundle(CVSUIPlugin.ID).getState() == Bundle.ACTIVE) { throw e; } } }
From source file:org.eclipse.team.svn.ui.decorator.SVNLightweightDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { try {/*from w w w . ja va 2 s . c om*/ // Don't decorate the workspace root or deleted/closed resources IResource resource = this.getResource(element); if (resource != null && (resource.getType() == IResource.ROOT || !resource.isAccessible())) { return; } // Get the mapping for the object and ensure it overlaps with SVN projects ResourceMapping mapping = Utils.getResourceMapping(element); if (mapping == null || !this.isMappedToSVN(mapping)) { return; } // Get the sync state tester from the context IDecorationContext context = decoration.getDecorationContext(); SynchronizationStateTester tester = SVNLightweightDecorator.DEFAULT_TESTER; Object property = context.getProperty(SynchronizationStateTester.PROP_TESTER); if (property instanceof SynchronizationStateTester) { tester = (SynchronizationStateTester) property; } // Calculate and apply the decoration if (tester.isDecorationEnabled(element) && this.isSupervised(mapping)) { //check if the element adapts to a single resource if (resource != null) { this.decorateResource(resource, decoration); } else { this.decorateModel(element, decoration, tester); } } } catch (Throwable ex) { LoggedOperation.reportError("SVN Decorator", ex);//$NON-NLS-1$ } }