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>
BaseIComponentimplementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <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.booleanareChildCommitsEnabled()booleanareChildRefreshEnabled()protected booleanareComponentsCreated()protected voidattachToModel()Attaches this component to the model.voidbeginExternalUpdate()Begins the external update operation.protected voidcheckComponents()Checks that the child components are actually created.protected voidcheckViewModels()Checks that the view models of this components are actually created.voidcommit()Commits this component changes to the model.protected voidcreateComponents()Creates the child components of this component.protected voidcreateViewModels()Creates the view models of this component.protected voiddetachFromModel()Detaches this component from the model.voiddispose()Disposes this component, its view models and its child components.protected voiddisposeComponents()Disposes the child components.protected voiddisposeViewModels()Disposes the view models of this component.voidendExternalUpdate()Ends the external update operation.Iterable<IComponent<?>>getComponents()MgetModel()PgetParameterization()Returns the parameterization of the component.IComponent<?>getParent()protected IRunnableQueuegetRunnableQueue()IScenegetScene()Collection<IServiceEventQualifier>getServiceEventQualifiers()Returns the collection of service event qualifiers that event should be traversed to component from event tracker.Iterable<IViewModel>getViewModels()booleanisDisposed()booleanisInExternalUpdate()voidqueueAndWaitEvent(IEvent event)Queues the event to this channel and waits for its processing done.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)voidsetModel(M model)Sets the model for this component.voidsetParent(IComponent<?> parent)voidsetScene(IScene scene)protected voidsubscribeOnEvents(IServiceEventQualifier eventQualifier)Subscribes on events which is covered by the given qualifier.protected voidsubscribeOnEvents(Class<? extends IServiceEvent> eventClass)Subscribes on events which is instances of the given class.protected voidunsubscribeOnEvents(IServiceEventQualifier eventQualifier)Unsubscribes on events which is covered by the given qualifier.
-
-
-
Constructor Detail
-
Component
protected Component(P parameterization)
Creates a component.- Parameters:
parameterization- the parameterization instance.
-
-
Method Detail
-
getScene
public IScene 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
public void setScene(IScene scene)
- Specified by:
setScenein interfaceIComponent<M extends IModel>- Parameters:
scene- the scene to place this component in.
-
getParent
public IComponent<?> getParent()
- Specified by:
getParentin interfaceIComponent<M extends IModel>- Returns:
- the parent component.
-
setParent
public void setParent(IComponent<?> parent)
- Specified by:
setParentin interfaceIComponent<M extends IModel>- Parameters:
parent- a component to set as the parent component.
-
getComponents
public Iterable<IComponent<?>> getComponents()
- Specified by:
getComponentsin interfaceIComponent<M extends IModel>- Returns:
- the child components of this component.
-
getViewModels
public Iterable<IViewModel> 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:
IComponent.beginExternalUpdate()
-
endExternalUpdate
public final void endExternalUpdate()
Description copied from interface:IComponentEnds the external update operation.- Specified by:
endExternalUpdatein interfaceIComponent<M extends IModel>- See Also:
IComponent.beginExternalUpdate()
-
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
public final void setModel(M model)
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
public final M 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:
IComponent.areChildCommitsEnabled()
-
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:
IComponent.areChildRefreshEnabled()
-
queueEvent
public final void queueEvent(IEvent event)
Description copied from interface:IEventChannelQueues the event to this channel.- Specified by:
queueEventin interfaceIEventChannel- Parameters:
event- the event to queue.- See Also:
IEventChannel.queueAndWaitEvent(IEvent)
-
queueAndWaitEvent
public final void queueAndWaitEvent(IEvent event)
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:
IEventChannel.queueEvent(IEvent)
-
addListener
public void addListener(IEventChannelListener listener)
Description copied from interface:IEventChannelAdds the given listener to the channel.- Specified by:
addListenerin interfaceIEventChannel- Parameters:
listener- the listener.
-
removeListener
public void removeListener(IEventChannelListener listener)
Description copied from interface:IEventChannelRemoves the given listener from the channel.- Specified by:
removeListenerin interfaceIEventChannel- Parameters:
listener- the listener.
-
getServiceEventQualifiers
public Collection<IServiceEventQualifier> 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:
IServiceEventTracker.trackEvent(IServiceEvent)
-
getParameterization
public P 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
protected <C extends IComponent<?>> C addComponent(C component)
Adds the child component.- Returns:
- the added component.
-
removeComponent
protected void removeComponent(IComponent<?> component)
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
protected void addViewModel(IViewModel viewModel)
Adds the view model to the view models of this component.- Parameters:
viewModel- the view model to add.
-
removeViewModel
protected void removeViewModel(IViewModel viewModel)
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
protected final IRunnableQueue getRunnableQueue()
- Returns:
- this component's runnable queue.
- See Also:
IRunnableQueue
-
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
protected final void subscribeOnEvents(Class<? extends IServiceEvent> eventClass)
Subscribes on events which is instances of the given class.- Parameters:
eventClass- the class of events.
-
subscribeOnEvents
protected final void subscribeOnEvents(IServiceEventQualifier eventQualifier)
Subscribes on events which is covered by the given qualifier.- Parameters:
eventQualifier- theIServiceEventQualifierinstance, cannot benull.
-
unsubscribeOnEvents
protected final void unsubscribeOnEvents(IServiceEventQualifier eventQualifier)
Unsubscribes on events which is covered by the given qualifier.- Parameters:
eventQualifier- theIServiceEventQualifierinstance, cannot benull.
-
-