Java Code Examples for org.eclipse.jface.viewers.IDecoration#addOverlay()

The following examples show how to use org.eclipse.jface.viewers.IDecoration#addOverlay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectTypeLabelDecorator.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void decorate(final Object element, final IDecoration decoration) {
	try {
		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);
	}
}
 
Example 2
Source File: OverrideIndicatorLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void decorate(Object element, IDecoration decoration) {
	int adornmentFlags= computeAdornmentFlags(element);
	if ((adornmentFlags & JavaElementImageDescriptor.IMPLEMENTS) != 0) {
		if ((adornmentFlags & JavaElementImageDescriptor.SYNCHRONIZED) != 0) {
			decoration.addOverlay(JavaPluginImages.DESC_OVR_SYNCH_AND_IMPLEMENTS);
		} else {
			decoration.addOverlay(JavaPluginImages.DESC_OVR_IMPLEMENTS);
		}
	} else if ((adornmentFlags & JavaElementImageDescriptor.OVERRIDES) != 0) {
		if ((adornmentFlags & JavaElementImageDescriptor.SYNCHRONIZED) != 0) {
			decoration.addOverlay(JavaPluginImages.DESC_OVR_SYNCH_AND_OVERRIDES);
		} else {
			decoration.addOverlay(JavaPluginImages.DESC_OVR_OVERRIDES);
		}
	}
}
 
Example 3
Source File: WWWFolderDecorator.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
	if (!(element instanceof IFolder)) {
		return;
	}

	IFolder folder = (IFolder)element;
	try {
		if (folder.getProject().hasNature("org.eclipse.thym.core.HybridAppNature")
			&& folder.getProjectRelativePath().toPortableString().equals("www")) {

			decoration.addOverlay(wwwOverlay);
		}
	} catch (CoreException e) {
		HybridUI.log(IStatus.WARNING, "Could not determine Nature of project", e);
	}
}
 
Example 4
Source File: ProblemsLabelDecorator.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
    int errorState = getErrorState(element);
    if (errorState == IMarker.SEVERITY_ERROR) {
        decoration.addOverlay(
                ImageCache.asImageDescriptor(
                        SharedUiPlugin.getImageCache().getDescriptor(UIConstants.ERROR_DECORATION)),
                IDecoration.BOTTOM_LEFT);

    } else if (errorState == IMarker.SEVERITY_WARNING) {
        decoration.addOverlay(
                ImageCache.asImageDescriptor(
                        SharedUiPlugin.getImageCache().getDescriptor(UIConstants.WARNING_DECORATION)),
                IDecoration.BOTTOM_LEFT);
    }
}
 
Example 5
Source File: SharedProjectDecorator.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
  // make a copy as this value might change while decorating
  ISarosSession currentSession = session;

  if (currentSession == null) return;

  IResource resource = (IResource) element;

  if (!currentSession.isShared(ResourceAdapterFactory.create(resource))) return;

  decoration.addOverlay(SharedProjectDecorator.PROJECT_DESCRIPTOR, IDecoration.TOP_LEFT);

  if (resource.getType() == IResource.PROJECT) {
    decoration.addSuffix(Messages.SharedProjectDecorator_shared);
  }
}
 
Example 6
Source File: ContactTypeDecorator.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration){
	IContact contact = (IContact) element;
	if (contact.isDeleted()) {
		ImageDescriptor deleted = Images.IMG_DELETE.getImageDescriptor();
		decoration.addOverlay(deleted, IDecoration.TOP_LEFT);
	}
	
	if (contact.isMandator()) {
		ImageDescriptor vip = Images.IMG_VIP_OVERLAY.getImageDescriptor();
		decoration.addOverlay(vip, IDecoration.BOTTOM_RIGHT);
	}
	if (contact.isUser()) {
		FieldDecoration info =
			FieldDecorationRegistry.getDefault().getFieldDecoration(
				FieldDecorationRegistry.DEC_INFORMATION);
		ImageDescriptor infoD = ImageDescriptor.createFromImage(info.getImage());
		decoration.addOverlay(infoD, IDecoration.BOTTOM_LEFT);
	}
}
 
Example 7
Source File: BuildpathIndicatorLabelDecorator.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
	ImageDescriptor overlay = getOverlay(element);
	if (overlay != null) {
		decoration.addOverlay(overlay, IDecoration.TOP_RIGHT);
	}
}
 
