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.apache.directory.studio.schemaeditor.view.SchemaEditorTypeLabelDecorator.java

License:Apache License

/**
 * {@inheritDoc}//from  ww w .j  a  v  a2s.c  o  m
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof AttributeTypeWrapper) {
        UsageEnum usage = ((AttributeTypeWrapper) element).getAttributeType().getUsage();
        if (usage == UsageEnum.USER_APPLICATIONS) {
            decoration.addOverlay(
                    Activator.getDefault()
                            .getImageDescriptor(PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION),
                    IDecoration.BOTTOM_RIGHT);
        } else if ((usage == UsageEnum.DIRECTORY_OPERATION) || (usage == UsageEnum.DISTRIBUTED_OPERATION)
                || (usage == UsageEnum.DSA_OPERATION)) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION), IDecoration.BOTTOM_RIGHT);
        }
    } else if (element instanceof ObjectClassWrapper) {
        ObjectClassTypeEnum classType = ((ObjectClassWrapper) element).getObjectClass().getType();
        if (classType == ObjectClassTypeEnum.ABSTRACT) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT), IDecoration.BOTTOM_RIGHT);
        } else if (classType == ObjectClassTypeEnum.STRUCTURAL) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL), IDecoration.BOTTOM_RIGHT);
        } else if (classType == ObjectClassTypeEnum.AUXILIARY) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY), IDecoration.BOTTOM_RIGHT);
        }
    } else if (element instanceof AttributeType) {
        UsageEnum usage = ((AttributeType) element).getUsage();
        if (usage == UsageEnum.USER_APPLICATIONS) {
            decoration.addOverlay(
                    Activator.getDefault()
                            .getImageDescriptor(PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_USER_APPLICATION),
                    IDecoration.BOTTOM_RIGHT);
        } else if ((usage == UsageEnum.DIRECTORY_OPERATION) || (usage == UsageEnum.DISTRIBUTED_OPERATION)
                || (usage == UsageEnum.DSA_OPERATION)) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_ATTRIBUTE_TYPE_OVERLAY_OPERATION), IDecoration.BOTTOM_RIGHT);
        }
    } else if (element instanceof ObjectClass) {
        ObjectClassTypeEnum classType = ((ObjectClass) element).getType();
        if (classType == ObjectClassTypeEnum.ABSTRACT) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_ABSTRACT), IDecoration.BOTTOM_RIGHT);
        } else if (classType == ObjectClassTypeEnum.STRUCTURAL) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_STRUCTURAL), IDecoration.BOTTOM_RIGHT);
        } else if (classType == ObjectClassTypeEnum.AUXILIARY) {
            decoration.addOverlay(Activator.getDefault().getImageDescriptor(
                    PluginConstants.IMG_OBJECT_CLASS_OVERLAY_AUXILIARY), IDecoration.BOTTOM_RIGHT);
        }
    }
}

From source file:org.apache.hadoop.eclipse.ui.internal.hdfs.HDFSLightweightLabelDecorator.java

License:Apache License

protected void decorate(HDFSFileStore store, IDecoration decoration) {
    if (store != null) {
        if (store.isLocalFile())
            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_LOCAL_OVR,
                    IDecoration.BOTTOM_LEFT);
        else if (store.isRemoteFile())
            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_REMOTE_OVR,
                    IDecoration.BOTTOM_LEFT);
        if (store.isLocalOnly())
            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_OUTGOING_OVR,
                    IDecoration.BOTTOM_RIGHT);

        Permissions effectivePermissions = store.getEffectivePermissions();
        if (effectivePermissions != null && !effectivePermissions.read && !effectivePermissions.write)
            decoration.addOverlay(org.apache.hadoop.eclipse.ui.Activator.IMAGE_READONLY_OVR);
    }//from   w ww  .j  a  v  a2  s . co  m
}

From source file:org.apache.sling.ide.eclipse.ui.internal.JcrNodeDecorator.java

License:Apache License

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

    if (element instanceof JcrNode) {
        JcrNode node = (JcrNode) element;
        if (node.getPrimaryType() != null) {
            decoration.addSuffix(" [" + node.getPrimaryType() + "]");
        }/*from  w  w  w  .  j a  v a  2s  . co  m*/

        if (node instanceof SyncDir) {
            decoration.addOverlay(SharedImages.CONTENT_OVERLAY, IDecoration.BOTTOM_RIGHT);
        }
    }
}

From source file:org.apache.sling.ide.eclipse.ui.internal.SlingProjectDecorator.java

License:Apache License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof IProject)) {
        return;/*w w  w . ja  v a  2s  . c  o  m*/
    }
    IProject project = (IProject) element;
    if (ProjectHelper.isBundleProject(project) || ProjectHelper.isContentProject(project)) {
        // then decorate
        decoration.addOverlay(SharedImages.SLING_DECORATION, IDecoration.BOTTOM_RIGHT);
    } else {
        // dont decorate
        return;
    }
}

