MutableDisplayable.java

  1. /*
  2.  * *************************************************************************************************************************************************************
  3.  *
  4.  * SteelBlue: DCI User Interfaces
  5.  * http://tidalwave.it/projects/steelblue
  6.  *
  7.  * Copyright (C) 2015 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
  8.  *
  9.  * *************************************************************************************************************************************************************
  10.  *
  11.  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
  12.  * You may obtain a copy of the License at
  13.  *
  14.  *     http://www.apache.org/licenses/LICENSE-2.0
  15.  *
  16.  * 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
  17.  * CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License.
  18.  *
  19.  * *************************************************************************************************************************************************************
  20.  *
  21.  * git clone https://bitbucket.org/tidalwave/steelblue-src
  22.  * git clone https://github.com/tidalwave-it/steelblue-src
  23.  *
  24.  * *************************************************************************************************************************************************************
  25.  */
  26. package it.tidalwave.ui.core.role;

  27. import jakarta.annotation.Nonnull;
  28. import java.util.Locale;
  29. import java.util.Map;
  30. import it.tidalwave.ui.core.Mutable;
  31. import it.tidalwave.ui.core.role.impl.DefaultMutableDisplayable;

  32. /***************************************************************************************************************************************************************
  33.  *
  34.  * A specialized {@link it.tidalwave.ui.core.role.Displayable} which is mutable (that is, its display name can be changed)
  35.  * and fires {@code PropertyChangeEvent}s.
  36.  *
  37.  * @stereotype Role
  38.  *
  39.  * @since   2.0-ALPHA-1
  40.  * @author  Fabrizio Giudici
  41.  * @it.tidalwave.javadoc.stable
  42.  *
  43.  **************************************************************************************************************************************************************/
  44. public interface MutableDisplayable extends Displayable, Mutable
  45.   {
  46.     public static final Class<MutableDisplayable> _MutableDisplayable_ = MutableDisplayable.class;

  47.     /** The property name for displayName */
  48.     public static final String PROP_DISPLAY_NAME = "displayName";

  49.     /** The property name for displayNames */
  50.     public static final String PROP_DISPLAY_NAMES = "displayNames";

  51.     /***********************************************************************************************************************************************************
  52.      * Sets the display name in {@code Locale.ENGLISH}.
  53.      *
  54.      * @param  displayName  the display name
  55.      **********************************************************************************************************************************************************/
  56.     public void setDisplayName (@Nonnull String displayName);

  57.     /***********************************************************************************************************************************************************
  58.      * Sets the display name in the given {@code Locale}.
  59.      *
  60.      * @param  displayName  the display name
  61.      * @param  locale       the locale
  62.      **********************************************************************************************************************************************************/
  63.     public void setDisplayName (@Nonnull String displayName, @Nonnull Locale locale);

  64.     /***********************************************************************************************************************************************************
  65.      * Sets a bag of display names for a number of {@code Locale}s.
  66.      *
  67.      * @param  displayNames  the display names
  68.      **********************************************************************************************************************************************************/
  69.     public void setDisplayNames (@Nonnull Map<Locale, String> displayNames);

  70.     /***********************************************************************************************************************************************************
  71.      * Creates an instance with an initial given display name in {@code Locale.ENGLISH}.
  72.      *
  73.      * @param  displayName    the display name
  74.      * @return                the new instance
  75.      * @since                 3.2-ALPHA-1
  76.      **********************************************************************************************************************************************************/
  77.     @Nonnull
  78.     public static MutableDisplayable of (@Nonnull final String displayName)
  79.       {
  80.         return of(displayName, "???");
  81.       }

  82.     /***********************************************************************************************************************************************************
  83.      * Creates an instance with an initial given display name in {@code Locale.ENGLISH} and an explicit identifier for
  84.      * {@code toString()}.
  85.      *
  86.      * @param  displayName    the display name
  87.      * @param  toStringName   the name to be rendered when {@code toString()} is called
  88.      * @return                the new instance
  89.      * @since                 3.2-ALPHA-1
  90.      **********************************************************************************************************************************************************/
  91.     @Nonnull
  92.     public static MutableDisplayable of (@Nonnull final String displayName, @Nonnull final String toStringName)
  93.       {
  94.         return new DefaultMutableDisplayable(displayName, toStringName);
  95.       }
  96.   }