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>
BaseIComponent
implementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <C extends IComponent<?>>
CaddComponent(C component)
Adds the child component.void
addListener(IEventChannelListener listener)
Adds the given listener to the channel.protected void
addViewModel(IViewModel viewModel)
Adds the view model to the view models of this component.boolean
areChildCommitsEnabled()
boolean
areChildRefreshEnabled()
protected boolean
areComponentsCreated()
protected void
attachToModel()
Attaches this component to the model.void
beginExternalUpdate()
Begins the external update operation.protected void
checkComponents()
Checks that the child components are actually created.protected void
checkViewModels()
Checks that the view models of this components are actually created.void
commit()
Commits this component changes to the model.protected void
createComponents()
Creates the child components of this component.protected void
createViewModels()
Creates the view models of this component.protected void
detachFromModel()
Detaches this component from the model.void
dispose()
Disposes this component, its view models and its child components.protected void
disposeComponents()
Disposes the child components.protected void
disposeViewModels()
Disposes the view models of this component.void
endExternalUpdate()
Ends the external update operation.Iterable<IComponent<?>>
getComponents()
M
getModel()
P
getParameterization()
Returns the parameterization of the component.IComponent<?>
getParent()
protected IRunnableQueue
getRunnableQueue()
IScene
getScene()
Collection<IServiceEventQualifier>
getServiceEventQualifiers()
Returns the collection of service event qualifiers that event should be traversed to component from event tracker.Iterable<IViewModel>
getViewModels()
boolean
isDisposed()
boolean
isInExternalUpdate()
void
queueAndWaitEvent(IEvent event)
Queues the event to this channel and waits for its processing done.void
queueEvent(IEvent event)
Queues the event to this channel.protected void
removeComponent(IComponent<?> component)
Removes the child component.void
removeListener(IEventChannelListener listener)
Removes the given listener from the channel.protected void
removeViewModel(IViewModel viewModel)
Removes the view model from the view models of this component.void
setChildCommitsEnabled(boolean value)
void
setChildRefreshEnable(boolean value)
void
setModel(M model)
Sets the model for this component.void
setParent(IComponent<?> parent)
void
setScene(IScene scene)
protected void
subscribeOnEvents(IServiceEventQualifier eventQualifier)
Subscribes on events which is covered by the given qualifier.protected void
subscribeOnEvents(Class<? extends IServiceEvent> eventClass)
Subscribes on events which is instances of the given class.protected void
unsubscribeOnEvents(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:
getScene
in interfaceIComponent<M extends IModel>
- Returns:
- the scene this component belongs to or
null
if component doesn't belong to a scene yet.
-
setScene
public void setScene(IScene scene)
- Specified by:
setScene
in interfaceIComponent<M extends IModel>
- Parameters:
scene
- the scene to place this component in.
-
getParent
public IComponent<?> getParent()
- Specified by:
getParent
in interfaceIComponent<M extends IModel>
- Returns:
- the parent component.
-
setParent
public void setParent(IComponent<?> parent)
- Specified by:
setParent
in interfaceIComponent<M extends IModel>
- Parameters:
parent
- a component to set as the parent component.
-
getComponents
public Iterable<IComponent<?>> getComponents()
- Specified by:
getComponents
in interfaceIComponent<M extends IModel>
- Returns:
- the child components of this component.
-
getViewModels
public Iterable<IViewModel> getViewModels()
- Specified by:
getViewModels
in interfaceIComponent<M extends IModel>
- Returns:
- the view models produced by this component.
-
beginExternalUpdate
public final void beginExternalUpdate()
Description copied from interface:IComponent
Begins 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.Internal
if no external update is in progress.- Specified by:
beginExternalUpdate
in interfaceIComponent<M extends IModel>
-
isInExternalUpdate
public final boolean isInExternalUpdate()
- Specified by:
isInExternalUpdate
in interfaceIComponent<M extends IModel>
- Returns:
true
if external update operation is in progress,false
otherwise.- See Also:
IComponent.beginExternalUpdate()
-
endExternalUpdate
public final void endExternalUpdate()
Description copied from interface:IComponent
Ends the external update operation.- Specified by:
endExternalUpdate
in interfaceIComponent<M extends IModel>
- See Also:
IComponent.beginExternalUpdate()
-
dispose
public void dispose()
Description copied from interface:IComponent
Disposes this component, its view models and its child components.- Specified by:
dispose
in interfaceIComponent<M extends IModel>
-
isDisposed
public boolean isDisposed()
- Specified by:
isDisposed
in interfaceIComponent<M extends IModel>
- Returns:
true
if the component was disposed,false
otherwise.
-
setModel
public final void setModel(M model)
Description copied from interface:IComponent
Sets 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:
setModel
in interfaceIComponent<M extends IModel>
- Parameters:
model
- the model to set.
-
getModel
public final M getModel()
- Specified by:
getModel
in interfaceIComponent<M extends IModel>
- Returns:
- the model of this component or
null
if component has no associated model.
-
commit
public void commit()
Description copied from interface:IComponent
Commits this component changes to the model.- Specified by:
commit
in interfaceIComponent<M extends IModel>
-
areChildCommitsEnabled
public boolean areChildCommitsEnabled()
- Specified by:
areChildCommitsEnabled
in interfaceIComponent<M extends IModel>
- Returns:
true
if child commits are allowed,false
if child commits are inhibited and this component handles a commit by itself.
-
setChildCommitsEnabled
public void setChildCommitsEnabled(boolean value)
- Specified by:
setChildCommitsEnabled
in interfaceIComponent<M extends IModel>
- Parameters:
value
-true
to enable child commits,false
to disable them.- See Also:
IComponent.areChildCommitsEnabled()
-
areChildRefreshEnabled
public boolean areChildRefreshEnabled()
- Specified by:
areChildRefreshEnabled
in interfaceIComponent<M extends IModel>
- Returns:
true
if child refreshing are allowed,false
if child refreshing are inhibited and this component handles a refresh by itself.
-
setChildRefreshEnable
public void setChildRefreshEnable(boolean value)
- Specified by:
setChildRefreshEnable
in interfaceIComponent<M extends IModel>
- Parameters:
value
-true
to enable child refreshing,false
to disable them.- See Also:
IComponent.areChildRefreshEnabled()
-
queueEvent
public final void queueEvent(IEvent event)
Description copied from interface:IEventChannel
Queues the event to this channel.- Specified by:
queueEvent
in interfaceIEventChannel
- Parameters:
event
- the event to queue.- See Also:
IEventChannel.queueAndWaitEvent(IEvent)
-
queueAndWaitEvent
public final void queueAndWaitEvent(IEvent event)
Description copied from interface:IEventChannel
Queues 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:
queueAndWaitEvent
in interfaceIEventChannel
- Parameters:
event
- the event to queue.- See Also:
IEventChannel.queueEvent(IEvent)
-
addListener
public void addListener(IEventChannelListener listener)
Description copied from interface:IEventChannel
Adds the given listener to the channel.- Specified by:
addListener
in interfaceIEventChannel
- Parameters:
listener
- the listener.
-
removeListener
public void removeListener(IEventChannelListener listener)
Description copied from interface:IEventChannel
Removes the given listener from the channel.- Specified by:
removeListener
in interfaceIEventChannel
- Parameters:
listener
- the listener.
-
getServiceEventQualifiers
public Collection<IServiceEventQualifier> getServiceEventQualifiers()
Description copied from interface:IComponent
Returns the collection of service event qualifiers that event should be traversed to component from event tracker.- Specified by:
getServiceEventQualifiers
in 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:
true
if child components have been created,false
otherwise
-
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
- theIServiceEventQualifier
instance, cannot benull
.
-
unsubscribeOnEvents
protected final void unsubscribeOnEvents(IServiceEventQualifier eventQualifier)
Unsubscribes on events which is covered by the given qualifier.- Parameters:
eventQualifier
- theIServiceEventQualifier
instance, cannot benull
.
-
-