From source file:org.cloudfoundry.ide.eclipse.internal.server.ui.CloudFoundryDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof ModuleServer) {
        ModuleServer moduleServer = (ModuleServer) element;
        IServer s = moduleServer.getServer();
        if (s != null && isCloudFoundryServerType(s)) {
            IModule[] modules = moduleServer.getModule();
            if (modules != null && modules.length == 1) {
                CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
                if (server == null || !server.isConnected()) {
                    return;

                }/*from   w  ww.ja  v  a 2s . c  o m*/
                ApplicationModule module = server.getApplication(modules[0]);
                if (module.getLocalModule() != null) {
                    // show local information?
                }

                CloudApplication application = module.getApplication();
                // if (application != null) {
                // decoration.addSuffix(NLS.bind("  [{0}, {1}, {2}]",
                // new Object[]{application.getName(),
                // getAppStateString(application.getState()),
                // application.getUris()}));
                // } else if (module.getName() != null) {
                // decoration.addSuffix(NLS.bind("  [{0}]",
                // module.getName()));
                // }
                if (application != null) {
                    decoration.addSuffix(NLS.bind(" - Deployed as {0}", application.getName()));
                } else {
                    decoration.addSuffix(" - Not Deployed");
                }

                if (module.getErrorMessage() != null) {
                    decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
                }
            }
        }
    } else if (element instanceof Server) {
        Server server = (Server) element;
        if (isCloudFoundryServerType(server)) {
            CloudFoundryServer cfServer = getCloudFoundryServer(server);
            if (cfServer != null && cfServer.getUsername() != null) {
                // decoration.addSuffix(NLS.bind("  [{0}, {1}]",
                // cfServer.getUsername(), cfServer.getUrl()));
                List<CloudURL> cloudUrls = CloudUiUtil
                        .getAllUrls(cfServer.getBehaviour().getServer().getServerType().getId());
                String url = cfServer.getUrl();
                //               decoration.addSuffix(NLS.bind("  {0}", cfServer.getUsername()));
                for (CloudURL cloudUrl : cloudUrls) {
                    if (cloudUrl.getUrl().equals(url)) {
                        decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl()));
                        break;
                    }
                }
            }
        }
    }
}

From source file:org.cloudfoundry.ide.eclipse.server.ui.internal.CloudFoundryDecorator.java

License:Open Source License

public void decorate(Object element, final IDecoration decoration) {
    if (element instanceof ModuleServer) {
        ModuleServer moduleServer = (ModuleServer) element;
        IServer s = moduleServer.getServer();
        if (s != null && CloudServerUtil.isCloudFoundryServer(s)) {
            IModule[] modules = moduleServer.getModule();
            if (modules != null && modules.length == 1) {
                CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
                if (server == null || !server.isConnected()) {
                    return;

                }/*  w  w  w  .j av a 2  s.  co m*/
                CloudFoundryApplicationModule module = server.getExistingCloudModule(modules[0]);

                // module may no longer exist
                if (module == null) {
                    return;
                }

                if (module.getLocalModule() != null) {
                    // show local information?
                }

                CloudApplication application = module.getApplication();
                if (application != null) {
                    String deployedAppName = application.getName();
                    IModule localModule = module.getLocalModule();
                    // Only show "Deployed as" when the local module name does not match the deployed app name.
                    if (localModule != null && !localModule.getName().equals(deployedAppName)) {
                        decoration.addSuffix(
                                NLS.bind(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED_AS, deployedAppName));
                    } else {
                        decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED);
                    }
                } else {
                    decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_NOT_DEPLOYED);
                }

                if (module.getErrorMessage() != null) {
                    decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
                }
            }
        }
    } else if (element instanceof Server) {
        Server server = (Server) element;
        if (CloudServerUtil.isCloudFoundryServer(server)) {
            final CloudFoundryServer cfServer = getCloudFoundryServer(server);
            if (cfServer != null && cfServer.getUsername() != null) {
                // This now runs on a non UI thread, so we need to join this
                // update to a UI thread.
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        // decoration.addSuffix(NLS.bind("  [{0}, {1}]",
                        // cfServer.getUsername(), cfServer.getUrl()));
                        if (cfServer.hasCloudSpace()) {
                            CloudFoundrySpace clSpace = cfServer.getCloudFoundrySpace();
                            if (clSpace != null) {
                                decoration.addSuffix(
                                        NLS.bind(" - {0} - {1}", clSpace.getOrgName(), clSpace.getSpaceName())); //$NON-NLS-1$
                            }
                        }
                        try {
                            List<AbstractCloudFoundryUrl> cloudUrls = CloudServerUIUtil.getAllUrls(
                                    cfServer.getBehaviour().getServer().getServerType().getId(), null);
                            String url = cfServer.getUrl();
                            // decoration.addSuffix(NLS.bind("  {0}",
                            // cfServer.getUsername()));
                            for (AbstractCloudFoundryUrl cloudUrl : cloudUrls) {
                                if (cloudUrl.getUrl().equals(url)) {
                                    decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$
                                    break;
                                }
                            }
                        } catch (CoreException e) {
                            CloudFoundryServerUiPlugin.logError(e);
                        }
                    }
                });
            }
        }
    }
}

