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:org.eclipse.emf.emfstore.client.ui.decorators.VersionDecorator.java

License:Open Source License

/**
 * . {@inheritDoc}/*w  ww.j  a  v a 2 s .co  m*/
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof ProjectSpace) {
        ProjectSpace projectSpace = (ProjectSpace) element;
        StringBuilder stringBuilder = new StringBuilder();
        if (projectSpace.getBaseVersion() != null) {
            stringBuilder.append("@");
            stringBuilder.append(projectSpace.getBaseVersion().getIdentifier());
        } else {
            stringBuilder.append("(Not shared)");
        }
        String string = stringBuilder.toString();
        decoration.addSuffix(string);
    }
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.decorators.UsernameDecorator.java

License:Open Source License

/**
 * {@inheritDoc}/* ww  w  .j a  va 2s.  c  o  m*/
 */
public void decorate(Object element, final IDecoration decoration) {
    if (element instanceof ProjectSpace) {
        final ProjectSpace projectSpace = (ProjectSpace) element;
        if (projectSpace.getUsersession() != null) {
            final String string = " " + projectSpace.getUsersession().getUsername();
            decoration.addSuffix(string);
        }
    }
}

From source file:org.eclipse.emf.emfstore.internal.client.ui.decorators.VersionDecorator.java

License:Open Source License

/**
 * . {@inheritDoc}/*from   ww  w. j  av  a  2  s .c o  m*/
 */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof ProjectSpace) {
        final ProjectSpace projectSpace = (ProjectSpace) element;
        final StringBuilder stringBuilder = new StringBuilder();
        if (projectSpace.getBaseVersion() != null) {
            stringBuilder.append("@");
            stringBuilder.append(projectSpace.getBaseVersion().getIdentifier());
            stringBuilder.append(" [" + projectSpace.getBaseVersion().getBranch() + "]");
        } else {
            stringBuilder.append("(Not shared)");
        }
        final String string = stringBuilder.toString();
        decoration.addSuffix(string);
    }
}

From source file:org.eclipse.flux.ui.integration.CloudProjectDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IProject
            && org.eclipse.flux.core.Activator.getDefault().getMessageConnector() != null
            && org.eclipse.flux.core.Activator.getDefault().getChannelSwitcher().getChannel() != null
            && org.eclipse.flux.core.Activator.getDefault().getRepository() != null
            && org.eclipse.flux.core.Activator.getDefault().getRepository().isConnected((IProject) element)) {
        decoration.addSuffix(" [connected to flux]");
    }/*from   w ww.  ja v  a2  s  .c o m*/
}

From source file:org.eclipse.jubula.client.teststyle.gui.decoration.DecoratorHandler.java

License:Open Source License

/**
 * Checks in the ProblemCont if the INodePO contains Elements which must be
 * decorated for violating a Checkstyle rule.
 * //from w  w  w .  j  a v  a 2s.c o m
 * {@inheritDoc}
 */
public void decorate(Object element, IDecoration decoration) {
    if (element == null || !TeststyleHandler.getInstance().isEnabled()) {
        return; // Cancel the method, an null element can't be decorated.
    }

    Severity severity = getWorstSeverity(getViolatingBaseChecks(element));

    if (element instanceof INodePO && severity != null) {
        INodePO node = (INodePO) element;
        IProblem worstProblem = ProblemFactory.getWorstProblem(node.getProblems());
        if (worstProblem != null && severity.ordinal() * 2 <= worstProblem.getStatus().getSeverity()) {
            severity = null;
        }
    }

    if (severity != null) {
        switch (severity) {
        case WARNING:
            decoration.addOverlay(IconConstants.WARNING_IMAGE_DESCRIPTOR, IDecoration.BOTTOM_RIGHT);
            break;
        case ERROR:
            decoration.addOverlay(IconConstants.ERROR_IMAGE_DESCRIPTOR, IDecoration.BOTTOM_RIGHT);
            break;
        default:
            break;
        }
    }
    for (BaseCheck chk : getViolatingBaseChecks(element)) {
        decoration.addPrefix(chk.getPrefix(element));
        decoration.addSuffix(chk.getSuffix(element));
    }
    BaseContext cont = BaseContext.getFor(element.getClass());
    for (DecoratingCheck chk : CheckCont.getDecChecksFor(cont)) {
        if (chk.isActive(cont) && chk.decorate(element)) {
            // FIXME mbs decorating icons
            decoration.addPrefix(chk.getPrefix(element));
            decoration.addSuffix(chk.getSuffix(element));
        }
    }
}

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

License:Open Source License

