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:org.eclipse.jubula.client.ui.rcp.provider.labelprovider.decorators.CompletenessDecorator.java

License:Open Source License

/** {@inheritDoc} */
public void decorate(Object element, IDecoration decoration) {
    final INodePO node = (INodePO) element;
    IProblem worstProblem = ProblemFactory.getWorstProblem(node.getProblems());
    if (worstProblem != null) {
        switch (worstProblem.getStatus().getSeverity()) {
        case IStatus.WARNING:
            decoration.addOverlay(IconConstants.WARNING_IMAGE_DESCRIPTOR);
            break;
        case IStatus.ERROR:
            decoration.addOverlay(IconConstants.ERROR_IMAGE_DESCRIPTOR);
            break;
        default://from   w  w  w. ja  va2 s .c o m
            break;
        }
    }
}

From source file:org.eclipse.jubula.client.ui.rcp.provider.labelprovider.decorators.CompNameDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    IComponentNamePO cN = (IComponentNamePO) element;
    if (cN.getTypeProblem() != null) {
        decoration.addOverlay(IconConstants.ERROR_IMAGE_DESCRIPTOR);
    }/*from  w  ww .java 2s.  co m*/
}

From source file:org.eclipse.jubula.client.ui.rcp.provider.labelprovider.decorators.ExternalDataDecorator.java

License:Open Source License

/**
 * {@inheritDoc}//from w w w.  j  av  a2 s.com
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IParamNodePO) {
        IParamNodePO pnpo = (IParamNodePO) element;
        if (!StringUtils.isEmpty(pnpo.getDataFile())) {
            decoration.addOverlay(IconConstants.EXCEL_DATA_IMAGE_DESCRIPTOR);
        } else if (pnpo.getReferencedDataCube() != null) {
            decoration.addOverlay(IconConstants.TDC_DECORATION_IMAGE_DESCRIPTOR);
        }
    }
}

From source file:org.eclipse.jubula.client.ui.rcp.provider.labelprovider.decorators.MissingReferenceDecorator.java

License:Open Source License

/**
 * {@inheritDoc}/*from   w  ww .j av a  2 s. c o  m*/
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IReusedProjectPO) {
        Long projID;
        IReusedProjectPO rProj = (IReusedProjectPO) element;
        try {
            projID = ProjectPM.findProjectId(rProj.getProjectGuid(), rProj.getMajorNumber(),
                    rProj.getMinorNumber(), rProj.getMicroNumber(), rProj.getVersionQualifier());
        } catch (JBException e) {
            projID = null;
        }
        if (projID == null) {
            decoration.addOverlay(IconConstants.ERROR_IMAGE_DESCRIPTOR);
        }
    }
}

From source file:org.eclipse.pde.emfforms.internal.validation.EmfValidatorLabelDecorator.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *      org.eclipse.jface.viewers.IDecoration)
 *//*w ww. j  ava2s.c  o  m*/
public void decorate(Object element, 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 {
        object = (EObject) AdapterFactoryEditingDomain.unwrap(element);
    }

    Diagnostic validate = Diagnostician.INSTANCE.validate(object);

    if (validate.getSeverity() == Diagnostic.ERROR) {
        decoration.addOverlay(getErrorImageDescriptor());
    } else if (validate.getSeverity() == Diagnostic.WARNING) {
        decoration.addOverlay(getWarningImageDescriptor());
    }
}

