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.cdt.internal.ui.viewsupport.ExcludedFileDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFile || element instanceof IFolder) {
        IResource resource = (IResource) element;
        ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
        ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(),
                ICProjectDescriptionManager.GET_IF_LOADDED);
        if (desc == null)
            return;
        ICConfigurationDescription conf = desc.getDefaultSettingConfiguration();
        ICSourceEntry[] entries = conf.getSourceEntries();
        boolean isUnderSourceRoot = false;
        IPath fullPath = resource.getFullPath();
        for (ICSourceEntry icSourceEntry : entries) {
            if (icSourceEntry.getFullPath().isPrefixOf(fullPath)) {
                isUnderSourceRoot = true;
                break;
            }//from   w  w  w .j av  a2 s. c  o  m
        }
        // Only bother to mark items that would be included otherwise
        if (isUnderSourceRoot && CDataUtil.isExcluded(fullPath, entries)) {
            decoration.addOverlay(CPluginImages.DESC_OVR_INACTIVE);
            decoration.setForegroundColor(
                    JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
        }
    }
}

From source file:org.eclipse.cdt.internal.ui.viewsupport.IncludeFolderDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    boolean isAccesible = true;

    if (element instanceof IncludeReferenceProxy) {
        IIncludeReference reference = ((IncludeReferenceProxy) element).getReference();
        IPath path = reference.getPath();
        IContainer container = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(path);
        if (container != null) {
            isAccesible = container.isAccessible();
        } else {//from   w  w w  .  j a va  2  s  .c om
            isAccesible = path.toFile().exists();
        }
    } else if (element instanceof IIncludeReference) {
        IPath path = ((IIncludeReference) element).getPath();
        isAccesible = path.toFile().exists();
    }

    if (!isAccesible) {
        decoration.addOverlay(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OVR_WARNING));
        // JFacePreferences.QUALIFIER_COLOR colors label in gray
        decoration.setForegroundColor(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));
    }
}

From source file:org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    int adornmentFlags = computeAdornmentFlags(element);

    if (adornmentFlags == ERRORTICK_ERROR) {
        decoration.addOverlay(CPluginImages.DESC_OVR_ERROR);
    } else if (adornmentFlags == ERRORTICK_WARNING) {
        decoration.addOverlay(CPluginImages.DESC_OVR_WARNING);
    }//ww  w . j  av  a2  s. c  om
}

From source file:org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.providers.decorators.impl.BookmarkDecorationService.java

License:Open Source License

/**
  * Will decorate the element with the bookmark icon
  *///from   www.  j  av a  2  s .  c o  m
public void decorate(Object element, IDecoration decoration) {
    if (hasBookmark(element)) {
        decoration.addOverlay(ImageDescription.getBookmarkDescriptor());
    }
}

From source file:org.eclipse.datatools.connectivity.sqm.core.internal.ui.explorer.providers.decorators.impl.ColumnDecorationService.java

License:Open Source License

private void decorate(Column column, IDecoration decoration) {
    boolean pk = column.isPartOfPrimaryKey();
    boolean fk = column.isPartOfForeignKey();
    boolean nullable = column.isNullable();
    String dataType = IDataToolsUIServiceManager.INSTANCE.getColumnHelperService().getDataType(column);

    if (fk && pk) {
        decoration.addSuffix(ColumnDecoratorUtil.getPKFKColumnDecoration(dataType));
        decoration.addOverlay(ImageDescription.getPKFKDecorationDescriptor());
    } else if (fk && nullable) {
        decoration.addSuffix(ColumnDecoratorUtil.getFKNullableColumnDecoration(dataType));
        decoration.addOverlay(ImageDescription.getFKDecorationDescriptor());
    } else if (fk) {
        decoration.addSuffix(ColumnDecoratorUtil.getFKColumnDecoration(dataType));
        decoration.addOverlay(ImageDescription.getFKDecorationDescriptor());
    } else if (pk) {
        decoration.addSuffix(ColumnDecoratorUtil.getPKColumnDecoration(dataType));
        decoration.addOverlay(ImageDescription.getPKDecorationDescriptor());
    } else if (nullable) {
        decoration.addSuffix(ColumnDecoratorUtil.getNullableColumnDecoration(dataType));
    } else {//from  ww w.j  a  v a 2  s .c  o m
        decoration.addSuffix(ColumnDecoratorUtil.getColumnDecoration(dataType));
    }
}