Example 8
Source File: GamlDecorator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void decorate(final Object element, final IDecoration deco) {
	if (element instanceof VirtualContent) {
		deco.addOverlay(((VirtualContent<?>) element).getOverlay(), BOTTOM_LEFT);
	} else if (element instanceof IFile) {
		final IFile r = (IFile) element;
		if (GamlFileExtension.isAny(r.getName()))
			try {
				deco.addOverlay(DESCRIPTORS.get(r.findMaxProblemSeverity(PROBLEM, true, DEPTH_INFINITE)),
						BOTTOM_LEFT);
			} catch (final CoreException e) {}
	}
}
 
Example 9
Source File: ProblemsLabelDecorator.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void decorate(Object element, IDecoration decoration)
{
	int adornmentFlags = computeAdornmentFlags(element);
	switch (adornmentFlags)
	{
		case ERROR:
			decoration.addOverlay(EditorPluginImages.DESC_OVR_ERROR);
			break;
		case WARNING:
			decoration.addOverlay(EditorPluginImages.DESC_OVR_WARNING);
			break;
	}
}
 
Example 10
Source File: ProblemsLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void decorate(Object element, IDecoration decoration) {
	int adornmentFlags= computeAdornmentFlags(element);
	if (adornmentFlags == ERRORTICK_ERROR) {
		decoration.addOverlay(JavaPluginImages.DESC_OVR_ERROR);
	} else if (adornmentFlags == ERRORTICK_BUILDPATH_ERROR) {
		decoration.addOverlay(JavaPluginImages.DESC_OVR_BUILDPATH_ERROR);
	} else if (adornmentFlags == ERRORTICK_WARNING) {
		decoration.addOverlay(JavaPluginImages.DESC_OVR_WARNING);
	}
}
 
Example 11
Source File: BuildpathIndicatorLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void decorate(Object element, IDecoration decoration) {
	ImageDescriptor overlay= getOverlay(element);
	if (overlay != null) {
		decoration.addOverlay(overlay, IDecoration.BOTTOM_LEFT);
	}
}
 
Example 12
Source File: InterfaceIndicatorLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void addOverlaysFromFlags(int flags, IDecoration decoration) {
	ImageDescriptor type;
	if (Flags.isAnnotation(flags)) {
		type= JavaPluginImages.DESC_OVR_ANNOTATION;
	} else if (Flags.isEnum(flags)) {
		type= JavaPluginImages.DESC_OVR_ENUM;
	} else if (Flags.isInterface(flags)) {
		type= JavaPluginImages.DESC_OVR_INTERFACE;
	} else if (/* is class */ Flags.isAbstract(flags)) {
		type= JavaPluginImages.DESC_OVR_ABSTRACT_CLASS;
	} else {
		type= null;
	}
	
	boolean deprecated= Flags.isDeprecated(flags);
	boolean packageDefault= Flags.isPackageDefault(flags);
	
	/* Each decoration position can only be used once. Since we don't want to take all positions
	 * away from other decorators, we confine ourselves to only use the top right position. */
	
	if (type != null && !deprecated && !packageDefault) {
		decoration.addOverlay(type, IDecoration.TOP_RIGHT);
		
	} else if (type == null && deprecated && !packageDefault) {
		decoration.addOverlay(JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_RIGHT);
		
	} else if (type != null || deprecated || packageDefault) {
		decoration.addOverlay(new TypeIndicatorOverlay(type, deprecated, packageDefault), IDecoration.TOP_RIGHT);
	}
}
 
Example 13
Source File: SharedProjectFileDecorator.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
  ImageDescriptor imageDescriptor = resourceToImageMapping.get(element);

  if (imageDescriptor == null) return;

  decoration.addOverlay(imageDescriptor, IDecoration.TOP_RIGHT);
}
 
Example 14
Source File: ProblemsLabelDecorator.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
	ImageDescriptor imageDescriptor= computeAdornmentFlags(element);
	if(imageDescriptor != null) {
		decoration.addOverlay(imageDescriptor);
	}
}
 
Example 15
Source File: CodeHighlightDecorator.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
private void setIcon(IDecoration decoration) {
	decoration.addOverlay(ImageDescriptor.createFromFile(getClass(), ICON));
}