Package com._1c.g5.aef2.components
Class Component<M extends IModel,P extends IParameterization>
java.lang.Object
com._1c.g5.aef2.components.Component<M,P>
- Type Parameters:
M- the model type.P- the parameterization type.
- All Implemented Interfaces:
IComponent<M>,IEventChannel
- Direct Known Subclasses:
StandardComponent
public abstract class Component<M extends IModel,P extends IParameterization>
extends Object
implements IComponent<M>
Base
IComponent implementation.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <C extends IComponent<?>>
CaddComponent(C component) Adds the child component.voidaddListener(IEventChannelListener listener) Adds the given listener to the channel.protected voidaddViewModel(IViewModel viewModel) Adds the view model to the view models of this component.booleanbooleanprotected final booleanprotected voidAttaches this component to the model.final voidBegins the external update operation.protected final voidChecks that the child components are actually created.protected final voidChecks that the view models of this components are actually created.voidcommit()Commits this component changes to the model.protected voidCreates the child components of this component.protected voidCreates the view models of this component.protected voidDetaches this component from the model.voiddispose()Disposes this component, its view models and its child components.protected voidDisposes the child components.protected voidDisposes the view models of this component.final voidEnds the external update operation.Iterable<IComponent<?>>final MgetModel()Returns the parameterization of the component.IComponent<?>protected final IRunnableQueuegetScene()Returns the collection of service event qualifiers that event should be traversed to component from event tracker.booleanfinal booleanfinal voidqueueAndWaitEvent(IEvent event) Queues the event to this channel and waits for its processing done.final voidqueueEvent(IEvent event) Queues the event to this channel.protected voidremoveComponent(IComponent<?> component) Removes the child component.voidremoveListener(IEventChannelListener listener) Removes the given listener from the channel.protected voidremoveViewModel(IViewModel viewModel) Removes the view model from the view models of this component.voidsetChildCommitsEnabled(boolean value) voidsetChildRefreshEnable(boolean value) final voidSets the model for this component.voidsetParent(IComponent<?> parent) voidprotected final voidsubscribeOnEvents(IServiceEventQualifier eventQualifier) Subscribes on events which is covered by the given qualifier.protected final voidsubscribeOnEvents(Class<? extends IServiceEvent> eventClass) Subscribes on events which is instances of the given class.protected final voidunsubscribeOnEvents(IServiceEventQualifier eventQualifier) Unsubscribes on events which is covered by the given qualifier.
-
Constructor Details
-
Component
Creates a component.- Parameters:
parameterization- the parameterization instance.
-
-
Method Details
-
getScene
- Specified by:
getScenein interfaceIComponent<M extends IModel>- Returns:
- the scene this component belongs to or
nullif component doesn't belong to a scene yet.
-
setScene
- Specified by:
setScenein interfaceIComponent<M extends IModel>- Parameters:
scene- the scene to place this component in.
-
getParent
- Specified by:
getParentin interfaceIComponent<M extends IModel>- Returns:
- the parent component.
-
setParent
- Specified by:
setParentin interfaceIComponent<M extends IModel>- Parameters:
parent- a component to set as the parent component.
-
getComponents
- Specified by:
getComponentsin interfaceIComponent<M extends IModel>- Returns:
- the child components of this component.
-
getViewModels
- Specified by:
getViewModelsin interfaceIComponent<M extends IModel>- Returns:
- the view models produced by this component.
-
beginExternalUpdate
public final void beginExternalUpdate()Description copied from interface:IComponentBegins the external update operation. All direct changes of the models associated with this component are marked asChangeOrigin.External. End the operation withIComponent.endExternalUpdate()call, external update operations may be nested. All model direct write changes are marked asChangeOrigin.Internalif no external update is in progress.- Specified by:
beginExternalUpdatein interfaceIComponent<M extends IModel>
-
isInExternalUpdate
public final boolean isInExternalUpdate()- Specified by:
isInExternalUpdatein interfaceIComponent<M extends IModel>- Returns:
trueif external update operation is in progress,falseotherwise.- See Also:
-
endExternalUpdate
public final void endExternalUpdate()Description copied from interface:IComponentEnds the external update operation.- Specified by:
endExternalUpdatein interfaceIComponent<M extends IModel>- See Also:
-
dispose
public void dispose()Description copied from interface:IComponentDisposes this component, its view models and its child components.- Specified by:
disposein interfaceIComponent<M extends IModel>
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposedin interfaceIComponent<M extends IModel>- Returns:
trueif the component was disposed,falseotherwise.
-
setModel
Description copied from interface:IComponentSets the model for this component. Component implementation may also accept the model from a constructor and call this method internally. Attaching listeners to the model should be postponed as long as possible, usually there are two safe points to start model listening:IComponent.getComponents()orIComponent.getViewModels()invocation.- Specified by:
setModelin interfaceIComponent<M extends IModel>- Parameters:
model- the model to set.
-
getModel
- Specified by:
getModelin interfaceIComponent<M extends IModel>- Returns:
- the model of this component or
nullif component has no associated model.
-
commit
public void commit()Description copied from interface:IComponentCommits this component changes to the model.- Specified by:
commitin interfaceIComponent<M extends IModel>
-
areChildCommitsEnabled
public boolean areChildCommitsEnabled()- Specified by:
areChildCommitsEnabledin interfaceIComponent<M extends IModel>- Returns:
trueif child commits are allowed,falseif child commits are inhibited and this component handles a commit by itself.
-
setChildCommitsEnabled
public void setChildCommitsEnabled(boolean value) - Specified by:
setChildCommitsEnabledin interfaceIComponent<M extends IModel>- Parameters:
value-trueto enable child commits,falseto disable them.- See Also:
-
areChildRefreshEnabled
public boolean areChildRefreshEnabled()- Specified by:
areChildRefreshEnabledin interfaceIComponent<M extends IModel>- Returns:
trueif child refreshing are allowed,falseif child refreshing are inhibited and this component handles a refresh by itself.
-
setChildRefreshEnable
public void setChildRefreshEnable(boolean value) - Specified by:
setChildRefreshEnablein interfaceIComponent<M extends IModel>- Parameters:
value-trueto enable child refreshing,falseto disable them.- See Also:
-
queueEvent
Description copied from interface:IEventChannelQueues the event to this channel.- Specified by:
queueEventin interfaceIEventChannel- Parameters:
event- the event to queue.- See Also:
-
queueAndWaitEvent
Description copied from interface:IEventChannelQueues the event to this channel and waits for its processing done. Typically, events created as a result of the user interaction with the UI should be processed synchronously using this method.- Specified by:
queueAndWaitEventin interfaceIEventChannel- Parameters:
event- the event to queue.- See Also:
-
addListener
Description copied from interface:IEventChannelAdds the given listener to the channel.- Specified by:
addListenerin interfaceIEventChannel- Parameters:
listener- the listener.
-
removeListener
Description copied from interface:IEventChannelRemoves the given listener from the channel.- Specified by:
removeListenerin interfaceIEventChannel- Parameters:
listener- the listener.
-
getServiceEventQualifiers
Description copied from interface:IComponentReturns the collection of service event qualifiers that event should be traversed to component from event tracker.- Specified by:
getServiceEventQualifiersin interfaceIComponent<M extends IModel>- Returns:
- collection of event qualifiers.
- See Also:
-
getParameterization
Returns the parameterization of the component.- Returns:
- the parameterization of the component.
-
createComponents
protected void createComponents()Creates the child components of this component. Override it to fill a component with a child components.Method can be called multiple times.
-
createViewModels
protected void createViewModels()Creates the view models of this component. Override it to provide a view models of this component. -
attachToModel
protected void attachToModel()Attaches this component to the model. Override it to add some listeners to the model. -
detachFromModel
protected void detachFromModel()Detaches this component from the model. Override it to remove listeners from the model. -
addComponent
Adds the child component.- Returns:
- the added component.
-
removeComponent
Removes the child component.- Parameters:
component- the component to remove.
-
disposeComponents
protected void disposeComponents()Disposes the child components. Override it to do some additional disposal operations specific to a component. -
addViewModel
Adds the view model to the view models of this component.- Parameters:
viewModel- the view model to add.
-
removeViewModel
Removes the view model from the view models of this component.- Parameters:
viewModel- the view model to remove.
-
disposeViewModels
protected void disposeViewModels()Disposes the view models of this component. Override it to do some additional disposal operations specific to a component. -
areComponentsCreated
protected final boolean areComponentsCreated()- Returns:
trueif child components have been created,falseotherwise
-
getRunnableQueue
- Returns:
- this component's runnable queue.
- See Also:
-
checkComponents
protected final void checkComponents()Checks that the child components are actually created. -
checkViewModels
protected final void checkViewModels()Checks that the view models of this components are actually created. -
subscribeOnEvents
Subscribes on events which is instances of the given class.- Parameters:
eventClass- the class of events.
-
subscribeOnEvents
Subscribes on events which is covered by the given qualifier.- Parameters:
eventQualifier- theIServiceEventQualifierinstance, cannot benull.
-
unsubscribeOnEvents
Unsubscribes on events which is covered by the given qualifier.- Parameters:
eventQualifier- theIServiceEventQualifierinstance, cannot benull.
-