public class ThemeManager
extends java.lang.Object
Theme
. The
current is defined for the entire client process. This class is client-side only. It will
request the configuration from server, but it will use that as a hint only. The class
configured in server directory might no contain a proper theme/class name.Modifier and Type | Field and Description |
---|---|
private static Theme |
crtTheme
Current theme.
|
private static boolean |
DEBUG
Flag for debugging GUI.
|
Constructor and Description |
---|
ThemeManager() |
Modifier and Type | Method and Description |
---|---|
static void |
debug(java.lang.Runnable debugCode)
Execute some debug code if debug is enabled.
|
static Theme |
getCurrentTheme()
Obtain the current
Theme . |
static boolean |
init(ServerExports server,
java.lang.String preferredTheme)
Initialize the
ThemeManager using negotiation with the server. |
private static boolean |
setTheme(java.lang.Class<? extends Theme> newThemeClass)
Sets a new
Theme . |
static boolean |
setTheme(java.lang.String name)
Sets a new
Theme . |
private static Theme crtTheme
null
after calls to setTheme(String)
. Any call to
getCurrentTheme()
will make sure this field is initialized with the default value
before returning it.private static boolean DEBUG
public static Theme getCurrentTheme()
Theme
. If not already initialized the default theme is
initialized and returned.Theme
. Always not null
.public static boolean setTheme(java.lang.String name)
Theme
. Before setting the new theme, a check if performed to test if the
theme is already active. If already active, the theme is not reloaded.
The old theme is not removed and its resources released until the new Theme
was
successfully initialized.
TODO: when a new theme is set, all resources need to be re-requested from server (fonts, font-sizes and color palette).
name
- The name of the new Theme
to be activated. The built-in
ClassicTheme
and Windows10Theme
are recognized by their short
names.true
if the old Theme
was replaced with the new one.private static boolean setTheme(java.lang.Class<? extends Theme> newThemeClass)
Theme
. The old theme is not removed and its resources released until
the new Theme
was successfully initialized.newThemeClass
- The new class to be instantiated and the new object to be set as new active
theme.true
if the old Theme
was replaced with the new one.public static boolean init(ServerExports server, java.lang.String preferredTheme)
ThemeManager
using negotiation with the server. If a theme is not
requested in command line (passed in by preferredTheme
parameter), it will request
the configuration from server directory, but it will use that as a hint only. The class
configured in server directory might no contain a proper theme/class name. If no definition
is found in directory, or the string obtained does not represent a name or full class of a
theme accessible from client path, the theme remains uninitialized.
It will be lazily instantiated when accessed the first time.server
- the ServerExports
object for communication with server.preferredTheme
- the preferred theme from command-line.public static void debug(java.lang.Runnable debugCode)
debugCode
- The code to be executed.