Example usage for org.eclipse.jface.viewers IDecoration addOverlay

List of usage examples for org.eclipse.jface.viewers IDecoration addOverlay

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IDecoration addOverlay.

Prototype

void addOverlay(ImageDescriptor overlay, int quadrant);

Source Link

Document

Adds an overlay to the element's image.

Usage

From source file:org.eclipse.php.internal.ui.util.BuildpathIndicatorLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    ImageDescriptor overlay = getOverlay(element);
    if (overlay != null) {
        decoration.addOverlay(overlay, IDecoration.BOTTOM_LEFT);
    }//ww w .  j  a va  2s  .  c o  m
}

From source file:org.eclipse.rcptt.ui.resources.viewers.WSResourceDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof WSLink) {
        if (WSValidators.validateLink((WSLink) element, null, null))
            decoration.addOverlay(LINK, IDecoration.BOTTOM_RIGHT);
        else/* w w w  .  j av  a 2s. c o  m*/
            decoration.addOverlay(BROKEN, IDecoration.BOTTOM_RIGHT);
    }
}

From source file:org.eclipse.ui.internal.ide.ResourceFilterDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {

    if (element instanceof IContainer == false) {
        return;/*from w w w  .j a  va2s  .  c o  m*/
    }
    IContainer container = (IContainer) element;
    IResourceFilterDescription[] filters = null;
    try {
        filters = container.getFilters();
        if ((filters.length > 0) && (descriptorImage != null))
            decoration.addOverlay(descriptorImage, IDecoration.BOTTOM_RIGHT);
    } catch (CoreException e) {
    }
}

From source file:org.eclipse.ui.internal.ide.VirtualResourceDecorator.java

License:Open Source License

/**
 * Replaces the resource image, if the given element is a virtual resource.
 * /*www.  ja v a  2s.  c om*/
 * @param element
 *            element to decorate
 * @param decoration
 *            The decoration we are adding to
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object,
 *      IDecoration)
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFolder && ((IResource) element).isVirtual()) {
        decoration.addOverlay(VIRTUAL_FOLDER, IDecoration.BOTTOM_RIGHT);
    }
}

From source file:org.eclipse.ui.tests.decorators.BadIndexDecorator.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
 *//*ww  w  .  j a  va2 s.  c  o m*/
public void decorate(Object element, IDecoration decoration) {
    decoration.addOverlay(getOverlay(element), 17);
}

From source file:org.eclipse.ui.tests.decorators.TestLightweightDecoratorMultipleQuadrantContributor.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
 *//* ww w  . j a  v a 2 s  .  com*/
public void decorate(Object element, IDecoration decoration) {
    decoration.addOverlay(getOverlay(element), IDecoration.BOTTOM_LEFT);
    decoration.addOverlay(getOverlay(element), IDecoration.BOTTOM_RIGHT);
    decoration.addOverlay(getOverlay(element), IDecoration.TOP_LEFT);
    decoration.addOverlay(getOverlay(element), IDecoration.TOP_RIGHT);
    decoration.addOverlay(getOverlay(element), IDecoration.UNDERLAY);
}

From source file:org.eclipse.vex.ui.internal.config.BuildProblemDecorator.java

License:Open Source License

@Override
public void decorate(final Object element, final IDecoration decoration) {

    if (errorIcon == null) {
        loadImageDescriptors();/*from   w  w  w .j  av  a2 s  . com*/
    }

    if (element instanceof IResource) {
        try {
            final IResource resource = (IResource) element;
            final IMarker[] markers = resource.findMarkers(IMarker.PROBLEM, true, 0);
            if (markers.length > 0) {
                decoration.addOverlay(errorIcon, IDecoration.BOTTOM_LEFT);
            }
        } catch (final CoreException e) {
        }
    }
}

From source file:org.eclipse.vex.ui.internal.config.PluginProjectDecorator.java

License:Open Source License

@Override
public void decorate(final Object element, final IDecoration decoration) {

    if (vexIcon == null) {
        loadImageDescriptors();/*from  ww  w  .java 2  s.c om*/
    }

    if (element instanceof IProject) {
        try {
            final IProject project = (IProject) element;
            if (project.hasNature(PluginProjectNature.ID)) {
                decoration.addOverlay(vexIcon, IDecoration.TOP_RIGHT);
            }
        } catch (final CoreException e) {
        }
    }
}

