Skip to contentPackage: MutableDisplayable
MutableDisplayable
Coverage
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
12: * the License. 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
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/thesefoolishthings-src
23: * git clone https://github.com/tidalwave-it/thesefoolishthings-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.role.ui;
28:
29: import javax.annotation.Nonnull;
30: import java.beans.PropertyChangeListener;
31: import java.util.Locale;
32: import java.util.Map;
33: import it.tidalwave.role.ui.impl.DefaultMutableDisplayable;
34:
35: /***********************************************************************************************************************
36: *
37: * A specialized {@link it.tidalwave.role.ui.Displayable} which is mutable (that is, its display name can be changed)
38: * and fires {@code PropertyChangeEvent}s.
39: *
40: * @stereotype Role
41: *
42: * @author Fabrizio Giudici
43: * @it.tidalwave.javadoc.stable
44: *
45: **********************************************************************************************************************/
46: public interface MutableDisplayable extends Displayable
47: {
48: public static final Class<MutableDisplayable> _MutableDisplayable_ = MutableDisplayable.class;
49:
50: /** The property name for displayName */
51: public static final String PROP_DISPLAY_NAME = "displayName";
52:
53: /** The property name for displayNames */
54: public static final String PROP_DISPLAY_NAMES = "displayNames";
55:
56: /*******************************************************************************************************************
57: *
58: * Sets the display name in {@code Locale.ENGLISH}.
59: *
60: * @param displayName the display name
61: *
62: ******************************************************************************************************************/
63: public void setDisplayName (@Nonnull String displayName);
64:
65: /*******************************************************************************************************************
66: *
67: * Sets the display name in the given {@code Locale}.
68: *
69: * @param displayName the display name
70: * @param locale the locale
71: *
72: ******************************************************************************************************************/
73: public void setDisplayName (@Nonnull String displayName, @Nonnull Locale locale);
74:
75: /*******************************************************************************************************************
76: *
77: * Sets a bag of display names for a number of {@code Locale}s.
78: *
79: * @param displayNames the display names
80: *
81: ******************************************************************************************************************/
82: public void setDisplayNames (@Nonnull Map<Locale, String> displayNames);
83:
84: /*******************************************************************************************************************
85: *
86: * Registers a {@link PropertyChangeListener}.
87: *
88: * @param listener the listener
89: *
90: ******************************************************************************************************************/
91: public void addPropertyChangeListener (@Nonnull PropertyChangeListener listener);
92:
93: /*******************************************************************************************************************
94: *
95: * Unregisters a {@link PropertyChangeListener}.
96: *
97: * @param listener the listener
98: *
99: ******************************************************************************************************************/
100: public void removePropertyChangeListener (@Nonnull PropertyChangeListener listener);
101:
102: /*******************************************************************************************************************
103: *
104: * Creates an instance with an initial given display name in {@code Locale.ENGLISH}.
105: *
106: * @param displayName the display name
107: * @return the new instance
108: * @since 3.2-ALPHA-1
109: *
110: ******************************************************************************************************************/
111: @Nonnull
112: public static MutableDisplayable of (@Nonnull final String displayName)
113: {
114: return of(displayName, "???");
115: }
116:
117: /*******************************************************************************************************************
118: *
119: * Creates an instance with an initial given display name in {@code Locale.ENGLISH} and an explicit identifier for
120: * {@code toString()}.
121: *
122: * @param displayName the display name
123: * @param toStringName the name to be rendered when {@code toString()} is called
124: * @return the new instance
125: * @since 3.2-ALPHA-1
126: *
127: ******************************************************************************************************************/
128: @Nonnull
129: public static MutableDisplayable of (@Nonnull final String displayName, @Nonnull final String toStringName)
130: {
131: return new DefaultMutableDisplayable(displayName, toStringName);
132: }
133: }