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:ch.elexis.core.ui.contacts.decorator.ContactTypeDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    IContact contact = (IContact) element;
    if (contact.isDeleted()) {
        ImageDescriptor deleted = Images.IMG_DELETE.getImageDescriptor();
        decoration.addOverlay(deleted, IDecoration.TOP_LEFT);
    }/* www.  j a  v a 2s  .  c  om*/

    if (contact.isMandator()) {
        ImageDescriptor vip = Images.IMG_VIP_OVERLAY.getImageDescriptor();
        decoration.addOverlay(vip, IDecoration.BOTTOM_RIGHT);
    }
    if (contact.isUser()) {
        FieldDecoration info = FieldDecorationRegistry.getDefault()
                .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
        ImageDescriptor infoD = ImageDescriptor.createFromImage(info.getImage());
        decoration.addOverlay(infoD, IDecoration.BOTTOM_LEFT);
    }
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.DockerFoundryDecorator.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 && CloudServerUtil.isCloudFoundryServer(s)) {
            IModule[] modules = moduleServer.getModule();
            if (modules != null && modules.length == 1) {
                DockerFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
                if (server == null || !server.isConnected()) {
                    return;

                }//from   w  w  w  .j  a v a2 s .  c  o m
                DockerFoundryApplicationModule 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) {
                // 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(Messages.DockerFoundryDecorator_SUFFIX_DEPLOYED_AS,
                            application.getName()));
                } else {
                    //                  decoration.addSuffix(Messages.DockerFoundryDecorator_SUFFIX_NOT_DEPLOYED);
                }

                if (module.getErrorMessage() != null) {
                    decoration.addOverlay(DockerFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
                }
            }
        }
    } else if (element instanceof Server) {
        Server server = (Server) element;
        if (CloudServerUtil.isCloudFoundryServer(server)) {
            DockerFoundryServer cfServer = getCloudFoundryServer(server);
            if (cfServer != null && cfServer.getUsername() != null) {
                // 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$
                //
                //                  }
                //               }
                List<CloudServerURL> cloudUrls = CloudUiUtil
                        .getAllUrls(cfServer.getBehaviour().getServer().getServerType().getId());
                String url = cfServer.getUrl();
                // decoration.addSuffix(NLS.bind("  {0}",
                // cfServer.getUsername()));
                for (CloudServerURL cloudUrl : cloudUrls) {
                    if (cloudUrl.getUrl().equals(url)) {
                        decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$
                        break;
                    }
                }
            }
        }
    }
}

From source file:com.android.ide.eclipse.adt.internal.project.FolderDecorator.java

License:Open Source License

public void doDecoration(IDecoration decoration, String suffix) {
    decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT);

    if (suffix != null) {
        decoration.addSuffix(suffix);/*from  ww w.  j  a va  2s .c  o  m*/
    }
}

From source file:com.android.ide.eclipse.adt.project.FolderDecorator.java

License:Open Source License

public void doDecoration(IDecoration decoration, String suffix) {
    decoration.addOverlay(mDescriptor, IDecoration.TOP_LEFT);

    if (suffix != null) {
        decoration.addSuffix(suffix);//from www .java  2s.  c o m

        // this is broken as it changes the color of the whole text, not only of the decoration.
        // TODO: figure out how to change the color of the decoration only.
        //            ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
        //            ColorRegistry registry = theme.getColorRegistry();
        //            decoration.setForegroundColor(
        //                    registry.get("org.eclipse.jdt.ui.ColoredLabels.decorations")); //$NON-NLS-1$
    }

}

From source file:com.arm.cmsis.pack.project.ui.RteProjectDecorator.java

License:Open Source License

private void addOverlay(IDecoration decoration, String iconFile) {
    ImageDescriptor descriptor = CpPlugInUI.getImageDescriptor(iconFile);
    if (descriptor == null)
        return;/* w w  w. j  a va2 s.c  o  m*/
    decoration.addOverlay(descriptor, IDecoration.TOP_LEFT);
}