From source file:org.codehaus.groovy.eclipse.ui.decorators.GroovyElementDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IAdaptable) {
        IMember member = (IMember) ((IAdaptable) element).getAdapter(IMember.class);
        if (member != null) {
            try {
                ICompilationUnit unit = member.getCompilationUnit();
                if (unit != null) {
                    IResource resource = unit.getResource();
                    if (resource != null && ContentTypeUtils.isGroovyLikeFileName(resource.getName())) {
                        decoration.addOverlay(GroovyPluginImages.DESC_GROOVY_OVERLAY, IDecoration.BOTTOM_RIGHT);
                    }//  w  ww  . j  av a2 s. c o  m
                }
            } catch (Exception e) {
                // ignore???
            }
        }
    }
}

From source file:org.cs3.pdt.navigator.internal.decorators.PDTConsultDecoratorContributor.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof IFile) && !(element instanceof IFolder)) {
        return;//w w w .  j  a v  a  2 s  . c  om
    }

    try {
        // get active pif from console
        PrologInterface currentPif = PDTCommonUtil.getActivePrologInterface();

        if (currentPif == null) {
            if (element instanceof IFile) {
                decoration.addOverlay(
                        ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_UNCONSULTED),
                        IDecoration.UNDERLAY);
            }
            return;
        }

        if (element instanceof IFile) {
            IFile file = (IFile) element;

            //         final DecorationContext decorationContext = (DecorationContext) decoration.getDecorationContext();
            //         decorationContext.putProperty(IDecoration.ENABLE_REPLACE, Boolean.TRUE);

            // check if file is in consulted files list (important for qlf files)
            String prologFileName = getPrologFileName(file);

            // XXX: don't mark qlf file if only the pl file is consulted 
            if (prologFileName.endsWith(".qlf")) {
                prologFileName = prologFileName.substring(0, prologFileName.length() - 3) + "pl";
            }
            // check if file is source_file
            if (isCurrent(prologFileName)) {
                decoration.addSuffix(" [consulted]");
                if (file.getFileExtension().equalsIgnoreCase("QLF")) {
                    decoration.addOverlay(
                            ImageRepository.getImageDescriptor(ImageRepository.QLF_FILE_CONSULTED),
                            IDecoration.BOTTOM_LEFT);
                } else {
                    decoration.addOverlay(
                            ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_CONSULTED),
                            IDecoration.UNDERLAY);
                }
            } else if (isOld(prologFileName)) {
                decoration.addSuffix(" [consulted]");
                if (file.getFileExtension().equalsIgnoreCase("QLF")) {
                    decoration.addOverlay(
                            ImageRepository.getImageDescriptor(ImageRepository.QLF_FILE_CONSULTED_OLD),
                            IDecoration.BOTTOM_LEFT);
                } else {
                    decoration.addOverlay(
                            ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_CONSULTED_OLD),
                            IDecoration.UNDERLAY);
                }
            } else {
                decoration.addOverlay(
                        ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FILE_UNCONSULTED),
                        IDecoration.UNDERLAY);
            }
        } else {
            IFolder folder = (IFolder) element;
            String dirName = Util.prologFileName(folder.getRawLocation().toFile());

            if (isContainingFolder(dirName)) {
                decoration.addOverlay(
                        ImageRepository.getImageDescriptor(ImageRepository.PROLOG_FOLDER_CONSULTED),
                        IDecoration.TOP_LEFT);
            }
        }
    } catch (Exception e) {
        Debug.error("Error during decoration of " + (element == null ? null : element.toString()));
        Debug.report(e);
    }

}

From source file:org.eclipse.ajdt.internal.ui.lazystart.AdviceImageDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    // add the orange triangle to the icon if this method, 
    // class or aspect is advised
    if ((element instanceof IMethod || element instanceof SourceType)) {
        IJavaElement je = (IJavaElement) element;
        IJavaProject jp = je.getJavaProject();
        // only query the model if the element is in an AJ project
        if ((jp != null) && Utils.isAJProject(jp.getProject()) && !(je instanceof AspectJMemberElement)) {
            if (AJProjectModelFactory.getInstance().getModelForJavaElement(je).isAdvised(je)) {
                ensureAdviceListenerIsRegistered();
                // causes bundle activation
                AspectJUIPlugin.getDefault();
                decoration.addOverlay(AspectJImages.ADVICE_OVERLAY.getImageDescriptor(), IDecoration.TOP_LEFT);
            }/*from  ww  w .j  a  va2 s.  c o  m*/
        }
    }
}

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

License:Open Source License

/**
 * Adds the linked resource overlay if the given element is a linked
 * resource.//from   w  w  w .  j ava  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)
 */
@Override
public void decorate(Object element, IDecoration decoration) {
    IIndexFileLocation ifl = null;
    IProject project = null;
    if (element instanceof IFile) {
        final IFile file = (IFile) element;
        ifl = IndexLocationFactory.getWorkspaceIFL(file);
        project = file.getProject();
    } else if (element instanceof ITranslationUnit) {
        final ITranslationUnit tu = (ITranslationUnit) element;
        ifl = IndexLocationFactory.getIFL(tu);
        project = tu.getCProject().getProject();
    }
    if (isIndexed(project, ifl)) {
        decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
    }
}