Example usage for org.eclipse.jface.viewers IDecoration addSuffix

List of usage examples for org.eclipse.jface.viewers IDecoration addSuffix

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IDecoration addSuffix.

Prototype

void addSuffix(String suffix);

Source Link

Document

Adds a suffix to the element's label.

Usage

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

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    IResource resource = ProjectUtils.getRteResource(element);
    if (resource == null)
        return;//  www  .ja va  2s  .  com
    int type = resource.getType();
    if (type != IResource.FOLDER && type != IResource.FILE)
        return;

    IPath path = resource.getProjectRelativePath();
    IProject project = resource.getProject();
    RteProjectManager rteProjectManager = CpProjectPlugIn.getRteProjectManager();
    IRteProject rteProject = rteProjectManager.getRteProject(project);

    if (type == IResource.FOLDER || resource.getFileExtension().equals(CmsisConstants.RTECONFIG)) {
        if (path.segmentCount() == 1) { // RTE folder itself 
            IRteConfiguration rteConf = rteProject != null ? rteProject.getRteConfiguration() : null;
            if (rteConf == null || !rteConf.isValid())
                addOverlay(decoration, CpPlugInUI.ICON_RTE_ERROR_OVR);
            else if (type == IResource.FOLDER)
                addOverlay(decoration, CpPlugInUI.ICON_RTE_OVR);
        }
    }

    if (rteProject != null && type == IResource.FILE) {
        ICpFileInfo fi = rteProject.getProjectFileInfo(path.toString());
        if (fi != null) {
            ICpComponentInfo ci = fi.getComponentInfo();
            String suffix = " [" + ci.getName() + "]"; //$NON-NLS-1$//$NON-NLS-2$
            decoration.addSuffix(suffix);
            if (ci.getComponent() == null)
                addOverlay(decoration, CpPlugInUI.ICON_RTE_ERROR_OVR);
            return;
        }
    }
}

From source file:com.codenvy.eclipse.ui.team.CodenvyLightweightLabelDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    final IResource resource = ResourceUtil.getResource(element);

    if (resource != null && resource.getType() != ROOT) {
        final CodenvyProvider provider = (CodenvyProvider) getProvider(resource.getProject(),
                CodenvyProvider.PROVIDER_ID);

        if (provider != null) {
            final CodenvyMetaResource metaResource = (CodenvyMetaResource) getAdapter(resource,
                    CodenvyMetaResource.class, true);

            if (metaResource != null && metaResource.isTracked()) {
                decoration.addOverlay(trackedImageDescriptor);

                if (resource.getType() == PROJECT) {
                    decoration.addSuffix(" [codenvy: " + provider.getProjectMetadata().url + "]");
                }/*from www.ja  va2s. c  o m*/
            }
        }
    }
}

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

From source file:com.hudren.woodpile.views.CategoryViewLabelProvider.java

License:Open Source License

/**
 * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
 *      org.eclipse.jface.viewers.IDecoration)
 *///from   w  w w .  j a va  2s  .co  m
@Override
public void decorate(final Object element, final IDecoration decoration) {
    if (element instanceof Category) {
        decoration.addSuffix(" [decorated]");
    }
}

From source file:com.iw.plugins.spindle.ui.decorators.ProjectInfoDecorator.java

License:Mozilla Public License

public void decorate(Object element, IDecoration decoration) {
    IProject project = (IProject) ((IAdaptable) element).getAdapter(IProject.class);
    if (project == null || !project.isOpen())
        return;//from w  w  w.j  a va  2s.  com

    try {
        ITapestryProject tproject = (ITapestryProject) project.getNature(TapestryCore.NATURE_ID);
        if (tproject != null) {
            decoration.addSuffix(getDecorationSuffix(project));
        }
    } catch (CoreException e) {
        e.printStackTrace();
    }

}

From source file:com.liferay.ide.gradle.ui.WatchDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (!(element instanceof IProject)) {
        return;//from w ww.  j  ava2 s  .c  o  m
    }

    IProject project = (IProject) element;

    String jobName = project.getName() + " - watch";

    IJobManager jobManager = Job.getJobManager();

    Job[] jobs = jobManager.find(jobName);

    if (ListUtil.isNotEmpty(jobs)) {
        decoration.addSuffix(" [watching]");
    } else {
        decoration.addSuffix("");
    }
}

From source file:com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof WorkflowDefinitionEntry) {
        WorkflowDefinitionEntry definition = (WorkflowDefinitionEntry) element;

        if (!definition.isLoadingNode()) {
            int version = definition.getVersion();
            int draftVersion = definition.getDraftVersion();

            decoration.addSuffix(combine(version, draftVersion));
        }/*from w w  w  .j  ava 2  s  .  c o m*/
    } else if (element instanceof WorkflowDefinitionsFolder) {
        WorkflowDefinitionsFolder folder = (WorkflowDefinitionsFolder) element;

        IStatus status = folder.getStatus();

        if (status != null) {
            if (status.getException() instanceof KaleoAPIException) {
                decoration.addSuffix("  [Error API unavailable. Ensure kaleo-designer-portlet is deployed.]");
                decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages()
                        .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR));
            } else {
                decoration.addSuffix("  [" + status.getMessage() + "]");
            }
        } else {
            decoration.addSuffix("");
        }
    }
}

