public class UIComponentFactoryImpl extends Object implements UIComponentFactory, Serializable
UIComponentFactory
which
supports all standard components defined in lsps standard library.Modifier and Type | Class and Description |
---|---|
static class |
UIComponentFactoryImpl.ScreenLevelRecord
Creates image of validation error in screen-level context, which is seen by all UIComponents.
|
Modifier and Type | Field and Description |
---|---|
protected LspsAppConnector |
connector
Instance of
LspsAppConnector |
static boolean |
DEBUG |
REQUIRED_STYLE_NAME
Constructor and Description |
---|
UIComponentFactoryImpl(LspsAppConnector connector)
Creates new instance with the given application connector.
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorMessagesToComponents(Map<UIComponent,List<String>> errorMessages)
Default implementation simply uses
UIComponents.addComponentError(com.whitestein.lsps.vaadin.ui.components.UIComponent, String) to attach error messages to Vaadin components. |
void |
afterCreate(UIComponent component)
Perform standard set of behaviors when component is created.
|
void |
applyCommonProperties(UIComponent component)
Applies all standard properties from the component definition to the
given input component.
|
protected void |
applyHint(UIComponent component,
String hintName,
Variant<Object> newValue,
Variant<Object> oldValue)
Applies single hint of the given value to the given component
|
void |
applyListeners(UIComponent component)
Applies all listeners defined in the component definition associated with the
given component.
|
protected UIComponent |
createActionLink(UIComponentData componentData) |
protected UIBrowserFrame |
createBrowserFrame(UIComponentData componentData) |
protected UIComponent |
createButtonLink(UIComponentData componentData) |
protected UICalendar |
createCalendar(UIComponentData componentData) |
protected UICartesianChart |
createCartesianChart(UIComponentData componentData) |
protected UIComponent |
createCheckBox(UIComponentData componentData) |
protected UIComponent |
createCheckBoxList(UIComponentData componentData) |
protected UIComponent |
createComboBox(UIComponentData componentData) |
UIComponent |
createComponent(LspsScreen screen,
UIComponent parent,
RecordHolder componentDefinition,
UIComponentScope scope)
Creates and injects component based on the provided component definition.
|
protected UIComponent |
createComponent(UIComponentData componentData)
This method is responsible for creating a component based on the
provided component data.
|
protected UIComponent |
createConditional(UIComponentData componentData) |
protected UIComponent |
createContainer(UIComponentData componentData) |
com.vaadin.data.util.converter.Converter<?,?> |
createConverterForRenderer(UIGrid owner,
Variant.RecordVariant rendererDef)
Optionally a converter may be used together with a renderer, to convert LSPS types to Java objects as expected by the renderer.
|
protected UIDashboard |
createDashboard(UIComponentData componentData) |
protected UIComponent |
createDateTextBox(UIComponentData componentData) |
protected UIComponent |
createDecimalTextBox(UIComponentData componentData) |
com.vaadin.ui.Field<?> |
createEditor(Variant.RecordVariant editorDef,
Type type)
Instantiates an editor field based on the editor definition record
and the value type.
|
protected UIComponent |
createFileDownload(UIComponentData componentData) |
protected UIComponent |
createFileUpload(UIComponentData componentData) |
protected UIFormLayout |
createFormLayout(UIComponentData componentData) |
protected UIGaugeChart |
createGaugeChart(UIComponentData componentData) |
protected UIGeolocator |
createGeolocator(UIComponentData componentData) |
protected UIComponent |
createGridLayout(UIComponentData componentData) |
protected UIComponent |
createHorizontalLayout(UIComponentData componentData) |
protected UIComponent |
createImage(UIComponentData componentData) |
protected UIComponent |
createLazyComboBox(UIComponentData componentData) |
protected UIListener |
createListener(UIComponent component,
RecordHolder uiListener)
Creates listener based on the provided component definition.
|
UIListenerAction |
createListenerAction(UIScreen screen,
UIListener listener,
RecordHolder definition,
UIComponent scope)
Creates listener action based on the provided definition.
|
protected UIMapDisplay |
createMapDisplay(UIComponentData componentData) |
protected UIComponent |
createMessage(UIComponentData componentData) |
protected UIComponent |
createMultiSelectList(UIComponentData componentData) |
protected UIComponent |
createNavigationLink(UIComponentData componentData) |
protected UIComponent |
createOutputText(UIComponentData componentData) |
protected UIComponent |
createPanel(UIComponentData componentData) |
protected UIPieChart |
createPieChart(UIComponentData componentData) |
protected UIPolarChart |
createPolarChart(UIComponentData componentData) |
protected UIComponent |
createPopup(UIComponentData componentData) |
protected UIComponent |
createProcessDiagram(UIComponentData componentData) |
protected UIComponent |
createRadioButtonList(UIComponentData componentData) |
protected UIComponent |
createRepeater(UIComponentData componentData) |
protected UIComponent |
createSingleSelectList(UIComponentData componentData) |
protected UIComponent |
createTabbedLayout(UIComponentData componentData) |
protected UIComponent |
createTable(UIComponentData componentData) |
protected UIComponent |
createTextArea(UIComponentData componentData) |
protected UIComponent |
createTextBox(UIComponentData componentData) |
protected UITokenField |
createTokenField(UIComponentData componentData) |
protected UITree2 |
createTree2(UIComponentData componentData) |
protected UITreeTable2 |
createTreeTable2(UIComponentData componentData) |
protected UIComponent |
createVerticalLayout(UIComponentData componentData) |
protected UIComponent |
createViewModel(UIComponentData componentData) |
String |
getErrorMessage(Variant.RecordVariant validationError,
UIComponent scope)
Retrieves the error message from the "ui::ValidationError" record.
|
Injector |
getInjector()
Returns instance of
Injector to use for injecting created components |
static boolean |
isUIValidationError(Variant.RecordVariant record)
Checks if given record is the "old" Validation error with error message and a placement.
|
Map<UIComponent,List<String>> |
mapErrorsToComponents(LspsScreen screen,
LspsFormConnector.ValidationErrors validationErrors,
Bindings bindings)
Takes a set of validation errors and shows them on components in given screen.
|
void |
refresh(UIComponent component)
Refreshes the UI component.
|
protected void |
setComponentReadOnly(UIComponent component,
boolean readOnly)
Sets the component to read-only state.
|
protected void |
unapplyHint(UIComponent component,
String hintName,
Variant<Object> oldValue) |
void |
updateComponentCaption(UIComponent component)
Sets caption property for the given component based on value of field
UIFieldNames.LABEL . |
protected void |
updateComponentHelpText(UIComponent component)
Sets description property for the given component based on value of field
UIFieldNames.HELP_TEXT . |
protected void |
updateComponentRequired(UIComponent component)
Adds required style class (
UIComponentFactory.REQUIRED_STYLE_NAME ) if the value of
field UIFieldNames.REQUIRED is true. |
void |
updateHints(UIComponent component,
Variant.MapVariant<String,Object> newHints,
Variant.MapVariant<String,Object> oldHints)
Applies all hints defined in the component definition associated with the
given component.
|
protected void |
updateImmediate(UIComponent component)
Sets immediate property for the given component based on value of field
UIFieldNames.TRIGGER_PROCESSING_ON_CHANGE |
protected void |
updateInputPrompt(UIComponent component)
Sets input prompt property for the given component based on value of
field
UIFieldNames.PLACEHOLDER |
protected void |
updateReadOnly(UIComponent component)
Sets read only and disabled property for the given component based on value of field
UIFieldNames.READ_ONLY /UIFieldNames.DISABLED . |
public static final boolean DEBUG
protected final LspsAppConnector connector
LspsAppConnector
public UIComponentFactoryImpl(LspsAppConnector connector) throws NullPointerException
connector
- NullPointerException
- if connector or its injector is nullpublic Injector getInjector()
UIComponentFactory
Injector
to use for injecting created componentsgetInjector
in interface UIComponentFactory
public void updateHints(UIComponent component, Variant.MapVariant<String,Object> newHints, Variant.MapVariant<String,Object> oldHints)
UIComponentFactory
UIComponent.refresh()
.updateHints
in interface UIComponentFactory
component
- component to apply hints fornewHints
- new presentation hints, never null, never absent.oldHints
- old presentation hints, never null, never absent.protected void unapplyHint(UIComponent component, String hintName, Variant<Object> oldValue)
protected void applyHint(UIComponent component, String hintName, Variant<Object> newValue, Variant<Object> oldValue)
component
- component to apply hint onhintName
- name of the hint to applynewValue
- value of the hint to applyoldValue
- previous value of the hintpublic void applyListeners(UIComponent component)
UIComponentFactory
applyListeners
in interface UIComponentFactory
component
- the component, not null.protected UIListener createListener(UIComponent component, RecordHolder uiListener)
component
- the owner component, not null.uiListener
- definition of the listenerpublic UIListenerAction createListenerAction(UIScreen screen, UIListener listener, RecordHolder definition, UIComponent scope)
UIComponentFactory
createListenerAction
in interface UIComponentFactory
screen
- containing screenlistener
- listener where this action is defined. Not null.definition
- definition of the listener action. Not null. Must be a subtype of ui::Action.scope
- run handle in this scope, not null.public UIComponent createComponent(LspsScreen screen, UIComponent parent, RecordHolder componentDefinition, UIComponentScope scope)
UIComponentFactory
createComponent
in interface UIComponentFactory
screen
- containing screen, ignored if parent is not null.parent
- parent of the component in the UI component hierarchy, null if root.componentDefinition
- definition of the component to create, not null.scope
- component scope; if null, same scope as parent will be usedpublic void afterCreate(UIComponent component)
UIComponentFactory
UIComponentFactory.createComponent(LspsScreen, UIComponent, RecordHolder, UIComponentScope)
, after the component is created.
If the component implements Field
, it's switched to buffered mode
so that conversion/validation of the field value is properly integrated
with the LSPS UI lifecycle.afterCreate
in interface UIComponentFactory
protected UIComponent createComponent(UIComponentData componentData)
componentData
- protected UIFormLayout createFormLayout(UIComponentData componentData)
protected UIGeolocator createGeolocator(UIComponentData componentData)
protected UIMapDisplay createMapDisplay(UIComponentData componentData)
protected UITreeTable2 createTreeTable2(UIComponentData componentData)
protected UITree2 createTree2(UIComponentData componentData)
protected UICalendar createCalendar(UIComponentData componentData)
protected UIBrowserFrame createBrowserFrame(UIComponentData componentData)
protected UIPolarChart createPolarChart(UIComponentData componentData)
protected UICartesianChart createCartesianChart(UIComponentData componentData)
protected UIGaugeChart createGaugeChart(UIComponentData componentData)
protected UIPieChart createPieChart(UIComponentData componentData)
protected UIDashboard createDashboard(UIComponentData componentData)
protected UITokenField createTokenField(UIComponentData componentData)
protected UIComponent createViewModel(UIComponentData componentData)
componentData
- UIComponentNames.VIEW_MODEL_COMPONENT
protected UIComponent createVerticalLayout(UIComponentData componentData)
componentData
- UIComponentNames.VERTICAL_LAYOUT_COMPONENT
protected UIComponent createDateTextBox(UIComponentData componentData)
componentData
- UIComponentNames.TEXT_BOX_COMPONENT
which binding is of type dateprotected UIComponent createDecimalTextBox(UIComponentData componentData)
componentData
- UIComponentNames.TEXT_BOX_COMPONENT
which binding is not of type dateprotected UIComponent createTextBox(UIComponentData componentData)
componentData
- UIComponentNames.TEXT_BOX_COMPONENT
which binding is not of type dateprotected UIComponent createTextArea(UIComponentData componentData)
componentData
- UIComponentNames.TEXT_AREA_COMPONENT
protected UIComponent createTable(UIComponentData componentData)
componentData
- UIComponentNames.TABLE_COMPONENT
protected UIComponent createTabbedLayout(UIComponentData componentData)
componentData
- UIComponentNames.TABBED_LAYOUT_COMPONENT
protected UIComponent createSingleSelectList(UIComponentData componentData)
componentData
- UIComponentNames.SINGLE_SELECT_LIST_COMPONENT
protected UIComponent createRepeater(UIComponentData componentData)
componentData
- UIComponentNames.REPEATER_COMPONENT
protected UIComponent createRadioButtonList(UIComponentData componentData)
componentData
- UIComponentNames.RADIO_BUTTON_LIST_COMPONENT
protected UIComponent createPopup(UIComponentData componentData)
componentData
- UIComponentNames.POPUP_COMPONENT
protected UIComponent createPanel(UIComponentData componentData)
componentData
- UIComponentNames.PANEL_COMPONENT
protected UIComponent createOutputText(UIComponentData componentData)
componentData
- UIComponentNames.OUTPUT_TEXT_COMPONENT
protected UIComponent createMultiSelectList(UIComponentData componentData)
componentData
- UIComponentNames.MULTI_SELECT_LIST_COMPONENT
protected UIComponent createMessage(UIComponentData componentData)
componentData
- UIComponentNames.MESSAGE_COMPONENT
protected UIComponent createNavigationLink(UIComponentData componentData)
componentData
- UIComponentNames.NAVIGATION_LINK_COMPONENT
protected UIComponent createImage(UIComponentData componentData)
componentData
- UIComponentNames.IMAGE_COMPONENT
protected UIComponent createHorizontalLayout(UIComponentData componentData)
componentData
- UIComponentNames.HORIZONTAL_LAYOUT_COMPONENT
protected UIComponent createGridLayout(UIComponentData componentData)
componentData
- UIComponentNames.GRID_LAYOUT_COMPONENT
protected UIComponent createFileUpload(UIComponentData componentData)
componentData
- UIComponentNames.FILE_UPLOAD_COMPONENT
protected UIComponent createFileDownload(UIComponentData componentData)
componentData
- UIComponentNames.FILE_DOWNLOAD_COMPONENT
protected UIComponent createContainer(UIComponentData componentData)
componentData
- UIComponentNames.CONTAINER_COMPONENT
protected UIComponent createConditional(UIComponentData componentData)
componentData
- UIComponentNames.CONDITIONAL_COMPONENT
protected UIComponent createComboBox(UIComponentData componentData)
componentData
- UIComponentNames.COMBO_BOX_COMPONENT
protected UIComponent createLazyComboBox(UIComponentData componentData)
componentData
- UIComponentNames.LAZY_COMBO_BOX
protected UIComponent createCheckBoxList(UIComponentData componentData)
componentData
- UIComponentNames.CHECK_BOX_LIST_COMPONENT
protected UIComponent createCheckBox(UIComponentData componentData)
componentData
- UIComponentNames.CHECK_BOX_COMPONENT
protected UIComponent createButtonLink(UIComponentData componentData)
componentData
- UIComponentNames.BUTTON_LINK_COMPONENT
protected UIComponent createActionLink(UIComponentData componentData)
componentData
- UIComponentNames.ACTION_LINK_COMPONENT
public static boolean isUIValidationError(Variant.RecordVariant record)
record
- the record, not null.protected UIComponent createProcessDiagram(UIComponentData componentData)
public Map<UIComponent,List<String>> mapErrorsToComponents(LspsScreen screen, LspsFormConnector.ValidationErrors validationErrors, Bindings bindings)
UIComponentFactory
UIComponentFactory.addErrorMessagesToComponents(java.util.Map)
to do that.
The specification of the algorithm is present in Workpackage 039: https://inside.whitestein.com/mediawiki/inside/LSPS:WP-039mapErrorsToComponents
in interface UIComponentFactory
screen
- the containing screen, not null.validationErrors
- not null. A set of "ui::ValidationError" records produced by validations during last event process pass. Never null.bindings
- never null. The algorithm may use this map to find components displaying particular record property.public void addErrorMessagesToComponents(Map<UIComponent,List<String>> errorMessages)
UIComponentFactory
UIComponents.addComponentError(com.whitestein.lsps.vaadin.ui.components.UIComponent, String)
to attach error messages to Vaadin components.
Override to show error messages in different way, e.g. mark the components with a custom CSS style.
All error messages on all components must be cleared prior running this method - this method does not clear previous error messages.
If you are adding custom CSS styles, you must manually clear the styles on all components.
To get the list of all components, use AbstractScreen.getAllComponents()
.addErrorMessagesToComponents
in interface UIComponentFactory
errorMessages
- maps vaadin components to a list of error messages which should be displayed. Never null, may be empty.public String getErrorMessage(Variant.RecordVariant validationError, UIComponent scope)
UIComponentFactory
getErrorMessage
in interface UIComponentFactory
validationError
- an instance of "ui::ValidationError" record, not null.scope
- the error record was produced by listener executing in this scope. Not null.public void refresh(UIComponent component)
UIComponentFactory
UIComponent.refresh()
.refresh
in interface UIComponentFactory
component
- the component, not null.public void applyCommonProperties(UIComponent component)
UIComponentFactory
UIFieldNames.READ_ONLY
- sets read only for the given component (Component.setEnabled(boolean)
)UIFieldNames.TRIGGER_PROCESSING_ON_CHANGE
- sets immediate property (AbstractComponent.setImmediate(boolean)
)UIFieldNames.REQUIRED
- adds required style class (UIComponentFactory.REQUIRED_STYLE_NAME
) if the field value is true)UIFieldNames.LABEL
- calls UIComponentFactory.updateComponentCaption(UIComponent)
UIFieldNames.HELP_TEXT
- sets help text property (AbstractComponent.setDescription(String)
)UIFieldNames.PLACEHOLDER
- sets input prompt property (AbstractTextField.setInputPrompt(String)
)applyCommonProperties
in interface UIComponentFactory
protected void updateComponentRequired(UIComponent component)
UIComponentFactory.REQUIRED_STYLE_NAME
) if the value of
field UIFieldNames.REQUIRED
is true.component
- public void updateComponentCaption(UIComponent component)
UIFieldNames.LABEL
.updateComponentCaption
in interface UIComponentFactory
component
- protected void updateComponentHelpText(UIComponent component)
UIFieldNames.HELP_TEXT
.component
- protected void updateInputPrompt(UIComponent component)
UIFieldNames.PLACEHOLDER
component
- the component, not null.protected void updateImmediate(UIComponent component)
UIFieldNames.TRIGGER_PROCESSING_ON_CHANGE
component
- the component, not null.protected void updateReadOnly(UIComponent component)
UIFieldNames.READ_ONLY
/UIFieldNames.DISABLED
.
Disables the component if the screen is read only.component
- the component, not null.protected void setComponentReadOnly(UIComponent component, boolean readOnly)
The default implementation calls Component.setEnabled(boolean)
.
Subclasses may override.
component
- readOnly
- public com.vaadin.data.util.converter.Converter<?,?> createConverterForRenderer(UIGrid owner, Variant.RecordVariant rendererDef)
UIComponentFactory
createConverterForRenderer
in interface UIComponentFactory
owner
- the grid that will use the rendererrendererDef
- the renderer definition, not null.public com.vaadin.ui.Field<?> createEditor(Variant.RecordVariant editorDef, Type type)
UIComponentFactory
Instantiates an editor field based on the editor definition record and the value type. The instantiated editor field allows to edit grid values.
The editors are used by the Grid component when editing grid values.
createEditor
in interface UIComponentFactory
type
- the type of the valuenull
Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.