From source file:org.eclipse.rcptt.ui.navigator.ProblemsLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IResource) {
        int adornmentFlags;
        try {/*  ww w  . j a v a  2 s  .  c  o m*/
            adornmentFlags = getErrorTicksFromMarkers((IResource) element, IResource.DEPTH_INFINITE);
            if (adornmentFlags == IMarker.SEVERITY_ERROR) {
                decoration.addOverlay(Images.getImageDescriptor(Images.OVERLAY_ERROR));
            } else if (adornmentFlags == IMarker.SEVERITY_WARNING) {
                decoration.addOverlay(Images.getImageDescriptor(Images.OVERLAY_WARNING));
            }
        } catch (CoreException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.eclipse.team.internal.ccvs.ui.CVSDecoration.java

License:Open Source License

public void apply(IDecoration decoration) {
    compute();//from  w  w w  . j av  a 2s .c o  m
    // apply changes
    String suffix = getSuffix();
    if (suffix != null)
        decoration.addSuffix(suffix);
    String prefix = getPrefix();
    if (prefix != null)
        decoration.addPrefix(prefix);
    ImageDescriptor overlay = getOverlay();
    if (overlay != null)
        decoration.addOverlay(overlay);
    Color bc = getBackgroundColor();
    if (bc != null)
        decoration.setBackgroundColor(bc);
    Color fc = getForegroundColor();
    if (fc != null)
        decoration.setForegroundColor(fc);
    Font f = getFont();
    if (f != null)
        decoration.setFont(f);
}

From source file:org.eclipse.team.svn.ui.decorator.SVNLightweightDecorator.java

License:Open Source License

protected void decorateModel(Object element, IDecoration decoration, SynchronizationStateTester tester)
        throws CoreException {
    //TODO how to limit depth according to "Compute deep outgoing state" properties ?
    int stateFlags = tester.getState(element, IDiff.ADD | IDiff.REMOVE | IDiff.CHANGE | IThreeWayDiff.OUTGOING,
            new NullProgressMonitor());
    if (this.indicateRemote) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED);
    }//ww w  .j av a  2 s  .  c  o  m
    if ((stateFlags & IThreeWayDiff.OUTGOING) != 0) {
        decoration.addPrefix(this.outgoingChars != null ? (this.outgoingChars + " ") : ""); //$NON-NLS-1$ //$NON-NLS-2$
    }
    tester.elementDecorated(element, new TeamStateDescription(stateFlags));
}

From source file:org.eclipse.team.svn.ui.decorator.SVNLightweightDecorator.java

License:Open Source License

