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);

Source Link

Document

Adds an overlay to the element's image.

Usage

From source file:com.rcpcompany.uibindings.bindingMessages.ValidationLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    final Integer severity = myObjectSeverities.get(element);
    if (severity == null)
        return;/*from w ww  .  ja  v a2 s  .c  o m*/
    if (Activator.getDefault() != null && Activator.getDefault().TRACE_LABEL_DECORATOR) {
        LogUtils.debug(this, hashCode() + ": " + element + ": severity: " + severity); //$NON-NLS-1$ //$NON-NLS-2$
    }
    switch (severity) {
    case IMessageProvider.NONE:
        break;
    case IMessageProvider.INFORMATION:
        break;
    case IMessageProvider.WARNING:
        decoration.addOverlay(WARNING_IMAGE);
        break;
    case IMessageProvider.ERROR:
        decoration.addOverlay(ERROR_IMAGE);
        break;
    default:
        break;
    }
}

From source file:com.symbian.smt.gui.OutOfSyncDecorator.java

License:Open Source License

public void decorateProject(String projectName, IDecoration decoration) {
    if (!temp.isInSync(projectName)) {
        decoration.addOverlay(ImageDescriptor.createFromURL(FileLocator.find(bundle, path, null)));
    } else {//from w ww  .  j  av a 2s .c  om
        decoration.addOverlay(null);
    }
}

From source file:com.synflow.ngDesign.ui.internal.navigator.CxLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFile) {
        IFile file = (IFile) element;/*from  w  w  w . j  a va  2  s  .  c  o  m*/
        if (FILE_EXT_CX.equals(file.getFileExtension())) {
            Module module = getEObject(file, Module.class);
            if (module != null) {
                Iterable<Network> networks = Iterables.filter(module.getEntities(), Network.class);
                if (!Iterables.isEmpty(networks)) {
                    ImageDescriptor descriptor = CxActivator.imageDescriptorFromPlugin("com.synflow.cx.ui",
                            "icons/overlay_network.png");
                    decoration.addOverlay(descriptor);
                }
            }
        }
    }
}

From source file:com.vectrace.MercurialEclipse.history.FileStatusDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof FileStatus)) {
        return;//ww  w. ja  v a  2s .  c  o m
    }
    final Action action = ((FileStatus) element).getAction();
    ImageDescriptor overlay = null;
    if (action == null) {
        overlay = DecoratorImages.NOT_TRACKED;
    } else {
        switch (action) {
        case ADDED:
            overlay = DecoratorImages.ADDED;
            break;
        case MODIFIED:
            overlay = DecoratorImages.MODIFIED;
            break;
        case REMOVED:
            overlay = DecoratorImages.REMOVED;
            break;
        case COPIED:
            overlay = DecoratorImages.COPIED;
            break;
        case MOVED:
            overlay = DecoratorImages.MOVED;
            break;
        }
    }
    decoration.addOverlay(overlay);
}

From source file:com.vectrace.MercurialEclipse.team.ResourceDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration d) {
    IResource resource = (IResource) element;
    IProject project = resource.getProject();
    if (project == null || !project.isAccessible()) {
        return;//from  w  w w . j av a2 s.c  om
    }

    try {
        if (!MercurialTeamProvider.isHgTeamProviderFor(project)) {
            return;
        }

        if (!STATUS_CACHE.isStatusKnown(project)) {
            // simply wait until the cache sends us an event
            d.addOverlay(DecoratorImages.NOT_TRACKED);
            if (resource == project) {
                d.addSuffix(" [Hg status pending...]");
            }
            return;
        }

        ImageDescriptor overlay = null;
        StringBuilder prefix = new StringBuilder(2);
        Integer output = STATUS_CACHE.getStatus(resource);
        if (output != null) {
            overlay = decorate(output.intValue(), prefix, d, colorise);
        } else {
            if (resource.getType() == IResource.FILE) {
                overlay = decorate(MercurialStatusCache.BIT_IGNORE, prefix, d, colorise);
            }
            // empty folder, do nothing
        }
        if (overlay != null) {
            d.addOverlay(overlay);
        }

        if (!showChangeset) {
            if (resource.getType() == IResource.PROJECT || shouldCheckSubrepo(resource)) {
                d.addSuffix(getSuffixForContainer((IContainer) resource));
            }
        } else {
            addChangesetInfo(d, resource, project, prefix);
        }

        // we want a prefix, even if no changeset is displayed
        if (prefix.length() > 0) {
            d.addPrefix(prefix.toString());
        }
    } catch (Exception e) {
        MercurialEclipsePlugin.logError(e);
    }
}