/** {@inheritDoc} */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof TestResultNode) {
        TestResultNode testResult = (TestResultNode) element;
        if (testResult.getNode() instanceof ICommentPO) {
            return;
        }//  w  w w .  j  av a  2 s  . c om

        Object testSuiteEndTimeValue = decoration.getDecorationContext()
                .getProperty(TestResultViewer.DECORATION_CONTEXT_SUITE_END_TIME_ID);
        Date endTime = testSuiteEndTimeValue instanceof Date ? (Date) testSuiteEndTimeValue : null;

        long durationMillis = testResult.getDuration(endTime);
        if (durationMillis != -1) {
            // only decorate if the duration could be determined
            decoration.addSuffix(SUFFIX_SPACER + DurationFormatUtils.formatDurationHMS(durationMillis));
        }
    }
}

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

License:Open Source License

/** {@inheritDoc} */
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof TestResultNode) {
        TestResultNode testResult = (TestResultNode) element;
        decoration.addSuffix(testResult.getParameterDescription());
        if (StringUtils.isNotBlank(testResult.getCommandLog())) {
            decoration.addOverlay(IconConstants.COMMANDLOG_IMAGE_DESCRIPTOR);
        }//from  w w w  .  j a  v a2  s  . c  o  m
    }
}

From source file:org.eclipse.mylyn.internal.sandbox.dev.InterestDebuggingDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {
    AbstractContextStructureBridge bridge = null;
    try {/*from  w  ww .  ja v a2 s.c  o m*/
        if (ContextCorePlugin.getDefault() == null) {
            return;
        }
        bridge = ContextCore.getStructureBridge(element);
    } catch (ConcurrentModificationException cme) {
        // ignored, because we can add structure bridges during decoration
    }
    try {
        IInteractionElement node = null;
        if (element instanceof InteractionContextRelation) {
            decoration.setForegroundColor(ColorMap.RELATIONSHIP);
        } else if (element instanceof IInteractionElement) {
            node = (IInteractionElement) element;
        } else {
            if (bridge != null && bridge.getContentType() != null) {
                node = ContextCore.getContextManager().getElement(bridge.getHandleIdentifier(element));
            }
        }
        if (node != null) {
            decoration.addSuffix(" {" + node.getInterest().getValue() + " ["
                    + node.getInterest().getEncodedValue() + "] " + "}");
        }
    } catch (Exception e) {
        StatusHandler.log(new Status(IStatus.WARNING, MylynDevPlugin.ID_PLUGIN, "Decoration failed", e));
    }
}

From source file:org.eclipse.mylyn.internal.tasks.ui.TaskLabelDecorator.java

License:Open Source License

public void decorate(Object element, IDecoration decoration) {

    ImageDescriptor priorityOverlay = getPriorityImageDescriptor(element);
    if (priorityOverlay != null) {
        decoration.addOverlay(priorityOverlay, IDecoration.BOTTOM_LEFT);
    }//from ww  w .  j  a va  2  s . com

    if (element instanceof ITask) {
        ITask task = (ITask) element;
        if (!task.isCompleted() && (TasksUiPlugin.getTaskActivityManager().isDueToday(task)
                || TasksUiPlugin.getTaskActivityManager().isOverdue(task))) {
            decoration.addOverlay(CommonImages.OVERLAY_DATE_OVERDUE, IDecoration.TOP_RIGHT);
        } else if (!task.isCompleted() && task.getDueDate() != null) {
            decoration.addOverlay(CommonImages.OVERLAY_DATE_DUE, IDecoration.TOP_RIGHT);
        }
        if (hasNotes(task)) {
            decoration.addOverlay(TasksUiImages.NOTES, IDecoration.BOTTOM_RIGHT);
        }
    } else if (element instanceof ITaskRepositoryElement) {
        ITaskRepositoryElement repositoryElement = (ITaskRepositoryElement) element;
        String repositoryUrl = repositoryElement.getRepositoryUrl();
        TaskRepository taskRepository = TasksUi.getRepositoryManager()
                .getRepository(repositoryElement.getConnectorKind(), repositoryUrl);
        if (taskRepository != null) {
            decoration.addSuffix("   [" + taskRepository.getRepositoryLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
        }
    } else if (element instanceof TaskRepository) {
        ImageDescriptor overlay = TasksUiPlugin.getDefault()
                .getOverlayIcon(((TaskRepository) element).getConnectorKind());
        if (overlay != null) {
            decoration.addOverlay(overlay, IDecoration.BOTTOM_RIGHT);
        }
    }
}

From source file:org.eclipse.php.ui.PHPLanguageLibraryDecorator.java

License:Open Source License

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof BuildPathContainer && ((BuildPathContainer) element).getBuildpathEntry().getPath()
            .equals(LanguageModelInitializer.LANGUAGE_CONTAINER_PATH)) {
        PHPVersion version = ProjectOptions.getPhpVersion(((BuildPathContainer) element).getScriptProject());
        if (version != null) {
            decoration.addSuffix(
                    new StringBuilder(" [PHP ").append(version.getAlias().substring(3)).append("]").toString()); //$NON-NLS-1$ //$NON-NLS-2$
        }/*from  ww w. ja v  a 2 s. co  m*/
    }

}