类hudson.model.BallColor源码实例Demo

下面列出了怎么用hudson.model.BallColor的API类实例代码及写法,或者点击链接到github查看源代码。

/**
 * Calculates the color of the status ball for the owner based on its descendants.
 * <br>
 * Kanged from Branch API (original author Stephen Connolly).
 *
 * @return the color of the status ball for the owner.
 */
@Nonnull
private BallColor calculateBallColor() {
    if (owner instanceof TemplateDrivenMultiBranchProject
            && ((TemplateDrivenMultiBranchProject) owner).isDisabled()) {
        return BallColor.DISABLED;
    }

    BallColor c = BallColor.DISABLED;
    boolean animated = false;

    for (Job job : owner.getAllJobs()) {
        BallColor d = job.getIconColor();
        animated |= d.isAnimated();
        d = d.noAnime();
        if (d.compareTo(c) < 0) {
            c = d;
        }
    }

    if (animated) {
        c = c.anime();
    }

    return c;
}
 
private UnescapedText getResultIcon(final QualityGateStatus qualityGateStatus) {
    BallColor color = qualityGateStatus.getColor();
    return join(img().withSrc(jenkins.getImagePath(color))
                    .withClasses(color.getIconClassName())
                    .withAlt(color.getDescription())
                    .withTitle(color.getDescription()),
            color.getDescription());
}
 
源代码3 项目: warnings-ng-plugin   文件: SummaryTest.java
private StaticAnalysisLabelProvider createLabelProvider(final String id, final String name) {
    JenkinsFacade jenkins = mock(JenkinsFacade.class);
    when(jenkins.getImagePath(any(BallColor.class))).thenReturn("color");
    when(jenkins.getImagePath(contains(StaticAnalysisLabelProvider.ERROR_ICON))).thenReturn("/path/to/error");
    when(jenkins.getImagePath(contains(StaticAnalysisLabelProvider.INFO_ICON))).thenReturn("/path/to/info");
    when(jenkins.getAbsoluteUrl(any())).thenReturn("absoluteUrl");
    return new StaticAnalysisLabelProvider(id, name, jenkins);
}
 
/**
 * Delegates the image to the {@link #owner}'s {@link BallColor}.
 * <br>
 * {@inheritDoc}
 */
@Override
public String getImageOf(String size) {
    if (owner == null) {
        return BallColor.GREY.getImageOf(size);
    }

    return calculateBallColor().getImageOf(size);
}
 
/**
 * Delegates the description to the {@link #owner}'s {@link BallColor}.
 * <br>
 * {@inheritDoc}
 */
@Override
public String getDescription() {
    if (owner == null) {
        return BallColor.GREY.getDescription();
    }

    return calculateBallColor().getDescription();
}
 
/**
 * Calculates the color of the status ball for the owner based on selected descendants.
 * <br>
 * Logic kanged from Branch API (original author Stephen Connolly).
 *
 * @return the color of the status ball for the owner.
 */
@Nonnull
private BallColor calculateBallColor() {
    if (owner instanceof TemplateDrivenMultiBranchProject
            && ((TemplateDrivenMultiBranchProject) owner).isDisabled()) {
        return BallColor.DISABLED;
    }

    BallColor c = BallColor.DISABLED;
    boolean animated = false;

    StringTokenizer tokens = new StringTokenizer(Util.fixNull(jobs), ",");
    while (tokens.hasMoreTokens()) {
        String jobName = tokens.nextToken().trim();
        TopLevelItem item = owner.getItem(jobName);
        if (item != null && item instanceof Job) {
            BallColor d = ((Job) item).getIconColor();
            animated |= d.isAnimated();
            d = d.noAnime();
            if (d.compareTo(c) < 0) {
                c = d;
            }
        }
    }

    if (animated) {
        c = c.anime();
    }

    return c;
}
 
/**
 * Delegates the image to the {@link #owner}'s {@link BallColor}.
 * <br>
 * {@inheritDoc}
 */
@Override
public String getImageOf(String size) {
    if (owner == null) {
        return BallColor.GREY.getImageOf(size);
    }

    return calculateBallColor().getImageOf(size);
}
 
/**
 * Delegates the description to the {@link #owner}'s {@link BallColor}.
 * <br>
 * {@inheritDoc}
 */
@Override
public String getDescription() {
    if (owner == null) {
        return BallColor.GREY.getDescription();
    }

    return calculateBallColor().getDescription();
}
 
public StatusImage getBuildImage( BallColor ballColor, String style )
    throws IOException, FontFormatException
{
    String subject = "build";
    String status = "unknown";
    String color;

    if ( ballColor.isAnimated() )
    {
        status = "running";
    }
    switch ( ballColor )
    {
        case RED:
        case ABORTED:
            status = "failing";
            // fall through
        case RED_ANIME:
        case ABORTED_ANIME:
            color = "red";
            break;
        case YELLOW:
            status = "unstable";
            // fall through
        case YELLOW_ANIME:
            color = "yellow";
            break;
        case BLUE:
            status = "passing";
            // fall through
        case BLUE_ANIME:
            color = "brightgreen";
            break;
        case DISABLED:
        case DISABLED_ANIME:
        case GREY:
        case GREY_ANIME:
        case NOTBUILT:
        case NOTBUILT_ANIME:
        default:
            color = "lightgrey";
            break;
    }

    return new StatusImage( subject, status, color, style );
}
 
public StatusImage getBuildImage(BallColor ballColor, String style) throws IOException, FontFormatException {
    return iconResolver.getBuildImage(ballColor, style);
}
 
public StatusImage getBuildImage( BallColor color, String style )
    throws IOException, FontFormatException
{
    return iconResolver.getBuildImage( color, style );
}
 
源代码12 项目: DotCi   文件: DbBackedBuild.java
@Override
public BallColor getIconColor() {
    return !isBuilding() ? getResult().color : BallColor.YELLOW_ANIME;
}
 
 类所在包
 类方法
 同包方法