List of usage examples for org.eclipse.jface.viewers IDecoration addOverlay
void addOverlay(ImageDescriptor overlay);
From source file:eu.numberfour.n4js.ui.decorator.ProjectTypeLabelDecorator.java
License:Open Source License
@Override public void decorate(final Object element, final IDecoration decoration) { try {//from www .j a va2 s .co m if (element instanceof IProject) { final URI uri = createPlatformResourceURI(((IProject) element).getName(), true); final IN4JSProject project = core.findProject(uri).orNull(); if (null != project) { final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType()); if (null != imageRef) { final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull(); if (null != descriptor) { decoration.addOverlay(descriptor); } } } } } catch (final Exception e) { // Exception should not propagate from here, otherwise the lightweight decorator stops working once till // next application startup. LOGGER.error("Error while trying to get decorator for " + element, e); } }
From source file:fede.workspace.tool.view.decorator.ItemDecorator.java
License:Apache License
public void decorate(Object element, IDecoration decoration) { IResource resource = getResource(element); if (resource == null || resource.getType() == IResource.ROOT) return;/*from w w w. j a v a 2s .co m*/ Item item = getItem(element, resource); if (item == null) return; try { if (element instanceof Item) { // IJavaElement je = JavaCore.create(resource); } else { ImageDescriptor image = WSPlugin.getDefault().getImageDescriptorFrom(item.getType(), item); if (image != null) { decoration.addOverlay(image); } } } catch (IllegalStateException e) { // This is thrown by Core if the workspace is in an illegal state // If we are not active, ignore it. Otherwise, propogate it. // (see bug 78303) if (Platform.getBundle(WSPlugin.PLUGIN_ID).getState() == Bundle.ACTIVE) { throw e; } } }
From source file:gov.nasa.ensemble.common.ui.ide.navigator.MarkerLabelDecorator.java
License:Open Source License
@Override public void decorate(Object element, IDecoration decoration) { if (element instanceof IResource) { IResource resource = (IResource) element; if (resource.isAccessible()) { try { int severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); switch (severity) { case IMarker.SEVERITY_ERROR: decoration.addOverlay(ERROR_OVERLAY); break; case IMarker.SEVERITY_WARNING: decoration.addOverlay(WARNING_OVERLAY); break; }//from w w w. j a va 2 s . co m } catch (CoreException e) { LogUtil.error("deteriming severity", e); } } } }
From source file:gov.redhawk.internal.ui.editor.validation.EmfValidatorLabelDecorator.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, * org.eclipse.jface.viewers.IDecoration) *//*from w w w . j a v a 2 s .com*/ @Override public void decorate(final Object element, final IDecoration decoration) { if (!(element instanceof EObject || element instanceof FeatureMap.Entry || element instanceof IWrapperItemProvider)) { return; } EObject object = null; if (element instanceof EObject) { object = (EObject) element; } else { final Object unwrapped = AdapterFactoryEditingDomain.unwrap(element); if (unwrapped instanceof EObject) { object = (EObject) unwrapped; } } // Skip non local resources if (object == null || object.eResource() == null || !object.eResource().getURI().isPlatform()) { return; } final Diagnostic validate; final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(object); if (editingDomain != null) { Diagnostic tmp = null; final EObject diagObj = object; try { tmp = TransactionUtil.runExclusive(editingDomain, new RunnableWithResult.Impl<Diagnostic>() { @Override public void run() { setResult(Diagnostician.INSTANCE.validate(diagObj)); } }); } catch (final InterruptedException e) { // PASS } validate = tmp; } else { validate = Diagnostician.INSTANCE.validate(object); } if (validate != null) { if (validate.getSeverity() == Diagnostic.ERROR) { decoration.addOverlay(getErrorImageDescriptor()); } else if (validate.getSeverity() == Diagnostic.WARNING) { decoration.addOverlay(getWarningImageDescriptor()); } } }
From source file:io.usethesource.impulse.editor.ProblemsLabelDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { int adornmentFlags = computeAdornmentFlags(element); if (adornmentFlags == ERRORTICK_ERROR) { decoration.addOverlay(PluginImages.DESC_OVR_ERROR); } else if (adornmentFlags == ERRORTICK_WARNING) { decoration.addOverlay(PluginImages.DESC_OVR_WARNING); }// w w w . ja v a 2 s.co m }
From source file:net.refractions.udig.project.ui.internal.LayerStateDecorator.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, * org.eclipse.jface.viewers.IDecoration) *///from w ww . j av a2 s .c o m @SuppressWarnings("unchecked") public void decorate(Object element, IDecoration decoration) { Layer layer = (Layer) element; // should be safe, extention point does the instanceof // check decoration.addOverlay(ProjectUIPlugin.getDefault().getImageDescriptor(ISharedImages.WRITE_OVR)); if (!layer.eAdapters().contains(hack)) { layer.eAdapters().add(hack); } }
From source file:net.refractions.udig.project.ui.internal.TemporaryLayerDecorator.java
License:Open Source License
public void decorate(Object element, IDecoration decoration) { ILayer layer = (ILayer) element;//from ww w . ja v a2 s . c o m if (layer.hasResource(ITransientResolve.class)) { decoration.addOverlay(ProjectUIPlugin.getDefault().getImageDescriptor(ISharedImages.CHANGED_OVR)); } }
From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java
License:Open Source License
/** * Adds decoration for derived objects.//w ww .j a va2s. com * * @param decoration * @param isLinkTargetCheckedOut */ private static void decorateDerivedObject(IDecoration decoration, String version) { if (ClearCaseUI.DEBUG_DECORATION) { ClearCaseUI.trace(DECORATOR, " decorateDerivedObject"); //$NON-NLS-1$ } if (ClearCaseUIPreferences.decorateDerivedObjects()) { decoration.addOverlay(IMG_DESC_DERIVED_OBJECT); } }
From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java
License:Open Source License
/** * Adds decoration for new state./*from w ww . j a v a 2 s . c om*/ * * @param decoration */ private static void decorateNew(IDecoration decoration) { if (ClearCaseUI.DEBUG_DECORATION) { ClearCaseUI.trace(DECORATOR, " decorateNew"); //$NON-NLS-1$ } if (ClearCaseUIPreferences.decorateViewPrivateElements()) { decoration.addOverlay(IMG_DESC_NEW_RESOURCE); } if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) { decoration.addPrefix(ClearCaseUI.getTextPrefixNew()); } }
From source file:net.sourceforge.eclipseccase.ui.ClearCaseDecorator.java
License:Open Source License
/** * Adds decoration for unknown state.//from w w w.j a v a2 s. co m * * @param decoration */ private static void decorateUnknown(IDecoration decoration) { if (ClearCaseUI.DEBUG_DECORATION) { ClearCaseUI.trace(DECORATOR, " decorateUnknown"); //$NON-NLS-1$ } if (ClearCaseUIPreferences.decorateUnknownElements()) { decoration.addOverlay(IMG_DESC_UNKNOWN_STATE); } if (ClearCaseUIPreferences.decorateElementStatesWithTextPrefix()) { decoration.addPrefix(ClearCaseUI.getTextPrefixUnknown()); } }