Class UIDefinition
- java.lang.Object
-
- org.openbravo.client.kernel.reference.UIDefinition
-
- Direct Known Subclasses:
AbsoluteTimeUIDefinition
,BinaryUIDefinition
,BooleanUIDefinition
,DateUIDefinition
,EnumUIDefinition
,ForeignKeyUIDefinition
,ImageUIDefinition
,LinkUIDefinition
,NumberUIDefinition
,ProcessFileUploadUIDefinition
,RelevantCharacteristicUIDefinition
,StringUIDefinition
,TimeUIDefinition
,WidgetInFormUIDefinition
,YesNoUIDefinition
public abstract class UIDefinition extends Object
Base implementation of a user interface client reference.- Author:
- mtaal
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.apache.logging.log4j.Logger
log
-
Constructor Summary
Constructors Constructor Description UIDefinition()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
convertToClassicString(Object value)
Creates a classic string which is used by callouts from an object value.Object
createFromClassicString(String value)
Convert a string value as used in classic OB to a type safe value.Object
createJsonValueFromClassicValueString(String value)
Deprecated.replaced bycreateFromClassicString(String)
void
establishGridConfigurationSettings(Field field, Optional<GCSystem> systemGC, Optional<GCTab> tabGC)
Obtains the grid configuration values for the given field and sets them into the 'gridConfigurationSettings' variable.String
formatValueFromSQL(String value)
Deprecated.replaced bycreateFromClassicString(String)
String
formatValueToSQL(String value)
Deprecated.replaced byconvertToClassicString(Object)
String
getCellAlign()
Returns alignment in grid view.Map<String,Object>
getDataSourceParameters()
Parameters passed in to the datasource, for example theJsonConstants.ADDITIONAL_PROPERTIES_PARAMETER
can be passed in like this.String
getDefaultValue(VariablesSecureApp vars, String columnName, String defaultValueExpression, String windowId)
Returns the value for a default value expression which represents a session value or a fixed value.String
getDefaultValueFromSQLExpression(VariablesSecureApp vars, Field field, String defaultValueExpression)
Returns the value for a default value expression based on a SQL expression.DomainType
getDomainType()
String
getFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient form.String
getFieldProperties(Field field, boolean getValueFromSession)
Computes properties to initialize and set the field in a Smartclient form.String
getFieldPropertiesFirstRecord(Field field, boolean getValueFromSession)
String
getFieldPropertiesWithoutCombo(Field field, boolean getValueFromSession)
It returns the same as getFieldProperties except in the case of combo UIDefinitions.String
getFilterEditorProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid filter.protected String
getFilterEditorPropertiesProperty(Field field)
Returns the filterEditorProperties property set on the gridfield.String
getFilterEditorType()
String
getFormEditorType()
String
getGridEditorFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid cell when it is being edited.String
getGridEditorType()
protected String
getGridFieldName(Field fld)
String
getGridFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid cell.String
getName()
Unique name used to identify the type.String
getParameterProperties(Parameter parameter)
String
getParameterWidth(Parameter parameter)
String
getParentType()
String
getReadOnlyEditorType()
Reference
getReference()
protected boolean
getSafeBoolean(Boolean value)
protected String
getShowHoverGridFieldSettings(Field field)
String
getTypeProperties()
Computes the properties used to define the type, this includes all the Smartclient SimpleType properties.String
getValueFromSQLDefault(ResultSet rs)
protected String
getValueInComboReference(Field field, boolean getValueFromSession, String columnValue)
protected String
getValueInComboReference(Field field, boolean getValueFromSession, String columnValue, boolean onlyFirstRecord)
static String
parseSQL(String code, ArrayList<String> colNames)
protected Object
readGridConfigurationSetting(String setting)
Reads a particular value from the grid configuration settingsprotected String
removeAttributeFromString(String inpString, String attr)
void
setReference(Reference reference)
boolean
showHover()
This method determines if the UI definition should include the showHover property as part of the grid field properties.
-
-
-
Method Detail
-
getName
public String getName()
Unique name used to identify the type.
-
getParentType
public String getParentType()
- Returns:
- the Smartclient type from which this type inherits.
-
getFormEditorType
public String getFormEditorType()
- Returns:
- the form item type used for editing this reference in a form.
-
getGridEditorType
public String getGridEditorType()
- Returns:
- the form item type used for editing this reference in a grid. As a default will return
getFormEditorType()
-
getReadOnlyEditorType
public String getReadOnlyEditorType()
- Returns:
- the read only editor type. As default will return "".
-
getFilterEditorType
public String getFilterEditorType()
- Returns:
- the form item type used for filtering in grids. As a default will return
getFormEditorType()
-
getTypeProperties
public String getTypeProperties()
Computes the properties used to define the type, this includes all the Smartclient SimpleType properties.- Returns:
- a javascript string which can be included in the javascript defining the SimpleType. The default implementation returns an empty string.
-
getFieldProperties
public String getFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient form. This can be the default value or the sets of values in the valuemap. NOTE: the field parameter may be null, implementors of subclasses should take this into account.- Parameters:
field
- the field for which the information should be computed. NOTE: the caller is allowed to pass null for cases where the field properties are needed for a FormItem which is not backed by an Openbravo field.- Returns:
- a JSONObject string which is used to initialize the formitem.
-
getValueFromSQLDefault
public String getValueFromSQLDefault(ResultSet rs) throws SQLException
- Throws:
SQLException
-
getFieldProperties
public String getFieldProperties(Field field, boolean getValueFromSession)
Computes properties to initialize and set the field in a Smartclient form. This can be the default value or the sets of values in the valuemap.- Parameters:
field
- the field for which the information should be computed.getValueFromSession
-- Returns:
- a JSONObject string which is used to initialize the formitem.
-
getDefaultValue
public String getDefaultValue(VariablesSecureApp vars, String columnName, String defaultValueExpression, String windowId)
Returns the value for a default value expression which represents a session value or a fixed value. This method is not used to calculate SQL based expressions (those that start with '@SQL=') and NOW expression ('@#Date@').- Parameters:
vars
- Handler for the session info.columnName
- String with the name of the column that has the default value.defaultValueExpression
- String with the default value expression.windowId
- String with the window id.- Returns:
- String with the calculated default value.
-
getDefaultValueFromSQLExpression
public String getDefaultValueFromSQLExpression(VariablesSecureApp vars, Field field, String defaultValueExpression)
Returns the value for a default value expression based on a SQL expression. This kind of expressions start with '@SQL='.- Parameters:
vars
- Handler for the session info.field
- Field whose column has the default value.defaultValueExpression
- String with the default value expression.- Returns:
- String with the calculated default value.
-
getFieldPropertiesWithoutCombo
public String getFieldPropertiesWithoutCombo(Field field, boolean getValueFromSession)
It returns the same as getFieldProperties except in the case of combo UIDefinitions. In combo UI definitions, a call to the super will be done, but the combo computation itself will not be done (so only the default value, or the current request value, will be considered).
-
getFieldPropertiesFirstRecord
public String getFieldPropertiesFirstRecord(Field field, boolean getValueFromSession)
-
getCellAlign
public String getCellAlign()
Returns alignment in grid view. In case it returns null, default alignment for actual data type is used.- Returns:
null
for default alignment, "left", "center" or "right"
-
createFromClassicString
public Object createFromClassicString(String value)
Convert a string value as used in classic OB to a type safe value.
-
convertToClassicString
public String convertToClassicString(Object value)
Creates a classic string which is used by callouts from an object value.- Parameters:
value
-- Returns:
- the classic string
-
getDataSourceParameters
public Map<String,Object> getDataSourceParameters()
Parameters passed in to the datasource, for example theJsonConstants.ADDITIONAL_PROPERTIES_PARAMETER
can be passed in like this.- Returns:
- a list of parameters used to drive the datasource generation incorporating this UIDefinition.
-
getFilterEditorProperties
public String getFilterEditorProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid filter. This can be the default value or the sets of values in the valuemap. Note: the result should be either empty, if not empty then it start with a comma and end without a comma, this to generate correct javascript.- Parameters:
field
- the field for which the information should be computed.- Returns:
- a JSONObject string which is used to initialize the formitem.
-
getFilterEditorPropertiesProperty
protected String getFilterEditorPropertiesProperty(Field field)
Returns the filterEditorProperties property set on the gridfield. Note for implementations in the subclass: field maybe null.- Parameters:
field
- the field to generate the filter editor properties for, note it is allowed to pass null, implementors should gracefully handle this.
-
getGridFieldProperties
public String getGridFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid cell. This can be the default value or the sets of values in the valuemap. Note: the result should be either empty, if not empty then it start with a comma and end without a comma, this to generate correct javascript.- Parameters:
field
- the field for which the information should be computed.- Returns:
- a JSONObject string which is used to initialize the formitem.
-
getGridEditorFieldProperties
public String getGridEditorFieldProperties(Field field)
Computes properties to initialize and set the field in a Smartclient grid cell when it is being edited. This can be the default value or the sets of values in the valuemap. Note: the result should be either empty, if not empty then it start with a comma and end without a comma, this to generate correct javascript.- Parameters:
field
- the field for which the information should be computed.- Returns:
- a JSONObject string which is used to initialize the formitem.
-
getReference
public Reference getReference()
-
setReference
public void setReference(Reference reference)
-
getDomainType
public DomainType getDomainType()
-
removeAttributeFromString
protected String removeAttributeFromString(String inpString, String attr)
-
readGridConfigurationSetting
protected Object readGridConfigurationSetting(String setting)
Reads a particular value from the grid configuration settings- Parameters:
setting
- the setting whose value is to be returned.
-
establishGridConfigurationSettings
public void establishGridConfigurationSettings(Field field, Optional<GCSystem> systemGC, Optional<GCTab> tabGC)
Obtains the grid configuration values for the given field and sets them into the 'gridConfigurationSettings' variable. The aim of having all these values in a single variable at once is to make a single call to the database and then be able to use the values stored into 'gridConfigurationSettings' wherever it be needed (without more calls to the database).- Parameters:
field
- the field for which the information should be computed.systemGC
-tabGC
-
-
showHover
public boolean showHover()
This method determines if the UI definition should include the showHover property as part of the grid field properties. Returnstrue
by default.- Returns:
true
if fields using this UI definition should display their text on a hover box, otherwise returnfalse
-
getValueInComboReference
protected String getValueInComboReference(Field field, boolean getValueFromSession, String columnValue)
-
getValueInComboReference
protected String getValueInComboReference(Field field, boolean getValueFromSession, String columnValue, boolean onlyFirstRecord)
-
createJsonValueFromClassicValueString
@Deprecated public Object createJsonValueFromClassicValueString(String value)
Deprecated.replaced bycreateFromClassicString(String)
-
formatValueFromSQL
@Deprecated public String formatValueFromSQL(String value)
Deprecated.replaced bycreateFromClassicString(String)
-
formatValueToSQL
@Deprecated public String formatValueToSQL(String value)
Deprecated.replaced byconvertToClassicString(Object)
-
getSafeBoolean
protected boolean getSafeBoolean(Boolean value)
-
-