org.eclipse.jface.viewers.IDecoration Java Examples

The following examples show how to use org.eclipse.jface.viewers.IDecoration. 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: XtendEditorErrorTickUpdater.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected void updateEditorImage(XtextEditor xtextEditor) {
	if (xtextEditor != null && !xtextEditor.isEditable()) {
		Severity severity = getSeverity(xtextEditor);
		if (severity != null && severity != Severity.INFO) {
			ImageDescriptor descriptor = severity == Severity.ERROR ? XtextPluginImages.DESC_OVR_ERROR
					: XtextPluginImages.DESC_OVR_WARNING;
			// TODO replace with new constructor that takes an ImageDescription when on Oxygen+
			DecorationOverlayIcon decorationOverlayIcon = new DecorationOverlayIcon(pluginImageHelper.getImage(images.forReadonly()), descriptor,
					IDecoration.BOTTOM_LEFT);
			scheduleUpdateEditor(decorationOverlayIcon);
		} else {
			scheduleUpdateEditor(images.forReadonly());
		}
	} else {
		super.updateEditorImage(xtextEditor);
	}
}
 
Example #2
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 #3
Source File: GamlEditorTickUpdater.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void updateEditorImage(final XtextEditor editor) {
	Severity severity = getSeverity(editor);
	ImageDescriptor descriptor = null;
	if (severity == null || severity == Severity.INFO) {
		descriptor = GamaIcons.create(IGamaIcons.OVERLAY_OK).descriptor();
	} else if (severity == Severity.ERROR) {
		descriptor = GamaIcons.create("navigator/overlay.error2").descriptor();
	} else if (severity == Severity.WARNING) {
		descriptor = GamaIcons.create("navigator/overlay.warning2").descriptor();
	} else {
		super.updateEditorImage(editor);
		return;
	}
	final DecorationOverlayIcon decorationOverlayIcon =
			new DecorationOverlayIcon(editor.getDefaultImage(), descriptor, IDecoration.BOTTOM_LEFT);
	scheduleUpdateEditor(decorationOverlayIcon);
}
 
Example #4
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 #5
Source File: TimeRangeDecorator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void decorate ( final Object element, final IDecoration decoration )
{
    try
    {
        final IFile resource = (IFile)element;
        final String timeframe = getTimeframe ( resource );
        if ( timeframe != null )
        {
            decoration.addSuffix ( " " + timeframe );
        }
    }
    catch ( final Exception e )
    {
    }

}
 
Example #6
Source File: JSIndexViewLabelProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Image decorateImage(Image image, Object element)
{
	Image result = null;

	if (image != null && element instanceof PropertyElement)
	{
		PropertyElement property = (PropertyElement) element;

		if (property.isClassProperty())
		{
			DecorationOverlayIcon decorator = new DecorationOverlayIcon(image, STATIC_OVERLAY,
					IDecoration.TOP_RIGHT);

			result = decorator.createImage();
		}
	}

	return result;
}
 
Example #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: CPVariableElementLabelProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public CPVariableElementLabelProvider(boolean highlightReadOnly) {
	ImageRegistry reg= JavaPlugin.getDefault().getImageRegistry();
	fJARImage= reg.get(JavaPluginImages.IMG_OBJS_EXTJAR);
	fFolderImage= PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);

	fDeprecatedJARImage= new DecorationOverlayIcon(fJARImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage();
	fDeprecatedFolderImage= new DecorationOverlayIcon(fFolderImage, JavaPluginImages.DESC_OVR_DEPRECATED, IDecoration.TOP_LEFT).createImage();

	fHighlightReadOnly= highlightReadOnly;
}
 
Example #13
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 #14
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 #15
Source File: AbapGitStagingLabelProvider.java    From ADT_Frontend with MIT License 5 votes vote down vote up
/**
 * Method to overlay an image with another
 */
private Image decorateImage(Image baseImage, String overlayImagePath) {
	Bundle bundle = Platform.getBundle(AbapGitUIPlugin.PLUGIN_ID);
	URL fullPathString = BundleUtility.find(bundle, overlayImagePath);
	DecorationOverlayIcon doi = new DecorationOverlayIcon(//
			baseImage, ImageDescriptor.createFromURL(fullPathString), IDecoration.BOTTOM_RIGHT);
	return doi.createImage();
}
 
Example #16
Source File: SVNLightweightDecorator.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void computeColorsAndFonts(boolean isIgnored, boolean isDirty, IDecoration decoration) {
	if (!SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS)) return;
	ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	if(isIgnored) {
		decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_BACKGROUND_COLOR));
		decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_FOREGROUND_COLOR));
		decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.IGNORED_FONT));
	} else if(isDirty) {
		decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR));
		decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR));
		decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FONT));
	}
}
 
Example #17
Source File: SVNDecoratorConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
    * add a prefix and a suffix depending on format string and the bindings
    * @param decoration
    * @param format
    * @param bindings
    */
public static void decorate(IDecoration decoration, IDecoratorComponent[][] format, Map bindings) {
       
       String[] prefixSuffix = decorate(format, bindings);
       decoration.addPrefix(prefixSuffix[0]);
       decoration.addSuffix(prefixSuffix[1]);
}
 
Example #18
Source File: InterfaceIndicatorLabelDecorator.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) {
	try {
		addOverlays(element, decoration);
	} catch (JavaModelException e) {
		return;
	}
}
 
