Package eu.bandm.tools.muli
Class Selection
java.lang.Object
eu.bandm.tools.muli.Selection
Represents a preference list of languages, to control translation
for a GUI, or sim.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
The top-most language currently selected.static final String
A language which is understood everywhere.protected final Set
<Selection.Listener> All subscribing Listeners.The list used for the search for translations, affected bysetLanguage(java.lang.String)
.The current list of preferences.The default preference sequence, as set when constructing. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener as subsrciber.The currently selected language.boolean
isMuLi()
Whether more than one language is provided.void
Remove a listener as subsrciber.void
setLanguage
(String lang) Select the current language.void
setPriorities
(String... langs) Re-define the sequence of supported languages and the default preferences.
-
Field Details
-
LINGUA_FRANCA
A language which is understood everywhere. It contains names which are never translated, because they are product names or ISO-defined entities, or sim.- See Also:
-
currentLanguage
The top-most language currently selected. (Normally all GUI elements will appear in this language, if possible. If not, the default preference sequence is searched instead.) -
priorities
The default preference sequence, as set when constructing. -
preferences
The list used for the search for translations, affected bysetLanguage(java.lang.String)
. -
listeners
All subscribing Listeners. -
prefs
The current list of preferences. ATTENTION Delivers a life-list which will change according tosetLanguage(java.lang.String)
, etc.
-
-
Constructor Details
-
Selection
Sets the default preference sequence. The initial state is set equal to this list.- Parameters:
langs
- default preference sequence.
-
Selection
Sets the default preference sequence. The initial state is set equal to this list.- Parameters:
langs
- default preference sequence.
-
-
Method Details
-
getCurrentLanguage
The currently selected language.- Returns:
- the currently selected language.
-
isMuLi
public boolean isMuLi()Whether more than one language is provided.- Returns:
- whether more than one language is provided.
-
addListener
Add a listener as subsrciber. Is idempotent: multiple calls have no further effect.- Parameters:
rec
- the subscribing listener.
-
removeListener
Remove a listener as subsrciber. Is idempotent: multiple calls have no further effect.- Parameters:
rec
- the no longer subscribing listener. If it is not subscribing, there is no effect.
-
setLanguage
Select the current language. The new prference sequence is calculated. Iff it differs, the listeners are notified.- Parameters:
lang
- the new current language.- Throws:
IllegalStateException
- if the languags is not in the list of (currently) supported languages.
-
setPriorities
Re-define the sequence of supported languages and the default preferences.- Parameters:
langs
- list of languages- Throws:
IllegalArgumentException
- if a null value is contained in langs
-