Class StandardComponent<M extends IModel,P extends IParameterization>
- java.lang.Object
-
- com._1c.g5.aef2.components.Component<M,P>
-
- com._1c.g5.aef2.standard.components.StandardComponent<M,P>
-
- All Implemented Interfaces:
IComponent<M>
,IEventChannel
- Direct Known Subclasses:
AbstractControlComponent
,ContainerComponent
public class StandardComponent<M extends IModel,P extends IParameterization> extends Component<M,P>
BaseIComponent
class for all of the components that use EMF-basedControlViewModel
implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StandardComponent.BindingDirection
The enum that describes the direction of binding with theStandardComponent
.
-
Constructor Summary
Constructors Constructor Description StandardComponent(P parameterization)
Creates standard component instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <DMR,VMR>
IList<VMR>bindList(IList<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature, IMapper<DMR,VMR> mapper)
Binds model value and view model feature together.protected <DM extends IModel,DMR,VMM extends IViewModelModel,VMR>
VMMbindModel(DM model, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature, BiFunction<ControlViewModel,org.eclipse.emf.ecore.EStructuralFeature,VMM> viewModelModelCreator, Function<DM,DMR> modelGetter, BiConsumer<DM,VMR> modelSetter, Function<VMM,VMR> viewModelGetter, BiConsumer<VMM,DMR> viewModelSetter, EnumSet<StandardComponent.BindingDirection> direction)
Binds the givenmodel
to view model.protected <DMR,VMR>
IValue<VMR>bindValue(IValue<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature)
Binds model value and view model feature together.protected <DMR,VMR>
IValue<VMR>bindValue(IValue<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature, IMapper<DMR,VMR> mapper)
Binds model value and view model feature together.protected <T> IViewModelList<T>
createDefaultViewModelList(ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature)
Creates defaultIList
for given view model.protected <T> IViewModelValue<T>
createDefaultViewModelValue(ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature)
Creates defaultIValue
for given view model.protected void
createViewModels()
Creates the view models of this component.protected void
disposeViewModels()
Disposes the view models of this component.IAefLayoutData
getLayoutData()
Returns theIAefLayoutData
instance.protected void
handleExternalValidationEvent(ExternalValidationEvent event)
Handles inbound external validationevent
.boolean
isEnabled()
returntrue
if the component is in enabled state andfalse
otherwise.protected boolean
isPassive()
void
setEnabled(boolean enabled)
Sets the component enable state.void
setFocus()
Queues a focus event to the first view model of the component.void
setLayoutData(IAefLayoutData layoutData)
Sets the layout data object.void
updateViewModels()
Updates view models of the component.protected void
updateViewModelStatus(ControlViewModel viewModel, IModel model)
Updates the validation status of the given view model.-
Methods inherited from class com._1c.g5.aef2.components.Component
addComponent, addListener, addViewModel, areChildCommitsEnabled, areChildRefreshEnabled, areComponentsCreated, attachToModel, beginExternalUpdate, checkComponents, checkViewModels, commit, createComponents, detachFromModel, dispose, disposeComponents, endExternalUpdate, getComponents, getModel, getParameterization, getParent, getRunnableQueue, getScene, getServiceEventQualifiers, getViewModels, isDisposed, isInExternalUpdate, queueAndWaitEvent, queueEvent, removeComponent, removeListener, removeViewModel, setChildCommitsEnabled, setChildRefreshEnable, setModel, setParent, setScene, subscribeOnEvents, subscribeOnEvents, unsubscribeOnEvents
-
-
-
-
Constructor Detail
-
StandardComponent
public StandardComponent(P parameterization)
Creates standard component instance.- Parameters:
parameterization
- the parameterization instance.
-
-
Method Detail
-
setLayoutData
public void setLayoutData(IAefLayoutData layoutData)
Sets the layout data object.- Parameters:
layoutData
- the layout data to set, can benull
.
-
getLayoutData
public IAefLayoutData getLayoutData()
Returns theIAefLayoutData
instance.- Returns:
- the layout date or
null
.
-
setEnabled
public void setEnabled(boolean enabled)
Sets the component enable state.- Parameters:
enabled
- the new value to set.
-
isEnabled
public boolean isEnabled()
returntrue
if the component is in enabled state andfalse
otherwise. Children of disabled standard components are considered disabled unconditionally, regardless of theenabled
flag.
-
setFocus
public void setFocus()
Queues a focus event to the first view model of the component.
-
updateViewModels
public void updateViewModels()
Updates view models of the component. Override it to update view model properties according to current state of the component.
-
createViewModels
protected void createViewModels()
Description copied from class:Component
Creates the view models of this component. Override it to provide a view models of this component.- Overrides:
createViewModels
in classComponent<M extends IModel,P extends IParameterization>
-
disposeViewModels
protected void disposeViewModels()
Description copied from class:Component
Disposes the view models of this component. Override it to do some additional disposal operations specific to a component.- Overrides:
disposeViewModels
in classComponent<M extends IModel,P extends IParameterization>
-
bindValue
protected final <DMR,VMR> IValue<VMR> bindValue(IValue<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature)
Binds model value and view model feature together.- Type Parameters:
DMR
- the type of objects from model.VMR
- the type of objects from view model.- Parameters:
modelValue
- the model value to bind.viewModel
- the view model to bind to.viewModelFeature
- view model's feature to bind.- Returns:
- a bound view model
IModel
instance.
-
bindValue
protected final <DMR,VMR> IValue<VMR> bindValue(IValue<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature, IMapper<DMR,VMR> mapper)
Binds model value and view model feature together.- Type Parameters:
DMR
- the type of objects from model.VMR
- the type of objects from view model.- Parameters:
modelValue
- the model value to bind.viewModel
- the view model to bind to.viewModelfeature
- the view model's feature to bind.mapper
- the mapper to map between mode and view model representation.- Returns:
- a bound view model value.
-
bindList
protected final <DMR,VMR> IList<VMR> bindList(IList<DMR> modelValue, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature viewModelFeature, IMapper<DMR,VMR> mapper)
Binds model value and view model feature together.- Type Parameters:
DMR
- the type of objects from model.VMR
- the type of objects from view model.- Parameters:
modelValue
- the model value to bind.viewModel
- the view model to bind to.viewModelfeature
- the view model's feature to bind.mapper
- the mapper to map between mode and view model representation.- Returns:
- a bound view model list.
-
updateViewModelStatus
protected void updateViewModelStatus(ControlViewModel viewModel, IModel model)
Updates the validation status of the given view model.- Parameters:
viewModel
- the view model.model
- the model to validate.
-
isPassive
protected boolean isPassive()
- Returns:
true
if the component is passive, that is the component is not refreshing itself,false
- otherwise.
-
createDefaultViewModelValue
protected <T> IViewModelValue<T> createDefaultViewModelValue(ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature)
Creates defaultIValue
for given view model.- Parameters:
viewModel
- the view model, cannot benull
.feature
- the feature, cannot benull
.- Returns:
- a newly created
IValue
instance.
-
createDefaultViewModelList
protected <T> IViewModelList<T> createDefaultViewModelList(ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature)
Creates defaultIList
for given view model.- Parameters:
viewModel
- the view model, cannot benull
.feature
- the feature, cannot benull
.- Returns:
- a newly created
IList
instance.
-
bindModel
protected <DM extends IModel,DMR,VMM extends IViewModelModel,VMR> VMM bindModel(DM model, ControlViewModel viewModel, org.eclipse.emf.ecore.EStructuralFeature feature, BiFunction<ControlViewModel,org.eclipse.emf.ecore.EStructuralFeature,VMM> viewModelModelCreator, Function<DM,DMR> modelGetter, BiConsumer<DM,VMR> modelSetter, Function<VMM,VMR> viewModelGetter, BiConsumer<VMM,DMR> viewModelSetter, EnumSet<StandardComponent.BindingDirection> direction)
Binds the givenmodel
to view model.- Type Parameters:
DM
- the type of givenmodel
.DMR
- the type of resulting object frommodel
.VMM
- the type of creatingIModel
of view model.VMR
- the type of result object from view model.- Parameters:
model
- the model of domain object to bind, cannot benull
.viewModel
- the view model, cannot benull
.feature
- the feature of the view model to access, cannot benull
.viewModelModelCreator
- the function that creates theIModel
for given view model, cannot benull
.modelGetter
- the function that returns the object represented bymodel
, cannot benull
.modelSetter
- the consumer that sets new value (obtained from view model) to model, can benull
if thedirection
equal toStandardComponent.BindingDirection.MODEL_TO_VIEW
only.viewModelGetter
- the function that returns the object represented by created view modelIModel
instance, can benull
if thedirection
equal toStandardComponent.BindingDirection.MODEL_TO_VIEW
only.viewModelSetter
- the consumer that sets new value (obtained from domain model) to view modelIModel
instance, cannot benull
.direction
- the direction of binding represented by set ofStandardComponent.BindingDirection
.- Returns:
- a bound view model
IModel
instance.
-
handleExternalValidationEvent
protected void handleExternalValidationEvent(ExternalValidationEvent event)
Handles inbound external validationevent
.- Parameters:
event
- the event, cannot benull
.
-
-