Example #19
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 #20
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 #21
Source File: ProblemsLabelDecorator.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
	public Image decorateImage(Image image, Object obj) {
		if(image == null)
			return null;
		
		ImageDescriptor overlayImage = computeAdornmentFlags(obj);
		if(overlayImage != null) {
//			ImageDescriptor baseImage = new ImageImageDescriptor(image);
			return getRegistry().get(new DecorationOverlayIcon(image, overlayImage, IDecoration.BOTTOM_LEFT));
		}
		return image;
	}
 
Example #22
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 #23
Source File: MissingDependenciesDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Image getErrorDecoratedImage(Image image) {
	if(errorIcon == null){
		errorIcon =  new DecorationOverlayIcon(image,new ImageDescriptor() {
			
			@Override
			public ImageData getImageData() {
				return errorDecoratorImage.getImageData();
			}
		} , IDecoration.BOTTOM_RIGHT).createImage() ;
	}
	return errorIcon;
}
 
Example #24
Source File: MissingDependenciesDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Image getWarningDecoratedImage(Image image) {
	if(warningIcon == null){
		
		warningIcon =  new DecorationOverlayIcon(image,new ImageDescriptor() {
			
			@Override
			public ImageData getImageData() {
				return warningDecoratorImage.getImageData();
			}
		}, IDecoration.BOTTOM_RIGHT).createImage() ;
	}
	return warningIcon;
}
 
Example #25
Source File: CustomJavaObjectDataItemProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object getImage(Object object) {
	Object icon = super.getImage(object);
	if(object instanceof Data){
		Image iconImage =  null;
		boolean formTransient = ((Data) object).getDatasourceId() != null && ((Data) object).getDatasourceId().equals("PAGEFLOW");
		if(object instanceof JavaObjectData){
			if(((JavaObjectData) object).getClassName() != null){
				try {
					IType t = RepositoryManager.getInstance().getCurrentRepository().getJavaProject().findType(((JavaObjectData) object).getClassName());
					if(t != null && t.isInterface()){
						iconImage = Pics.getImage("int_obj.gif");
						if(EMFEditCustomPlugin.getDefault().getImageRegistry().get("decoratedImageForInterfaceJavaObject") == null){
							EMFEditCustomPlugin.getDefault().getImageRegistry().put("decoratedImageForInterfaceJavaObject", new DecorationOverlayIcon(iconImage,Pics.getImageDescriptor("form_decorator.png",EMFEditCustomPlugin.getDefault()),IDecoration.BOTTOM_LEFT).createImage());
						}
						if(formTransient){
							return EMFEditCustomPlugin.getDefault().getImageRegistry().get("decoratedImageForInterfaceJavaObject") ;
						}
						return iconImage;
					}else{
						iconImage = Pics.getImage("class_obj.gif");
						if(EMFEditCustomPlugin.getDefault().getImageRegistry().get("decoratedImageForClassJavaObject") == null){
							EMFEditCustomPlugin.getDefault().getImageRegistry().put("decoratedImageForClassJavaObject", new DecorationOverlayIcon(iconImage,Pics.getImageDescriptor("form_decorator.png",EMFEditCustomPlugin.getDefault()),IDecoration.BOTTOM_LEFT).createImage());
						}
						if(formTransient){
							return EMFEditCustomPlugin.getDefault().getImageRegistry().get("decoratedImageForClassJavaObject") ;
						}
						return iconImage;
					}
				} catch (JavaModelException e) {

				}
			}
		}
	}
	return icon;
}
 
Example #26
Source File: WizardPageDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Image decorateImage(Image image, Object element) {
    IProcessConfigurationWizardPage page = (IProcessConfigurationWizardPage) element ;
    String erroMessage = page.isConfigurationPageValid(dialog.getConfiguration()) ;
    if (image != null && erroMessage != null) {
        return new DecorationOverlayIcon(image,Pics.getImageDescriptor("problem.gif",ConfigurationPlugin.getDefault()) , IDecoration.BOTTOM_RIGHT).createImage();
    }

    return null;
}
 
Example #27
Source File: ImageManager.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static Image get(String filename, String overlay) {
	if (filename == null || overlay == null)
		return null;
	String id = filename + "-" + overlay;
	Image withOverlay = registry.get(id);
	if (withOverlay != null && !withOverlay.isDisposed())
		return withOverlay;
	DecorationOverlayIcon withIcon = new DecorationOverlayIcon(
			get(filename), descriptor(overlay), IDecoration.BOTTOM_RIGHT);
	withOverlay = withIcon.createImage();
	registry.put(id, withOverlay);
	return withOverlay;
}
 
Example #28
Source File: InCompilationSetDecorator.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void decorate(Object element, IDecoration decoration) {
	if (element instanceof IXdsSdkLibraryContainer) {
		IProject project = ((IXdsSdkLibraryContainer)element).getXdsProject().getProject();
		decorateWithSdkName(project, decoration);
	}
    else {
        decorateElement(element, decoration);
    }
}
 
Example #29
Source File: N4JSDecoratorRow.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("javadoc")
public N4JSDecoratorRow(ImageDescriptor main, int quadrant, List<ImageDescriptor> decos) {
	Objects.requireNonNull(main);
	if ((quadrant < IDecoration.TOP_LEFT) || (quadrant > IDecoration.BOTTOM_RIGHT)) {
		throw new IllegalArgumentException();
	}
	Objects.requireNonNull(decos);
	this.main = main;
	this.quadrant = quadrant;
	this.decos = decos.toArray(new ImageDescriptor[decos.size()]);
}
 
Example #30
Source File: N4JSDecoratorRow.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Are the decorators aligned vertically on top?
 */
private boolean isDecoTop() {
	switch (quadrant) {
	case IDecoration.TOP_LEFT:
	case IDecoration.TOP_RIGHT:
		return true;

	default:
		return false;
	}
}