public class ClientConfigManager extends ConfigManager implements WidgetStateListener
Modifier and Type | Field and Description |
---|---|
private boolean |
canPushUpdates
Flag indicating when the client-side can start pushing updates.
|
protected java.util.Map<java.lang.Class<? extends WidgetConfig>,WidgetConfigDef> |
cfgDefs
Map of widget configuration definitions by their config class.
|
private static java.util.List<java.lang.Class<? extends WidgetConfig>> |
CONFIG_CLASSES
This list contains all config classes which implement
WidgetConfig . |
private ThinClient |
tc
Cache of the
ThinClient instance. |
activeConfigs, backupConfigs, dirtyConfigs, widgetCfg
Constructor and Description |
---|
ClientConfigManager()
Initialize the client-side by collecting all widget configuration classes (registered in
the
CONFIG_CLASSES ) and store them in the cfgDefs map. |
Modifier and Type | Method and Description |
---|---|
void |
activateConfigUpdates()
Inform the client-side that it can start sending the config updates.
|
void |
deactivateConfigUpdates()
Inform the client-side that it can no longer send config updates.
|
protected WidgetConfigDef |
getConfigDef(java.lang.Class<? extends WidgetConfig> cls)
Get the
WidgetConfigDef instance associated with the given WidgetConfig
implementation. |
WidgetConfigUpdates[] |
getConfigUpdates()
Get the widget configuration updates, by comparing the active with the backup configuration.
|
protected boolean |
isRegisteredWidget(WidgetId id)
Check if the given ID is associated with a registered widget.
|
void |
notifyWidgetDestroyed(Widget<? extends OutputManager<?>> w)
Notify the given widget has been destroyed.
|
void |
pushConfigDefs(ServerExports server)
On client-side, send the widget configurations to the specified server.
|
(package private) ConfigOwner<?> |
resolveConfigOwner(WidgetId widgetId)
The method attempts to resolve a
ConfigOwner reference from
the widget widgetId . |
void |
setConfigField(WidgetId wid,
WidgetConfig wcfg,
java.lang.String fname,
java.lang.Object value)
Set the widget config field to the specified value.
|
(package private) <T extends WidgetConfig> |
setWidgetConfig(T cfg,
java.lang.Object value,
WidgetConfigDef wdef,
java.lang.String fname)
Set a widget configuration field to the specified value.
|
void |
switchId(WidgetId oldId,
WidgetId newId)
Switch the widget's ID from the old one to the new one.
|
private void |
switchId(WidgetId oldId,
WidgetId newId,
java.util.Map map)
Helper method to replace the entry in the given map, to use the new key.
|
void |
trackAllChanges(WidgetConfig cfg)
Mark all differences between the backup config and the given widget configuration as being
"dirty".
|
addDirtyConfig, addWidgetConfig, addWidgetConfig, duplicate, getActiveConfig, getBackupConfig, getConfigDef, getDynamicConfig, getInstance, notifyWidgetDestroyed, removeWidgetConfig, replaceConfig, resolveWidgetConfig, resolveWidgetConfig, setDynamicConfig, setTracking, syncConfigChanges, trackConfig
private static final java.util.List<java.lang.Class<? extends WidgetConfig>> CONFIG_CLASSES
WidgetConfig
.private boolean canPushUpdates
ClientExports.activateConfigUpdates()
.private final ThinClient tc
ThinClient
instance.protected final java.util.Map<java.lang.Class<? extends WidgetConfig>,WidgetConfigDef> cfgDefs
public ClientConfigManager()
CONFIG_CLASSES
) and store them in the cfgDefs
map.public void setConfigField(WidgetId wid, WidgetConfig wcfg, java.lang.String fname, java.lang.Object value)
wid
- The widget ID.wcfg
- The widget configuration; if this is a down widget, this will be used.fname
- The list of config field names.value
- The list of new config field values.public void pushConfigDefs(ServerExports server)
server
- The server where to send the configs.ServerExports.initWidgetConfigurations(Map)
public void deactivateConfigUpdates()
public void activateConfigUpdates()
public WidgetConfigUpdates[] getConfigUpdates()
getConfigUpdates
in class ConfigManager
public void notifyWidgetDestroyed(Widget<? extends OutputManager<?>> w)
notifyWidgetDestroyed
in interface WidgetStateListener
w
- The deleted widget.public void switchId(WidgetId oldId, WidgetId newId)
oldId
- The old widget ID, currently in use by the manager.newId
- The new widget ID.public void trackAllChanges(WidgetConfig cfg)
cfg
- The configuration from which the changes are extracted.protected boolean isRegisteredWidget(WidgetId id)
isRegisteredWidget
in class ConfigManager
id
- The widget ID.true
if a widget exists in the registry, with the given ID.ConfigOwner<?> resolveConfigOwner(WidgetId widgetId)
ConfigOwner
reference from
the widget widgetId
.resolveConfigOwner
in class ConfigManager
widgetId
- Widget Id.ConfigOwner
reference or null
if
such cannot be find.protected WidgetConfigDef getConfigDef(java.lang.Class<? extends WidgetConfig> cls)
WidgetConfigDef
instance associated with the given WidgetConfig
implementation.getConfigDef
in class ConfigManager
cls
- The widget config class.<T extends WidgetConfig> void setWidgetConfig(T cfg, java.lang.Object value, WidgetConfigDef wdef, java.lang.String fname)
setWidgetConfig
in class ConfigManager
cfg
- The widget configuration to be updated.value
- The new field value.wdef
- The definition of the widget configuration.fname
- The ID of the changed field.private void switchId(WidgetId oldId, WidgetId newId, java.util.Map map)
oldId
- The old widget ID, which has some state registered in the given map.newId
- The new widget ID, to which the state needs to be re-put.map
- The map which needs to be updated.