001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.console.widgets; 018 019import org.apache.juneau.commons.bean.*; 020 021/** 022 * A labelled count widget in a {@link BarSlot} — the "N change pending"-style badge to the right of the subtab 023 * ribbon. 024 * 025 * @since 10.0.0 026 */ 027@BeanType(properties="id,label,badge") 028@SuppressWarnings({ 029 "java:S1845" // Fluent-builder setters intentionally mirror field names (Juneau DSL convention). 030}) 031public final class BarBadge implements BarWidget { 032 033 /** The stable widget id, unique within its {@link BarSlot}. Required, non-blank. */ 034 public String id; 035 036 /** The contextual label painted as {@code textContent} (e.g. <js>"change pending"</js>). */ 037 public String label; 038 039 /** The overlay count/tone badge (amber for the yellow "pending" badge). */ 040 public Badge badge; 041 042 /** 043 * Creates a bar badge with the given id. 044 * 045 * @param id The stable widget id. Must not be <jk>null</jk> or blank. 046 * @return A new {@link BarBadge}. 047 */ 048 public static BarBadge of(String id) { 049 var b = new BarBadge(); 050 b.id = id; 051 return b; 052 } 053 054 /** 055 * Sets the contextual label. 056 * 057 * @param value The label text. 058 * @return This object. 059 */ 060 public BarBadge label(String value) { 061 label = value; 062 return this; 063 } 064 065 /** 066 * Sets the count/tone badge. 067 * 068 * @param value The badge. 069 * @return This object. 070 */ 071 public BarBadge badge(Badge value) { 072 badge = value; 073 return this; 074 } 075}