content: /*
   *  Licensed to the Apache Software Foundation (ASF) under one
   *  or more contributor license agreements.  See the NOTICE file
   *  distributed with this work for additional information
   *  regarding copyright ownership.  The ASF licenses this file
   *  to you under the Apache License, Version 2.0 (the
   *  "License"); you may not use this file except in compliance
   *  with the License.  You may obtain a copy of the License at
   *
   *        http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing,
   *  software distributed under the License is distributed on an
   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   *  KIND, either express or implied.  See the License for the
   *  specific language governing permissions and limitations
   *  under the License.
   */
  package org.apache.causeway.viewer.wicket.ui.components.attributes.choices;
  
  import java.util.EnumSet;
  
  import org.apache.wicket.Component;
  
  import org.apache.causeway.viewer.wicket.model.models.UiAttributeWkt;
  import org.apache.causeway.viewer.wicket.ui.components.attributes.AttributeFragmentFactory.CompactFragment;
  import org.apache.causeway.viewer.wicket.ui.components.attributes.value.ValueAttributePanel;
  import org.apache.causeway.viewer.wicket.ui.util.Wkt;
  
  /**
   * Panel for rendering titles for scalars of any type.
   * <p>
   * Most prominently this is used for {@link Enum} values.
   */
  class TitleBadgeAttributePanel<T> extends ValueAttributePanel<T> {
  
      private static final long serialVersionUID = 1L;
  
      public TitleBadgeAttributePanel(final String id, final UiAttributeWkt attributeModel, final Class<T> type) {
          super(id, attributeModel, type);
      }
  
      @Override
      protected void setupFormatModifiers(final EnumSet<FormatModifier> modifiers) {
          // enforce use of text representation, as the HTML template fragments already have badge specific markup
          modifiers.add(FormatModifier.TEXT_ONLY);
      }
  
      @Override
      protected Component createComponentForOutput(final String id) {
          return CompactFragment.BADGE.createFragment(id, this, scalarValueId->
              Wkt.labelWithDynamicEscaping(scalarValueId, this::obtainOutputFormat));
      }
  
  }
  