From source file:org.eclipse.virgo.ide.jdt.internal.ui.decoration.JdtClasspathContainerElementDecorator.java

License:Open Source License

/**
 * Decorates the given <code>element</code>.
 *//*from w ww  .  ja  v a2 s  . c o  m*/
public void decorate(Object element, IDecoration decoration) {
    // package fragments are the first elements below the JAR file
    if (element instanceof IPackageFragment) {
        IPackageFragment packageFragment = (IPackageFragment) element;
        if (shouldDecorateImportedPackageFragment(packageFragment)) {
            // make light gray and lock icon decoration
            decoration.setForegroundColor(ColorMap.GRAY_LIGHT);
            decoration.addOverlay(JdtUiImages.DESC_OVR_LOCKED, IDecoration.TOP_LEFT);
        } else if (shouldDecorateExportedPackageFragment(packageFragment)) {
            decoration.addOverlay(JdtUiImages.DESC_OVR_EXPORTED, IDecoration.TOP_RIGHT);
        }
    }
    // jar package fragments roots; decorate those that come from a test dependency
    else if (element instanceof IPackageFragmentRoot) {
        IPackageFragmentRoot root = (IPackageFragmentRoot) element;
        try {
            if (ServerClasspathContainer.CLASSPATH_CONTAINER_PATH.equals(root.getRawClasspathEntry().getPath())
                    && root.getJavaProject().getProject().isAccessible() && root.getJavaProject().isOpen()) {
                ServerClasspathContainer cpContainer = (ServerClasspathContainer) JavaCore
                        .getClasspathContainer(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH,
                                root.getJavaProject());
                if (cpContainer != null) {
                    for (IClasspathEntry entry : cpContainer.getClasspathEntries()) {
                        if (entry.getPath().equals(root.getPath()) && entry.getExtraAttributes() != null) {
                            for (IClasspathAttribute attribute : entry.getExtraAttributes()) {
                                if (attribute.getName()
                                        .equals(ServerClasspathContainer.TEST_CLASSPATH_ATTRIBUTE_VALUE)) {
                                    decoration.setForegroundColor(ColorMap.GRAY_LIGHT);
                                    decoration.addOverlay(JdtUiImages.DESC_OVR_LOCKED, IDecoration.TOP_LEFT);
                                }
                            }
                            break;
                        }
                    }
                }

            }
        } catch (JavaModelException e) {
        }
    }
    // class files represent a single type file in a JAR
    else if (element instanceof IClassFile) {
        IClassFile classFile = (IClassFile) element;
        if (classFile.getParent() instanceof IPackageFragment) {
            if (shouldDecorateImportedPackageFragment((IPackageFragment) classFile.getParent())) {
                // make light gray
                decoration.setForegroundColor(ColorMap.GRAY_LIGHT);
            }
        }
    }
    // decorate the class path container and add the originating target runtime
    else if (element instanceof ClassPathContainer) {
        ClassPathContainer container = (ClassPathContainer) element;
        if (container.getClasspathEntry().getPath().equals(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH)) {
            try {
                if (container.getJavaProject().getProject().isAccessible()
                        && container.getJavaProject().isOpen()) {
                    ServerClasspathContainer cpContainer = (ServerClasspathContainer) JavaCore
                            .getClasspathContainer(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH,
                                    container.getJavaProject());
                    decoration.addSuffix(cpContainer.getDescriptionSuffix());
                }
            } catch (JavaModelException e) {
            }
        }
    }
}

From source file:org.eclipse.virgo.ide.runtime.internal.ui.providers.ServerFileLabelProvider.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof ServerFile) {
        ServerFile serverFile = (ServerFile) element;
        String suffix = " [" + serverFile.getServer() + "] - " + serverFile.getFile().getLocation();
        if (element instanceof ServerFileSelection) {
            suffix += " #" + ((ServerFileSelection) element).getItem();
        }/* w  w  w  .  j av  a  2 s  . c  om*/
        decoration.addSuffix(suffix);
        if (!(element instanceof ServerFileSelection)) {
            decoration.addOverlay(ServerUiImages.DESC_OBJ_VIRGO_OVER, IDecoration.TOP_LEFT);
        }
    }
}