From source file:com.bb.extensions.plugin.unittests.internal.navigator.decorators.MocksUpdateDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof MocksUnitTestsNavigatorElement) {
        MocksUnitTestsNavigatorElement mocksElement = (MocksUnitTestsNavigatorElement) element;
        if (mocksElement.isUpToDate() == false) {
            AbstractUIPlugin plugin = Activator.getDefault();
            ImageRegistry imageRegistry = plugin.getImageRegistry();
            ImageDescriptor outOfDateImageDescriptor = imageRegistry.getDescriptor(Activator.outOfDateImageId);

            decoration.addOverlay(outOfDateImageDescriptor, IDecoration.TOP_LEFT);
        }//from ww  w.  java2s  . c  o  m
    }
}

From source file:com.centimia.orm.jaqu.plugin.decorator.ResourceDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFile) {
        String isJaqu = Activator.getDefault().getPreferenceStore()
                .getString(((IFile) element).getProject().getName() + "_" + ((IFile) element).getName());
        if (!"".equals(isJaqu)) {
            ((DecorationContext) decoration.getDecorationContext()).putProperty(IDecoration.ENABLE_REPLACE,
                    Boolean.TRUE);
            decoration.addOverlay(getFileImageDescriptor(), IDecoration.TOP_LEFT);
        }/*  w w  w . j a v  a  2  s  .co  m*/
    }
}

From source file:com.google.dart.tools.ui.internal.filesview.FilesViewLightweightDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFileStore) {
        IFileStore fileStore = (IFileStore) element;

        if (fileStore.fetchInfo().getAttribute(EFS.ATTRIBUTE_READ_ONLY)) {
            decoration.addOverlay(DESC_READ_ONLY, IDecoration.BOTTOM_RIGHT);
        }/*from ww  w. j  av a2s  .  c o m*/
    } else if (element instanceof IFile) {
        IFile file = (IFile) element;

        try {
            DartElement dartElement = DartCore.create(file);

            if (dartElement != null) {
                if (file.equals(dartElement.getDartProject().getCorrespondingResource())) {
                    decoration.addOverlay(DESC_READ_ONLY, IDecoration.BOTTOM_RIGHT);
                }
            }
        } catch (CoreException exception) {
            //ignore
        }
    }
}

From source file:com.google.dart.tools.ui.internal.libraryview.DartLightweightDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IProject) {
        // IProject case:
        int maxSeverity = getProjectMaxSeverity((IProject) element);
        ImageDescriptor overlayImageDescriptor = getDecorationForSeverity(maxSeverity);
        if (overlayImageDescriptor != null) {
            decoration.addOverlay(overlayImageDescriptor, IDecoration.BOTTOM_LEFT);
        }// ww w . j ava  2  s . co m
    } else if (element instanceof IFile) {
        // IFile case:
        IFile file = (IFile) element;
        if (isDartProject(file.getProject())) {
            ImageDescriptor overlayImageDescriptor = getDecorationForResource(file);

            if (overlayImageDescriptor != null) {
                decoration.addOverlay(overlayImageDescriptor, IDecoration.BOTTOM_LEFT);
            }
        }
    } else if (element instanceof DartElement) {
        // DartElement case:
        DartElement dartElement = (DartElement) element;
        try {
            if (dartElement.getElementType() == DartElement.LIBRARY) {
                // DartElement, DartLibrary case:
                int maxSeverity = getLibraryMaxSeverity((DartLibrary) dartElement);
                ImageDescriptor overlayImageDescriptor = getDecorationForSeverity(maxSeverity);
                if (overlayImageDescriptor != null) {
                    decoration.addOverlay(overlayImageDescriptor, IDecoration.BOTTOM_LEFT);
                }
            } else {
                // DartElement, non-DartLibrary case:
                IResource resource = dartElement.getCorrespondingResource();
                if (resource != null) {
                    ImageDescriptor overlayImageDescriptor = getDecorationForResource(resource);
                    if (overlayImageDescriptor != null) {
                        decoration.addOverlay(overlayImageDescriptor, IDecoration.BOTTOM_LEFT);
                    }
                }
            }
        } catch (DartModelException dme) {
            // ignore
        }
    }
}

From source file:com.google.gdt.eclipse.managedapis.ui.ManageApiInfoDecorator.java

License:Open Source License

private void applyUpdateAvailableDecoration(IDecoration decoration) throws MalformedURLException {
    decoration.addSuffix(" [Update available]");
    ImageDescriptor overlay = resources.getUpdateAvailableOverlay16ImageDescriptor();
    decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
}