From source file:com.xored.af.ui.labels.EObjectDecorator.java

License:Open Source License

private void doDecorate(final EObject eobject, final IDecoration decoration) {
    final Resource resource = eobject.eResource();
    if (resource == null) {
        return;/*from  w w w  .  j ava  2s . c om*/
    }

    // iterate over copies to avoid concurrency issues
    for (final Diagnostic d : new ArrayList<Diagnostic>(resource.getErrors())) {
        if (d instanceof EmfDiagnostic) {
            final EmfDiagnostic diag = (EmfDiagnostic) d;
            try {
                if (isDiagnosticRelevant(eobject, diag)) {
                    decoration.addOverlay(AfUiPlugin.OVR_ERROR);
                    ensureIsObserved(resource);
                    return;
                }
            } catch (final Exception e) {
                AfUiPlugin.getDefault().warn(e);
            }
        } else if (d instanceof SimpleDiagnostic) {
            final SimpleDiagnostic diag = (SimpleDiagnostic) d;
            if (diag.getLocation() != null
                    && URI.createURI(diag.getLocation()).equals(EcoreUtil.getURI(eobject).trimFragment())) {
                decoration.addOverlay(AfUiPlugin.OVR_ERROR);
                ensureIsObserved(resource);
                return;
            }
        }
    }

    for (final Diagnostic d : new ArrayList<Diagnostic>(resource.getWarnings())) {
        if (d instanceof EmfDiagnostic) {
            final EmfDiagnostic diag = (EmfDiagnostic) d;
            try {
                if (isDiagnosticRelevant(eobject, diag)) {
                    decoration.addOverlay(AfUiPlugin.OVR_WARN);
                    ensureIsObserved(resource);
                    return;
                }
            } catch (final Exception e) {
                AfUiPlugin.getDefault().warn(e);
            }
        }
    }
}

From source file:com.xored.af.ui.labels.ResourceDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof Resource) {
        final Resource resource = (Resource) element;
        if (!resource.getErrors().isEmpty()) {
            decoration.addOverlay(AfUiPlugin.OVR_ERROR);
        } else if (!resource.getWarnings().isEmpty()) {
            decoration.addOverlay(AfUiPlugin.OVR_WARN);
        }/*from w  w w.  java  2 s. c o m*/
    }
}

From source file:descent.ui.ProblemsLabelDecorator.java

License:Open Source License

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_WARNING) {
        decoration.addOverlay(JavaPluginImages.DESC_OVR_WARNING);
    }/*from  ww  w .  j  av  a  2s  . c om*/
}

From source file:edu.uci.lighthouse.core.decorators.LighthouseProjectLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IProject) {
        IProject project = (IProject) element;
        LighthouseModel model = LighthouseModel.getInstance();
        Collection<String> projectNames = model.getProjectNames();
        if (projectNames.contains(project.getName())) {
            decoration.addOverlay(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, ICON));
        }//from   ww  w .  j  a v  a2  s .c  o m
    }
}

From source file:edu.wpi.cs.jburge.SEURAT.decorators.SEURATLightWeightDecorator.java

License:Open Source License

/**
 * This is where the actual decoration takes place.
 * @param object - this is what we are decorating
 * @param decoration - this is what we are decorating it with
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
 *///from   w  ww  .  j  a  v  a 2s .  c o  m
public void decorate(Object object, IDecoration decoration) {
    IResource objectResource;

    // Get the resource using the adaptable mechanism. 
    objectResource = getResource(object);

    Vector decoratorImageKeys = new Vector();
    if (objectResource == null) {
        // The IResource object is null for all the members / member methods etc
        // for a java file in a package explorer. 
        return;
    }

    // Decorating a Project

    // The project should be decorated with DecoratorDemo text label. 
    if (objectResource.getType() == IResource.PROJECT) {
        // Projects should not be decorated
        return;
    }

    // Decorating a Folder
    if (objectResource.getType() == IResource.FOLDER) {
        // Folders should not be decorated..
        return;
    }

    try {
        // Resource properties have been changed. 

        // Find the decorator with which the image should be decorated
        decoratorImageKeys = SEURATResourcePropertiesManager.findDecorationImageForResource(objectResource);

        SEURATDecoratorManager.removeResource(objectResource);

        if (decoratorImageKeys.size() != 0) {
            decoration.addOverlay(SEURATImages.ratDescriptor);
        }
        return;
    } catch (Exception e) {
        Logger.logError(e);
    }
}