From source file:org.eclipse.datatools.enablement.sybase.ase.internal.ui.decorator.ProxyTableDecorationService.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {

    /**//  w  w w . jav  a  2  s  . c om
      * ASE has four kinds of proxy table. Each proxy table has a special icon,
      */
    if (element instanceof SybaseASEProxyTable && !(element instanceof SybaseASEWebServiceTable)) {
        SybaseASEProxyTable table = (SybaseASEProxyTable) element;
        decoration.addSuffix(" [" + table.getExternalPath() + "]");
        switch (table.getExternalType().getValue()) {
        case ProxyTableExternalType.FILE:
            decoration.addOverlay(ASEImages.DESC_FILEPROXYTABLE);
            break;
        case ProxyTableExternalType.DIRECTORY:
            decoration.addOverlay(ASEImages.DESC_DIRPROXYTABLE);
            break;
        case ProxyTableExternalType.PROCEDURE:
            decoration.addOverlay(ASEImages.DESC_RPCPROXYTABLE);
            break;
        case ProxyTableExternalType.TABLE:
            decoration.addOverlay(ASEImages.DESC_REMOTETABLE);
            break;
        }
    }
}

From source file:org.eclipse.datatools.enablement.sybase.ui.SystemTableDecorationService.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {

    if (element instanceof SybaseBaseTable && (((SybaseBaseTable) element).isSystem())) {
        decoration.addOverlay(SybaseImages.DESC_SYSTEMTABLE);
    }/*from   w  w  w. j  ava2 s . c o m*/
}

From source file:org.eclipse.dltk.mod.ui.ProblemsLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    int adornmentFlags = computeAdornmentFlags(element);
    if (adornmentFlags == ERRORTICK_ERROR) {
        decoration.addOverlay(DLTKPluginImages.DESC_OVR_ERROR);
    } else if (adornmentFlags == ERRORTICK_WARNING) {
        decoration.addOverlay(DLTKPluginImages.DESC_OVR_WARNING);
    }/*from  ww  w.  j  a  v a2  s .co  m*/
}

From source file:org.eclipse.edt.ide.ui.internal.packageexplorer.EGLProjectDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    try {//from   w  w w  .j a  va2  s.c  o  m
        if (element instanceof IProject) {
            IProject project = (IProject) element;
            if (project.hasNature(EGLCore.NATURE_ID)) {
                decoration.addOverlay(PluginImages.DESC_OVR_EGL);
                IEGLProject eglProject = EGLCore.create(project);
                if (eglProject.isBinary()) {
                    decoration.addOverlay(PluginImages.DESC_OBJS_EGL_BINARY_PROJECT_OPEN);
                }
            }
        }
    } catch (CoreException e) {
        EGLLogger.log(this, e);
    }
}

From source file:org.eclipse.emf.ecoretools.legacy.diagram.ui.outline.decorator.AbstractValidationMarkerDecorator.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 . c  o  m*/
public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof EObject)) {
        return;
    }

    EObject object = (EObject) element;

    if (object.eResource() != null) {
        IStatus status = getMarkerReader().getStatus(object);
        if (status.matches(IStatus.ERROR)) {
            decoration.addOverlay(getErrorImageDescriptor());
        } else if (status.matches(IStatus.WARNING)) {
            decoration.addOverlay(getWarningImageDescriptor());
        }
    }
}