public abstract class WidgetConfig
extends java.lang.Object
implements java.io.Externalizable
ConfigFieldSetterAspect
class must have as suffix the Config
text.
See the javadoc for ConfigFieldSetterAspect.beforeSetField(com.goldencode.p2j.ui.WidgetConfig, org.aspectj.lang.JoinPoint.StaticPart)
for details about which
fields are instrumented.
All widget state needs to be separated from the concrete widget implementation (be it on server or client-side). This ensures the state is shared between devices (i.e. a ChUI and GUI impl of a widget can access the state) and on server-side ensures that shared widgets (TODO: P2J doesn't create unique widgets resources for a child shared frame) can share this state, too.
Explicit setters and getters can be defined only as a last resort. Before deciding to add a setter/getter here, determine if the case is related to server-side or client-side, and check if the setter/getter at the widget implementation can address this problem, instead of the widget config class.
Only public, non-transient, instance fields will be collected by the client-side and pushed to the server-side. The server-side will always send the entire definition (via pushWidgetConfig calls).
This class implements Externalizable
, to allow the server-side to send it to the
client-side in one go. All sub-classes need to ensure that the writeExternal(java.io.ObjectOutput)
and
readExternal(java.io.ObjectInput)
are overridden, in case the config class has additional instance fields.
All sub-classes of this class must be added to the ClientConfigManager.CONFIG_CLASSES
list.
The following are some TODO's to improve the usage of the WidgetConfig
classes:
LogicalTerminal.pushScreenDefinition(com.goldencode.p2j.ui.ScreenDefinition[])
or the scaling that we do via
Coordinate.scale(double)
. WARNING: if AspectJ is used, be careful that it can affect
performance, if the called aspect has any parameters (like JoinPoint
) or if the
called aspect is time-consuming. In any case, once this is added, the performance needs
to be checked if it is affected by the changes.AbstractWidget.config()
method and any reliance on
direct access to widget configs from outside of widgets. Move all widget-internal access
to direct field references on the local properly-typed config instance.WidgetConfig
instances, to allow complete
separation between a widget's state and its concrete implementation (as a widget may exist
for GUI or ChUI at the same time). WARNING: this client-side specific state must not be
instrumented by the ConfigFieldSetterAspect
and it must not be sent to server-side.
Modifier and Type | Field and Description |
---|---|
int |
contextHelpId
CONTEXT-HELP-ID attribute variable.
|
boolean |
enabled
Widget enabled flag.
|
BaseDataType |
frameDefValue
Store the widget's value set at frame definition.
|
int |
frameId
The index of the frame which holds this widget.
|
boolean |
header
Mark header widget.
|
boolean |
hidden
The HIDDEN attribute, which stops widgets from displaying.
|
WidgetId |
id
WIDGET-ID attribute variable.
|
boolean |
manualHightlight
MANUAL-HIGHLIGHT attribute variable.
|
java.lang.String |
menuKey
MENU-KEY attribute variable.
|
java.lang.Integer |
menuMouse
MENU-MOUSE attribute variable.
|
boolean |
modified
MODIFIED attribute variable.
|
int |
popupMenuId
An ID of POPUP-MENU assigned to widget or -1
|
boolean |
realized
Flag to indicate whether the widget has been realized.
|
boolean |
selectable
SELECTABLE attribute variable.
|
private static long |
serialVersionUID
Serial Version ID
|
byte |
state
The state of the data for this widget.
|
boolean |
visible
Means whether the widget is visible or not.
|
boolean |
wasRealized
Flag to indicate whether the widget's has been realized.
|
Modifier | Constructor and Description |
---|---|
|
WidgetConfig()
Default constructor (only used in deserialization).
|
protected |
WidgetConfig(int id)
Create a new config and associate it with the given widget.
|
protected |
WidgetConfig(WidgetId id)
Create a new config and associate it with the given widget.
|
Modifier and Type | Method and Description |
---|---|
void |
applyConfig(WidgetConfig config)
Set new values from the provided configuration instance.
|
java.lang.String |
getDynamicColumnLabel()
Get the
COLUMN-LABEL attribute in this widget configuration, dynamically. |
java.lang.String |
getDynamicFormat()
Get the
FORMAT attribute in this widget configuration, dynamically. |
java.lang.String |
getDynamicHelp()
Get the
HELP attribute in this widget configuration, dynamically. |
java.lang.String |
getDynamicLabel()
Get the
LABEL attribute in this widget configuration, dynamically. |
void |
readExternal(java.io.ObjectInput in)
Replacement for the default object reading method.
|
void |
setDynamicFormat(java.lang.String format)
Set the
FORMAT attribute in this widget configuration, dynamically. |
void |
setDynamicHeader(boolean header)
Set the
header attribute in this widget configuration, dynamically. |
void |
setDynamicHelp(java.lang.String help)
Set the
HELP attribute in this widget configuration, dynamically. |
void |
setDynamicLabel(java.lang.String label)
Set the
LABEL attribute in this widget configuration, dynamically. |
void |
setDynamicLabels(boolean labels)
Set the
LABELS attribute in this widget configuration, dynamically. |
java.lang.String |
toString()
Get the string representation of this widget configuration.
|
void |
writeExternal(java.io.ObjectOutput out)
Replacement for the default object writing method.
|
private static final long serialVersionUID
public int frameId
public boolean visible
public boolean realized
public boolean wasRealized
public boolean hidden
public boolean header
public boolean enabled
public int popupMenuId
public boolean modified
public WidgetId id
public int contextHelpId
public boolean manualHightlight
public boolean selectable
public java.lang.Integer menuMouse
public java.lang.String menuKey
public byte state
AbstractWidget.setState(byte)
API.public BaseDataType frameDefValue
public WidgetConfig()
protected WidgetConfig(int id)
id
- The ID of the widget to which this configuration belongs.protected WidgetConfig(WidgetId id)
id
- The ID of the widget to which this configuration belongs.public void setDynamicHeader(boolean header)
header
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the header
name, then this
will be a no-op.
header
- The new value for the header attribute.public void setDynamicLabels(boolean labels)
LABELS
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the labels
name, then this
will be a no-op.
labels
- The new value for the LABELS attribute.public java.lang.String getDynamicFormat()
FORMAT
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the format
name, then this
will return null
public void setDynamicFormat(java.lang.String format)
FORMAT
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the format
name, then this
will be a no-op.
format
- The new value for the FORMAT attribute.public java.lang.String getDynamicColumnLabel()
COLUMN-LABEL
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the clabel
name, then this
will return null
public java.lang.String getDynamicLabel()
LABEL
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the label
name, then this
will return null
public void setDynamicLabel(java.lang.String label)
LABEL
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the label
name, then this
will be a no-op.
label
- The new value for the LABEL attribute.public java.lang.String getDynamicHelp()
HELP
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the help
name, then this
will return null
public void setDynamicHelp(java.lang.String help)
HELP
attribute in this widget configuration, dynamically.
If the configuration doesn't define a field with the help
name, then this
will be a no-op.
help
- The new value for the HELP attribute.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The output destination to which fields will be saved.java.io.IOException
- In case of I/O errors.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- The input source from which fields will be restored.java.io.IOException
- In case of I/O errors.java.lang.ClassNotFoundException
- If payload can't be instantiated.public java.lang.String toString()
toString
in class java.lang.Object
public void applyConfig(WidgetConfig config)
config
- The instance from which to take values.