List of usage examples for org.eclipse.jface.viewers IDecoration getDecorationContext
IDecorationContext getDecorationContext();
From source file:com.centimia.orm.jaqu.plugin.decorator.ResourceDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof IFile) { String isJaqu = Activator.getDefault().getPreferenceStore() .getString(((IFile) element).getProject().getName() + "_" + ((IFile) element).getName()); if (!"".equals(isJaqu)) { ((DecorationContext) decoration.getDecorationContext()).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); decoration.addOverlay(getFileImageDescriptor(), IDecoration.TOP_LEFT); }//from www . ja v a 2 s . co m } }
From source file:com.google.gdt.eclipse.managedapis.ui.ManageApiInfoDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { // Enables use of REPLACE as a valid image decoration ((DecorationContext) decoration.getDecorationContext()).putProperty(IDecoration.ENABLE_REPLACE, true); try {//from w w w . j a v a2 s . co m if (ManagedApiContainer.isManagedApiContainer(element)) { ClassPathContainer container = (ClassPathContainer) element; ManagedApiProject managedApiProject = ManagedApiContainer .getManagedApiProjectForClassPathContainer(container); ManagedApi managedApi = ManagedApiContainer.getManagedApiForClassPathContainer(container); if (checkAndApplyErrorDecoration(decoration, managedApiProject, container.getClasspathEntry())) { return; } if (managedApi.isUpdateAvailable()) { applyUpdateAvailableDecoration(decoration); } } } catch (MalformedURLException e) { ManagedApiLogger.warn(e, "Unexpected MalformedURLException"); } }
From source file:com.google.gdt.eclipse.managedapis.ui.ManagedApiContainerDecorator.java
License:Open Source License
/** * Conditionally decorate the element by replacing the element's icon *///w ww . j a va2s . c o m public void decorate(Object element, IDecoration decoration) { // Enables use of REPLACE as a valid image decoration ((DecorationContext) decoration.getDecorationContext()).putProperty(IDecoration.ENABLE_REPLACE, true); try { if (ManagedApiContainer.isManagedApiContainer(element)) { applyApiSpecificContainerIcon(element, decoration); } } catch (MalformedURLException e) { ManagedApiLogger.warn(e, "Unexpected MalformedURLException"); } }
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; }/*from w ww .ja va 2 s. c o m*/ return tester; }
From source file:org.eclipse.jubula.client.ui.provider.labelprovider.decorators.ResultDecorator.java
License:Open Source License
/** {@inheritDoc} */ public void decorate(Object element, IDecoration decoration) { if (element instanceof TestResultNode) { TestResultNode resultNode = ((TestResultNode) element); if (resultNode.getNode() instanceof ICommentPO) { return; }//from www.j a v a 2 s.c o m int status = resultNode.getStatus(); ImageDescriptor image2use = null; IDecorationContext context = decoration.getDecorationContext(); if (context instanceof DecorationContext) { ((DecorationContext) context).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); } switch (status) { case TestResultNode.NOT_YET_TESTED: break; case TestResultNode.NO_VERIFY: image2use = IconConstants.STEP_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.TESTING: image2use = IconConstants.STEP_TESTING_IMAGE_DESCRIPTOR; break; case TestResultNode.SUCCESS: image2use = IconConstants.STEP_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.ERROR: case TestResultNode.CONDITION_FAILED: case TestResultNode.INFINITE_LOOP: image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.ERROR_IN_CHILD: image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.NOT_TESTED: image2use = IconConstants.STEP_FAILED_IMAGE_DESCRIPTOR; break; case TestResultNode.RETRYING: image2use = IconConstants.STEP_RETRY_IMAGE_DESCRIPTOR; break; case TestResultNode.SUCCESS_RETRY: image2use = IconConstants.STEP_RETRY_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.ABORT: image2use = IconConstants.STEP_NOT_OK_IMAGE_DESCRIPTOR; break; case TestResultNode.SKIPPED: image2use = IconConstants.STEP_SKIPPED_IMAGE_DESCRIPTOR; break; case TestResultNode.SUCCESS_ONLY_SKIPPED: image2use = IconConstants.STEP_SUCCESS_SKIPPED_IMAGE_DESCRIPTOR; break; default: break; } decoration.addOverlay(image2use, IDecoration.REPLACE); } }
From source file:org.eclipse.jubula.client.ui.provider.labelprovider.decorators.TestResultDurationDecorator.java
License:Open Source License
/** {@inheritDoc} */ public void decorate(Object element, IDecoration decoration) { if (element instanceof TestResultNode) { TestResultNode testResult = (TestResultNode) element; if (testResult.getNode() instanceof ICommentPO) { return; }/*from w w w . ja va 2 s . c om*/ Object testSuiteEndTimeValue = decoration.getDecorationContext() .getProperty(TestResultViewer.DECORATION_CONTEXT_SUITE_END_TIME_ID); Date endTime = testSuiteEndTimeValue instanceof Date ? (Date) testSuiteEndTimeValue : null; long durationMillis = testResult.getDuration(endTime); if (durationMillis != -1) { // only decorate if the duration could be determined decoration.addSuffix(SUFFIX_SPACER + DurationFormatUtils.formatDurationHMS(durationMillis)); } } }
From source file:org.eclipse.papyrus.infra.onefile.providers.OneFileDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { if (element instanceof IPapyrusFile) { IPapyrusFile papy = (IPapyrusFile) element; IResource[] associatedResources = papy.getAssociatedResources(); FilteredDecorationBuilder builder = new FilteredDecorationBuilder(decoration.getDecorationContext(), associatedResources.length); for (IResource r : associatedResources) { WorkbenchPlugin.getDefault().getDecoratorManager().getLightweightManager().getDecorations(r, builder);/*from w w w . j a va 2 s . c o m*/ } builder.handleDecoration(decoration); } }
From source file:org.eclipse.php.internal.ui.navigator.PHPNavigatorLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IFolder) { IDecorationContext context = decoration.getDecorationContext(); if (context instanceof DecorationContext) { ((DecorationContext) context).putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE); }//from w w w . j a va 2 s .com IFolder folder = (IFolder) element; IScriptProject project = DLTKCore.create(folder.getProject()); try { if (PHPToolkitUtil.isPhpProject(folder.getProject()) && project.isOnBuildpath(folder)) { if (lfm.isInLibraryFolder(folder)) { decoration.addOverlay(PHPPluginImages.DESC_OBJS_PHP_LIBFOLDER, IDecoration.REPLACE); } else { decoration.addOverlay(DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT, IDecoration.REPLACE); } } } catch (CoreException e) { Logger.logException(e); } } }
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 va 2s . c o 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 www . ja v a 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$ } }