MutableDisplayable.java

  1. /*
  2.  * *************************************************************************************************************************************************************
  3.  *
  4.  * TheseFoolishThings: Miscellaneous utilities
  5.  * http://tidalwave.it/projects/thesefoolishthings
  6.  *
  7.  * Copyright (C) 2009 - 2024 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/thesefoolishthings-src
  22.  * git clone https://github.com/tidalwave-it/thesefoolishthings-src
  23.  *
  24.  * *************************************************************************************************************************************************************
  25.  */
  26. package it.tidalwave.role.ui;

  27. import javax.annotation.Nonnull;
  28. import java.beans.PropertyChangeListener;
  29. import java.util.Locale;
  30. import java.util.Map;
  31. import it.tidalwave.role.ui.impl.DefaultMutableDisplayable;

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

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

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

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

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

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

  69.     /***********************************************************************************************************************************************************
  70.      * Registers a {@link PropertyChangeListener}.
  71.      *
  72.      * @param  listener   the listener
  73.      **********************************************************************************************************************************************************/
  74.     public void addPropertyChangeListener (@Nonnull PropertyChangeListener listener);

  75.     /***********************************************************************************************************************************************************
  76.      * Unregisters a {@link PropertyChangeListener}.
  77.      *
  78.      * @param  listener   the listener
  79.      **********************************************************************************************************************************************************/
  80.     public void removePropertyChangeListener (@Nonnull PropertyChangeListener listener);

  81.     /***********************************************************************************************************************************************************
  82.      * Creates an instance with an initial given display name in {@code Locale.ENGLISH}.
  83.      *
  84.      * @param  displayName    the display name
  85.      * @return                the new instance
  86.      * @since                 3.2-ALPHA-1
  87.      **********************************************************************************************************************************************************/
  88.     @Nonnull
  89.     public static MutableDisplayable of (@Nonnull final String displayName)
  90.       {
  91.         return of(displayName, "???");
  92.       }

  93.     /***********************************************************************************************************************************************************
  94.      * Creates an instance with an initial given display name in {@code Locale.ENGLISH} and an explicit identifier for
  95.      * {@code toString()}.
  96.      *
  97.      * @param  displayName    the display name
  98.      * @param  toStringName   the name to be rendered when {@code toString()} is called
  99.      * @return                the new instance
  100.      * @since                 3.2-ALPHA-1
  101.      **********************************************************************************************************************************************************/
  102.     @Nonnull
  103.     public static MutableDisplayable of (@Nonnull final String displayName, @Nonnull final String toStringName)
  104.       {
  105.         return new DefaultMutableDisplayable(displayName, toStringName);
  106.       }
  107.   }