From source file:com.liferay.ide.project.ui.migration.MigrationDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    final List<Problem> problems = new ArrayList<>();

    final List<Problem> resolvedProblems = new ArrayList<>();

    final List<Problem> ignoreProblems = new ArrayList<>();

    if (element instanceof FileProblems) {
        final FileProblems fileProblems = (FileProblems) element;

        problems.addAll(fileProblems.getProblems());

        resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));

        ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
    } else if (element instanceof UpgradeProblems) {
        final UpgradeProblems upgradeProblems = (UpgradeProblems) element;

        for (FileProblems fileProblems : upgradeProblems.getProblems()) {
            problems.addAll(fileProblems.getProblems());

            resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));

            ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
        }//from ww  w .  ja v a 2 s .  c  o  m
    } else if (element instanceof ProblemsContainer) {
        ProblemsContainer problemsContainer = (ProblemsContainer) element;

        for (UpgradeProblems upgradeProblems : problemsContainer.getProblemsArray()) {
            for (FileProblems fileProblems : upgradeProblems.getProblems()) {
                problems.addAll(fileProblems.getProblems());

                resolvedProblems.addAll(fileProblems.getProblems(Problem.STATUS_RESOLVED));

                ignoreProblems.addAll(fileProblems.getProblems(Problem.STATUS_IGNORE));
            }
        }
    }

    if (problems != null && problems.size() > 0) {
        final StringBuilder sb = new StringBuilder();

        sb.append("[");

        sb.append(problems.size() + " total");

        if (resolvedProblems.size() > 0) {
            sb.append(", " + resolvedProblems.size() + " resolved");
        }

        if (ignoreProblems.size() > 0) {
            sb.append(", " + ignoreProblems.size() + " ignored");
        }

        sb.append("]");

        decoration.addSuffix(sb.toString());
    }
}

From source file:com.liferay.ide.server.ui.navigator.BundlesDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    if (element instanceof BundleDTO) {
        BundleDTO bundle = (BundleDTO) element;

        if (!(bundle instanceof BundleDTOLoading)) {
            String id = bundle.id + "";
            String state = bundle.state + "";
            String version = bundle.version;

            decoration.addSuffix(combine(id, state, version));
        }/*from   ww  w . j a va 2  s .  c  o m*/
    } else if (element instanceof BundlesFolder) {
        BundlesFolder folder = (BundlesFolder) element;

        IStatus status = folder.getStatus();

        if (status != null) {
            if (status.getException() instanceof BundleAPIException) {
                decoration.addSuffix(" [Error Bundle API unavailable.]");
                decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages()
                        .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR));
            } else {
                decoration.addSuffix("  [" + status.getMessage() + "]");
            }
        } else {
            decoration.addSuffix("");
        }
    } else if (element instanceof IServerModule) {
        final IServerModule module = (IServerModule) element;

        final IServer server = module.getServer();

        if (server.getServerState() == IServer.STATE_STARTED) {
            final BundleDeployer deployer = getDeployer(server);

            //TODO this chould be cached somehow?
            for (BundleDTO bundle : deployer.listBundles()) {
                if (module.getModule()[0].getName().equals(bundle.symbolicName)) {
                    String id = bundle.id + "";
                    String state = bundle.state + "";
                    String version = bundle.version;

                    decoration.addSuffix(combine(id, state, version));
                }
            }
        }
    }
}

From source file:com.mercatis.lighthouse3.status.ui.LighthouseStatusDecorator.java

License:Apache License

public void decorate(Object element, IDecoration decoration) {
    LighthouseDomain lighthouseDomain = CommonBaseActivator.getPlugin().getDomainService()
            .getLighthouseDomainByEntity(element);
    if (element instanceof StatusCarrier) {
        StatusHistogram sh = CommonBaseActivator.getPlugin().getStatusService()
                .getStatusHistogramForObject(lighthouseDomain, element);
        if (sh.getError() > 0) {
            decoration.addOverlay(getImageDescriptorForStatus(Status.ERROR, Size.x8), IDecoration.BOTTOM_LEFT);
            decoration.addSuffix(" " + sh.getError() + " status erroneous");
        } else if (sh.getStale() > 0) {
            decoration.addOverlay(getImageDescriptorForStatus(Status.STALE, Size.x8), IDecoration.BOTTOM_LEFT);
            decoration.addSuffix(" " + sh.getStale() + " status stale");
        } else if (sh.getOk() > 0) {
            decoration.addOverlay(getImageDescriptorForStatus(Status.OK, Size.x8), IDecoration.BOTTOM_LEFT);
            decoration.addSuffix(" " + sh.getOk() + " status ok");
        } else if (sh.getNone() > 0) {
            decoration.addOverlay(getImageDescriptorForStatus(Status.NONE, Size.x8), IDecoration.BOTTOM_LEFT);
        }//from  w  w w.j  a v  a  2 s .  c o  m
    }
}