Package com._1c.g5.aef2.views
Class View<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- java.lang.Object
-
- com._1c.g5.aef2.views.View<P,VM,NC>
-
- All Implemented Interfaces:
IView<P,VM,NC>
public abstract class View<P extends IRenderingParameters,VM extends IControlViewModel,NC> extends Object implements IView<P,VM,NC>
BaseIView
implementation.
-
-
Constructor Summary
Constructors Constructor Description View()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
bind(VM viewModel, NC nativeControl)
Binds the view model and native control together to this view.protected <T> void
bindListener(T listener, BiConsumer<NC,T> bindAction, BiConsumer<NC,T> undindAction)
Binds the specifiedlistener
for the native control using the givenbindAction
.void
bindNativeControl(NC nativeControl)
Binds the native control to this view.protected void
bindValue(org.eclipse.core.databinding.observable.value.IObservableValue<?> modelObservable, org.eclipse.core.databinding.observable.value.IObservableValue<?> controlObservable)
Binds two observables.protected void
bindValue(org.eclipse.core.databinding.observable.value.IObservableValue<?> modelObservable, org.eclipse.core.databinding.observable.value.IObservableValue<?> controlObservable, org.eclipse.core.databinding.UpdateValueStrategy modelToControl, org.eclipse.core.databinding.UpdateValueStrategy controlToModel)
Binds two observables.void
bindViewModel(VM viewModel)
Binds the view model to this view.NC
getNativeControl()
Gets the bound native control for this view.protected P
getParameters()
VM
getViewModel()
Gets the bound view model for this view.protected void
handleEventChannelEvent(IEvent event, VM viewModel, NC control)
Handles events fromIEventChannel
.protected abstract void
handleFocusEvent(FocusEvent event, VM viewModel, NC control)
HandlesFocusEvent
.void
initialize(P parameters)
Initializes this view with parameters.protected abstract boolean
isControlDisposed(NC control)
Returnstrue
if native control is disposed.protected void
manageObservable(org.eclipse.core.databinding.observable.IObservable observable)
Adds the specified observable to the view context and manages it throughout the view lifecycle.protected void
queueAndWaitEvent(IEvent event)
Queues and waits event to theIEventChannel
.protected void
queueEvent(IEvent event)
Queues event to theIEventChannel
.protected void
registerEventChannelListener(IEventChannelListener listener)
Registers the specified listener for view modelIEventChannel
.
NOTE:#handleEventChannelEvent(IEvent)
can be used to process event channel events.protected void
unbind(VM viewModel, NC nativeControl)
Unbinds the view model and the native control from this view.void
unbindNativeControl()
Unbinds the native control from this view, if any.void
unbindViewModel()
Unbinds the bound view mode form this view, if any.protected void
unmanageObservable(org.eclipse.core.databinding.observable.IObservable observable)
Excludes the specified observable from the view context and stoppes its managing throughout the view lifecycle.protected void
unregisterEventChannelListener(IEventChannelListener listener)
Unregisters the specified listener.
-
-
-
Method Detail
-
initialize
public void initialize(P parameters)
Description copied from interface:IView
Initializes this view with parameters.- Specified by:
initialize
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- Parameters:
parameters
- the parameters to initialize with.
-
bindViewModel
public final void bindViewModel(VM viewModel)
Description copied from interface:IView
Binds the view model to this view.- Specified by:
bindViewModel
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- Parameters:
viewModel
- the view model to bind.
-
getViewModel
public final VM getViewModel()
Description copied from interface:IView
Gets the bound view model for this view.- Specified by:
getViewModel
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- Returns:
- the view model or
null
if no view model is bound.
-
unbindViewModel
public final void unbindViewModel()
Description copied from interface:IView
Unbinds the bound view mode form this view, if any.- Specified by:
unbindViewModel
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
-
bindNativeControl
public final void bindNativeControl(NC nativeControl)
Description copied from interface:IView
Binds the native control to this view.- Specified by:
bindNativeControl
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- Parameters:
nativeControl
- the control to bind.
-
getNativeControl
public final NC getNativeControl()
Description copied from interface:IView
Gets the bound native control for this view.- Specified by:
getNativeControl
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
- Returns:
- the native control or
null
if no native control is bound.
-
unbindNativeControl
public final void unbindNativeControl()
Description copied from interface:IView
Unbinds the native control from this view, if any.- Specified by:
unbindNativeControl
in interfaceIView<P extends IRenderingParameters,VM extends IControlViewModel,NC>
-
getParameters
protected final P getParameters()
- Returns:
- this view rendering parameters.
-
bind
protected void bind(VM viewModel, NC nativeControl)
Binds the view model and native control together to this view. Override this method to customize the binding.- Parameters:
viewModel
- the view model to bind.nativeControl
- the native control to bind.
-
unbind
protected void unbind(VM viewModel, NC nativeControl)
Unbinds the view model and the native control from this view. Override this method to customize the unbinding.- Parameters:
viewModel
- the view mode to unbind.nativeControl
- the native control to unbind.
-
bindValue
protected final void bindValue(org.eclipse.core.databinding.observable.value.IObservableValue<?> modelObservable, org.eclipse.core.databinding.observable.value.IObservableValue<?> controlObservable)
Binds two observables.- Parameters:
modelObservable
- the view model observable to bind, cannot benull
controlObservable
- the native control observable to bind, cannot benull
-
bindValue
protected final void bindValue(org.eclipse.core.databinding.observable.value.IObservableValue<?> modelObservable, org.eclipse.core.databinding.observable.value.IObservableValue<?> controlObservable, org.eclipse.core.databinding.UpdateValueStrategy modelToControl, org.eclipse.core.databinding.UpdateValueStrategy controlToModel)
Binds two observables.- Parameters:
modelObservable
- view model observable to bind, cannot benull
controlObservable
- native control observable to bind, cannot benull
modelToControl
- the view model to native control update strategy, can benull
controlToModel
- the native control to view model update strategy, can benull
-
manageObservable
protected final void manageObservable(org.eclipse.core.databinding.observable.IObservable observable)
Adds the specified observable to the view context and manages it throughout the view lifecycle.- Parameters:
observable
- the observable to manage, cannot benull
.
-
unmanageObservable
protected final void unmanageObservable(org.eclipse.core.databinding.observable.IObservable observable)
Excludes the specified observable from the view context and stoppes its managing throughout the view lifecycle.- Parameters:
observable
- the observable to unmanage, cannot benull
.
-
bindListener
protected final <T> void bindListener(T listener, BiConsumer<NC,T> bindAction, BiConsumer<NC,T> undindAction)
Binds the specifiedlistener
for the native control using the givenbindAction
. It will be automatically unbound withinunbind(IControlViewModel, Object)
using the givenunbindAction
.- Parameters:
listener
- the native control listener, cannot benull
.bindAction
- the action for binding listener to native control, cannot benull
.undindAction
- the action for unbinding listener from native control, cannot benull
.
-
registerEventChannelListener
protected final void registerEventChannelListener(IEventChannelListener listener)
Registers the specified listener for view modelIEventChannel
.
NOTE:#handleEventChannelEvent(IEvent)
can be used to process event channel events. The specified method should be used only in case of custom event processing lifecycle.- Parameters:
listener
- the listener, cannot benull
.
-
unregisterEventChannelListener
protected final void unregisterEventChannelListener(IEventChannelListener listener)
Unregisters the specified listener.- Parameters:
listener
- the listener, cannot benull
.
-
queueAndWaitEvent
protected final void queueAndWaitEvent(IEvent event)
Queues and waits event to theIEventChannel
.- Parameters:
event
- the event, cannot benull
.
-
queueEvent
protected final void queueEvent(IEvent event)
Queues event to theIEventChannel
.- Parameters:
event
- the event, cannot benull
.
-
handleEventChannelEvent
protected void handleEventChannelEvent(IEvent event, VM viewModel, NC control)
Handles events fromIEventChannel
. By default handles only focus events.- Parameters:
event
- the event, cannot benull
.viewModel
- the view model, cannot benull
.control
- the control, cannot benull
.
-
handleFocusEvent
protected abstract void handleFocusEvent(FocusEvent event, VM viewModel, NC control)
HandlesFocusEvent
.- Parameters:
event
- the focus event, cannot benull
.viewModel
- the view model, cannot benull
.control
- the native control, cannot benull
.
-
isControlDisposed
protected abstract boolean isControlDisposed(NC control)
Returnstrue
if native control is disposed.- Parameters:
control
- the native control, cannot benull
.- Returns:
true
if native control is disposed,false
- otherwise.
-
-