protected void decorateResourceImpl(final IRepositoryResource remote, final ILocalResource local,
        final IResource resource, final String state, final int mask, IDecoration decoration) {
    if (IStateFilter.SF_TREE_CONFLICTING.accept(resource, state, mask) && this.indicateConflicted) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_CONFLICTED);
    } else if (local.isLocked() && this.indicateLocked) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_LOCKED);
    } else if (IStateFilter.SF_IGNORED.accept(resource, state, mask)) {
        if (this.useFonts) {
            decoration.setBackgroundColor(this.ignoredBackgroundColor);
            decoration.setForegroundColor(this.ignoredForegroundColor);
            decoration.setFont(this.ignoredFont);
        }/*ww  w.j av  a2s.  c om*/
    } else if (IStateFilter.SF_NEW.accept(resource, state, mask)) {
        if (this.indicateNew) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_NEW);
        }
    } else if (this.indicateNeedsLock && IStateFilter.SF_NEEDS_LOCK.accept(resource, state, mask)) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_NEEDS_LOCK);
    } else if (IStateFilter.SF_ADDED.accept(resource, state, mask)) {
        //new state also recognized as added, then it should be before added
        if (this.indicateAdded) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_ADDED);
        }
    } else if (this.indicateDeleted(resource) && IStateFilter.SF_DELETED.accept(resource, state, mask)) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_DELETED);
    } else if (IStateFilter.SF_CONFLICTING.accept(resource, state, mask)) {
        if (this.indicateConflicted) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_CONFLICTED);
        } else if (this.indicateModified) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_MODIFIED);
        } else if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED);
        } else if (this.indicateRemote) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED);
        }
    } else if (IStateFilter.SF_MODIFIED.accept(resource, state, mask)) {
        if (this.indicateModified) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_MODIFIED);
        } else if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED);
        } else if (this.indicateRemote) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED);
        }
    } else if (IStateFilter.SF_OBSTRUCTED.accept(resource, state, mask)) {
        decoration.addOverlay(SVNLightweightDecorator.OVR_OBSTRUCTED);
    } else if (IStateFilter.SF_VERSIONED.accept(resource, state, mask)) {
        if (this.indicateSwitched && (local.getChangeMask() & ILocalResource.IS_SWITCHED) != 0) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_SWITCHED);
        } else if (this.indicateRemote) {
            decoration.addOverlay(SVNLightweightDecorator.OVR_VERSIONED);
        }
    }
    if (this.useFonts && IStateFilter.SF_ANY_CHANGE.accept(resource, state, mask)) {
        decoration.setBackgroundColor(this.changedBackgroundColor);
        decoration.setForegroundColor(this.changedForegroundColor);
        decoration.setFont(this.changedFont);
    }

    this.decorator.decorateText(decoration, this.getFormat(resource), new IVariableContentProvider() {
        public String getValue(IVariable var) {
            if (var.equals(TextVariableSetProvider.VAR_ADDED_FLAG)) {
                return IStateFilter.SF_ADDED.accept(resource, state, mask)
                        ? SVNLightweightDecorator.this.addedChars
                        : ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_OUTGOING_FLAG)) {
                return (IStateFilter.SF_COMMITABLE.accept(resource, state, mask)
                        || IStateFilter.SF_CONFLICTING.accept(resource, state, mask)
                        || IStateFilter.SF_TREE_CONFLICTING.accept(resource, state, mask))
                                ? SVNLightweightDecorator.this.outgoingChars
                                : ""; //$NON-NLS-1$
            }

            if (var.equals(TextVariableSetProvider.VAR_REVISION)) {
                return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)
                        && !IStateFilter.SF_PREREPLACEDREPLACED.accept(resource, state, mask)
                                ? String.valueOf(local.getRevision())
                                : ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_AUTHOR)) {
                String author = local.getAuthor() == null ? "[no author]" : local.getAuthor(); //$NON-NLS-1$
                return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? author : ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_DATE)) {
                if (!IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    return ""; //$NON-NLS-1$
                }
                long date = local.getLastCommitDate();
                if (date == 0) {
                    return SVNMessages.SVNInfo_NoDate;
                }
                return DateFormatter.formatDate(date);
            } else if (var.equals(TextVariableSetProvider.VAR_RESOURCE_URL)) {
                return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)
                        ? SVNUtility.decodeURL(remote.getUrl())
                        : ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_SHORT_RESOURCE_URL)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    String shortURL = SVNUtility.decodeURL(remote.getUrl())
                            .substring(remote.getRepositoryLocation().getRepositoryRootUrl().length());
                    return shortURL.startsWith("/") ? shortURL.substring(1) : shortURL; //$NON-NLS-1$
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_LOCATION_URL)) {
                return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)
                        ? remote.getRepositoryLocation().getUrlAsIs()
                        : ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_LOCATION_LABEL)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    IRepositoryLocation location = remote.getRepositoryLocation();
                    String label = location.getLabel();
                    return label == null || label.length() == 0 ? location.getUrlAsIs() : label;
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_ROOT_PREFIX)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    int kind = ((IRepositoryRoot) remote.getRoot()).getKind();
                    return kind == IRepositoryRoot.KIND_TAGS ? SVNLightweightDecorator.this.tagPrefix
                            : (kind == IRepositoryRoot.KIND_BRANCHES ? SVNLightweightDecorator.this.branchPrefix
                                    : (kind == IRepositoryRoot.KIND_TRUNK
                                            ? SVNLightweightDecorator.this.trunkPrefix
                                            : "" //$NON-NLS-1$
                    ));
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_ASCENDANT)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    return SVNUtility.getAscendant(remote);
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_DESCENDANT)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    return SVNUtility.getDescendant(remote);
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_FULLNAME)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    return SVNUtility.getPathUpToRoot(remote);
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_FULLPATH)) {
                if (IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask)) {
                    String retVal = SVNUtility.getPathUpToRoot(remote);
                    int pos = retVal.lastIndexOf('/');
                    if (pos != -1) {
                        retVal = retVal.substring(0, pos);
                    }
                    return retVal;
                }
                return ""; //$NON-NLS-1$
            } else if (var.equals(TextVariableSetProvider.VAR_REMOTE_NAME)) {
                return IStateFilter.SF_ONREPOSITORY.accept(resource, state, mask) ? remote.getName() : ""; //$NON-NLS-1$
            }
            if (var.equals(TextVariableSetProvider.VAR_NAME)) {
                return local.getName();
            }
            return var.toString();
        }
    });
}

From source file:org.eclipse.ui.internal.decorators.DeclarativeDecorator.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *      org.eclipse.jface.viewers.IDecoration)
 *//*from  ww w  .  j  a v  a 2  s  . c  o  m*/
public void decorate(Object element, IDecoration decoration) {
    if (descriptor == null) {
        URL url = BundleUtility.find(configElement.getDeclaringExtension().getNamespace(), iconLocation);
        if (url == null) {
            return;
        }
        descriptor = ImageDescriptor.createFromURL(url);
    }
    decoration.addOverlay(descriptor);
}