Class ViewModelContextImpl
- java.lang.Object
-
- org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl
-
- All Implemented Interfaces:
ViewModelContext
,EMFFormsViewContext
- Direct Known Subclasses:
DiffMergeModelContextImpl
public class ViewModelContextImpl extends java.lang.Object implements ViewModelContext
The Class ViewModelContextImpl.- Author:
- Eugen Neufeld
-
-
Constructor Summary
Constructors Constructor Description ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject)
Instantiates a new view model context impl.ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, java.util.Map<java.lang.String,?> contextValues)
Instantiates a new view model context with initial context values.ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement)
Instantiates a new view model context impl.ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelService... modelServices)
Deprecated.As of 1.16, use theViewModelContextImpl(VElement, EObject, ViewModelContext, VElement, ViewModelServiceProvider)
APIViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelServiceProvider modelServiceProvider)
Instantiates a new view model context impl with a parent context.ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelService... modelServices)
Deprecated.As of 1.16, use theViewModelContextImpl(VElement, EObject, ViewModelServiceProvider)
APIViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider)
Instantiates a new view model context impl.ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider, java.util.Map<java.lang.String,?> contextValues)
Instantiates a new view model context with initial context values.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addContextUser(java.lang.Object user)
Inner method for registering context users (notViewModelService
).void
changeDomainModel(org.eclipse.emf.ecore.EObject newDomainModel)
Changes the domain model of this view context to the givenEObject
.void
dispose()
Dispose.ViewModelContext
getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelService... viewModelServices)
Deprecated.ViewModelContext
getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelServiceProvider viewModelServiceProvider)
This returns a child context for the providedEObject
andVElement
.java.lang.Object
getContextValue(java.lang.String key)
Returns the value of the context for the passed key.java.util.Set<VControl>
getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Deprecated.java.util.Set<VElement>
getControlsFor(UniqueSetting setting)
Deprecated.org.eclipse.emf.ecore.EObject
getDomainModel()
Gets the domain model.ViewModelContext
getParentContext()
This returns the parent context.VElement
getParentVElement()
If this context has aparent context
this method will return the parent VElement which requested the creation of this context.<T> T
getService(java.lang.Class<T> serviceType)
Retrieve anViewModelService
of typeserviceType
.protected <T> T
getServiceWithoutLog(java.lang.Class<T> serviceType)
Retrieve anViewModelService
of typeserviceType
without reporting an error if none is found.VElement
getViewModel()
Gets the view model.protected ViewModelServiceProvider
getViewModelServiceProvider()
Obtains the provider of local view-model service overrides.<T> boolean
hasService(java.lang.Class<T> serviceType)
Whether the context has a service of the given typeserviceType
.void
pause()
Pauses the Context by not reacting to any notifications anymore.void
putContextValue(java.lang.String key, java.lang.Object value)
Puts the value for the provided key into the context.void
reactivate()
Reactive the Context by reacting to notifications again.void
registerDisposeListener(ViewModelContextDisposeListener listener)
Allows to register a dispose listener.void
registerDomainChangeListener(ModelChangeListener modelChangeListener)
Register domain change listener.void
registerEMFFormsContextListener(EMFFormsContextListener contextListener)
Register anEMFFormsContextListener
.void
registerRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Register aRootDomainModelChangeListener
.void
registerViewChangeListener(ModelChangeListener modelChangeListener)
Register view change listener.void
removeContextUser(java.lang.Object user)
Inner method for unregistering the context user.void
unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Unregister domain change listener.void
unregisterEMFFormsContextListener(EMFFormsContextListener contextListener)
Unregister anEMFFormsContextListener
.void
unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Unregister aRootDomainModelChangeListener
.void
unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Unregister view change listener.
-
-
-
Constructor Detail
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject)
Instantiates a new view model context impl.- Parameters:
view
- the viewdomainObject
- the domain object
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement)
Instantiates a new view model context impl.- Parameters:
view
- the viewdomainObject
- the domain objectparent
- The parentViewModelContext
parentVElement
- the parentVElement
-
ViewModelContextImpl
@Deprecated public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelService... modelServices)
Deprecated.As of 1.16, use theViewModelContextImpl(VElement, EObject, ViewModelServiceProvider)
APIInstantiates a new view model context impl.- Parameters:
view
- the viewdomainObject
- the domain objectmodelServices
- an array of services to use in theViewModelContext
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider)
Instantiates a new view model context impl.- Parameters:
view
- the viewdomainObject
- the domain objectmodelServiceProvider
- a provider of services to use in theViewModelContext
. May benull
if local service overrides are not needed- Since:
- 1.16
-
ViewModelContextImpl
@Deprecated public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelService... modelServices)
Deprecated.As of 1.16, use theViewModelContextImpl(VElement, EObject, ViewModelContext, VElement, ViewModelServiceProvider)
APIInstantiates a new view model context impl with a parent context.- Parameters:
view
- the viewdomainObject
- the domain objectparent
- The parentViewModelContext
parentVElement
- The parentVElement
modelServices
- an array of services to use in theViewModelContext
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelServiceProvider modelServiceProvider)
Instantiates a new view model context impl with a parent context.- Parameters:
view
- the viewdomainObject
- the domain objectparent
- The parentViewModelContext
parentVElement
- The parentVElement
modelServiceProvider
- a provider of services to use in theViewModelContext
. May benull
if local service overrides are not needed- Since:
- 1.16
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, java.util.Map<java.lang.String,?> contextValues)
Instantiates a new view model context with initial context values.- Parameters:
view
- the viewdomainObject
- the domain objectcontextValues
- initial context values to set- Since:
- 1.21
- See Also:
getContextValue(String)
-
ViewModelContextImpl
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider, java.util.Map<java.lang.String,?> contextValues)
Instantiates a new view model context with initial context values.- Parameters:
view
- the viewdomainObject
- the domain objectmodelServiceProvider
- a provider of services to use in theViewModelContext
. May benull
if local service overrides are not neededcontextValues
- initial context values to set- Since:
- 1.21
- See Also:
getContextValue(String)
-
-
Method Detail
-
getControlsFor
@Deprecated public java.util.Set<VControl> getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Deprecated.Returns all controls which are associated with the providedEStructuralFeature.Setting
. TheEStructuralFeature.Setting
is converted to aUniqueSetting
.- Specified by:
getControlsFor
in interfaceViewModelContext
- Parameters:
setting
- theEStructuralFeature.Setting
to search controls for- Returns:
- the Set of all controls associated with the provided setting or null if no controls can be found
- See Also:
ViewModelContext.getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting)
-
getControlsFor
@Deprecated public java.util.Set<VElement> getControlsFor(UniqueSetting setting)
Deprecated.Returns all controls which are associated with the providedUniqueSetting
.- Specified by:
getControlsFor
in interfaceViewModelContext
- Parameters:
setting
- theUniqueSetting
to search controls for- Returns:
- the Set of all controls associated with the provided setting or null if no controls can be found
- See Also:
ViewModelContext.getControlsFor(org.eclipse.emf.ecp.common.spi.UniqueSetting)
-
getViewModel
public VElement getViewModel()
Gets the view model.- Specified by:
getViewModel
in interfaceEMFFormsViewContext
- Specified by:
getViewModel
in interfaceViewModelContext
- Returns:
- the view model
- See Also:
ViewModelContext.getViewModel()
-
getDomainModel
public org.eclipse.emf.ecore.EObject getDomainModel()
Gets the domain model.- Specified by:
getDomainModel
in interfaceEMFFormsViewContext
- Specified by:
getDomainModel
in interfaceViewModelContext
- Returns:
- the domain model
- See Also:
ViewModelContext.getDomainModel()
-
dispose
public void dispose()
Dispose.- Specified by:
dispose
in interfaceViewModelContext
-
registerViewChangeListener
public void registerViewChangeListener(ModelChangeListener modelChangeListener)
Description copied from interface:ViewModelContext
Register view change listener.- Specified by:
registerViewChangeListener
in interfaceEMFFormsViewContext
- Specified by:
registerViewChangeListener
in interfaceViewModelContext
- Parameters:
modelChangeListener
- the model change listener
-
unregisterViewChangeListener
public void unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Description copied from interface:ViewModelContext
Unregister view change listener.- Specified by:
unregisterViewChangeListener
in interfaceEMFFormsViewContext
- Specified by:
unregisterViewChangeListener
in interfaceViewModelContext
- Parameters:
modelChangeListener
- the model change listener
-
registerDomainChangeListener
public void registerDomainChangeListener(ModelChangeListener modelChangeListener)
Description copied from interface:ViewModelContext
Register domain change listener.- Specified by:
registerDomainChangeListener
in interfaceEMFFormsViewContext
- Specified by:
registerDomainChangeListener
in interfaceViewModelContext
- Parameters:
modelChangeListener
- the model change listener
-
unregisterDomainChangeListener
public void unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Description copied from interface:ViewModelContext
Unregister domain change listener.- Specified by:
unregisterDomainChangeListener
in interfaceEMFFormsViewContext
- Specified by:
unregisterDomainChangeListener
in interfaceViewModelContext
- Parameters:
modelChangeListener
- the model change listener
-
hasService
public <T> boolean hasService(java.lang.Class<T> serviceType)
Whether the context has a service of the given typeserviceType
.- Specified by:
hasService
in interfaceViewModelContext
- Type Parameters:
T
- the type of the desired service- Parameters:
serviceType
- the type of the service- Returns:
true
, if the context has a service of the given type,false
otherwise- See Also:
ViewModelContext.hasService(java.lang.Class)
-
getService
public <T> T getService(java.lang.Class<T> serviceType)
Retrieve anViewModelService
of typeserviceType
.- Specified by:
getService
in interfaceEMFFormsViewContext
- Specified by:
getService
in interfaceViewModelContext
- Type Parameters:
T
- the type of the desired service- Parameters:
serviceType
- the type of the service to be retrieved- Returns:
- the service
- See Also:
ViewModelContext.getService(java.lang.Class)
-
getServiceWithoutLog
protected <T> T getServiceWithoutLog(java.lang.Class<T> serviceType)
Retrieve anViewModelService
of typeserviceType
without reporting an error if none is found.- Type Parameters:
T
- the type of the desired service- Parameters:
serviceType
- the type of the service to be retrieved- Returns:
- the service
-
addContextUser
public void addContextUser(java.lang.Object user)
Inner method for registering context users (notViewModelService
).- Specified by:
addContextUser
in interfaceViewModelContext
- Parameters:
user
- the user of the context
-
removeContextUser
public void removeContextUser(java.lang.Object user)
Inner method for unregistering the context user.- Specified by:
removeContextUser
in interfaceViewModelContext
- Parameters:
user
- the user of the context
-
getContextValue
public java.lang.Object getContextValue(java.lang.String key)
Returns the value of the context for the passed key.- Specified by:
getContextValue
in interfaceViewModelContext
- Parameters:
key
- the key of the value to get- Returns:
- the Object for the provided key
- See Also:
ViewModelContext.getContextValue(java.lang.String)
-
putContextValue
public void putContextValue(java.lang.String key, java.lang.Object value)
Puts the value for the provided key into the context.- Specified by:
putContextValue
in interfaceViewModelContext
- Parameters:
key
- the key to setvalue
- the Object to set into the context- See Also:
ViewModelContext.putContextValue(java.lang.String, java.lang.Object)
-
getViewModelServiceProvider
protected ViewModelServiceProvider getViewModelServiceProvider()
Obtains the provider of local view-model service overrides.- Returns:
- the local view-model service provider
- Since:
- 1.16
-
getChildContext
@Deprecated public ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelService... viewModelServices)
Deprecated.Description copied from interface:ViewModelContext
This returns the childContext for the provided EObject and the provided
VElement
. If a child context already exists it will be returned otherwise a newViewModelContext
will be created.Note that the injection of
viewModelServices
is useful for services that are not registered externally (via extension point or OSGi). If any of these services locally override registered implementations of the same interface, then it is better to use aViewModelServiceProvider
that can propagate the override to child contexts.- Specified by:
getChildContext
in interfaceViewModelContext
- Parameters:
eObject
- TheEObject
to get the child context forparent
- TheVElement
which requests the child contextvView
- TheVView
of theEObject
viewModelServices
- The list ofViewModelService
which should be part of a child context- Returns:
- a
ViewModelContext
witch is a child of the current context - See Also:
ViewModelContext.getChildContext(EObject, VElement, VView, ViewModelServiceProvider)
-
getChildContext
public ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelServiceProvider viewModelServiceProvider)
Description copied from interface:ViewModelContext
This returns a child context for the providedEObject
andVElement
. If a child context already exists it will be returned otherwise a newViewModelContext
will be created.- Specified by:
getChildContext
in interfaceViewModelContext
- Parameters:
eObject
- TheEObject
to get the child context forparent
- TheVElement
which requests the child contextvView
- TheVView
of theEObject
viewModelServiceProvider
- a provider of view model services to inject into the child context, which will only be used in the case that it is necessary to create the context. Thus no services will be created if not needed. May benull
if additional local service overrides are not needed- Returns:
- a
ViewModelContext
which is a child of the current context
-
getParentContext
public ViewModelContext getParentContext()
Description copied from interface:ViewModelContext
This returns the parent context. This may benull
for the topmost context.- Specified by:
getParentContext
in interfaceViewModelContext
- Returns:
- the parent
-
getParentVElement
public VElement getParentVElement()
Description copied from interface:ViewModelContext
If this context has aparent context
this method will return the parent VElement which requested the creation of this context. Otherwise this method will returnnull
.- Specified by:
getParentVElement
in interfaceViewModelContext
- Returns:
- the parent
-
registerDisposeListener
public void registerDisposeListener(ViewModelContextDisposeListener listener)
Allows to register a dispose listener.- Specified by:
registerDisposeListener
in interfaceViewModelContext
- Parameters:
listener
- TheViewModelContextDisposeListener
to register- See Also:
ViewModelContext.registerDisposeListener(org.eclipse.emf.ecp.view.spi.context.ViewModelContextDisposeListener)
-
registerEMFFormsContextListener
public void registerEMFFormsContextListener(EMFFormsContextListener contextListener)
Description copied from interface:EMFFormsViewContext
Register anEMFFormsContextListener
.- Specified by:
registerEMFFormsContextListener
in interfaceEMFFormsViewContext
- Parameters:
contextListener
- theEMFFormsContextListener
to register
-
unregisterEMFFormsContextListener
public void unregisterEMFFormsContextListener(EMFFormsContextListener contextListener)
Description copied from interface:EMFFormsViewContext
Unregister anEMFFormsContextListener
.- Specified by:
unregisterEMFFormsContextListener
in interfaceEMFFormsViewContext
- Parameters:
contextListener
- theEMFFormsContextListener
to unregister
-
changeDomainModel
public void changeDomainModel(org.eclipse.emf.ecore.EObject newDomainModel)
Description copied from interface:EMFFormsViewContext
Changes the domain model of this view context to the givenEObject
.- Specified by:
changeDomainModel
in interfaceEMFFormsViewContext
- Parameters:
newDomainModel
- The new domain model- See Also:
EMFFormsViewContext.getDomainModel()
-
registerRootDomainModelChangeListener
public void registerRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Register aRootDomainModelChangeListener
.- Specified by:
registerRootDomainModelChangeListener
in interfaceEMFFormsViewContext
- Parameters:
rootDomainModelChangeListener
- TheRootDomainModelChangeListener
to register- See Also:
EMFFormsViewContext.registerRootDomainModelChangeListener(org.eclipse.emfforms.spi.core.services.view.RootDomainModelChangeListener)
-
unregisterRootDomainModelChangeListener
public void unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Unregister aRootDomainModelChangeListener
.- Specified by:
unregisterRootDomainModelChangeListener
in interfaceEMFFormsViewContext
- Parameters:
rootDomainModelChangeListener
- TheRootDomainModelChangeListener
to unregister- See Also:
EMFFormsViewContext.unregisterRootDomainModelChangeListener(org.eclipse.emfforms.spi.core.services.view.RootDomainModelChangeListener)
-
pause
public void pause()
Description copied from interface:ViewModelContext
Pauses the Context by not reacting to any notifications anymore.- Specified by:
pause
in interfaceViewModelContext
-
reactivate
public void reactivate()
Description copied from interface:ViewModelContext
Reactive the Context by reacting to notifications again. Please be aware that reactiving the ViewModelContext will not rereport the notifications that were ignored during pause. In order to update the state after reactivation you should callEMFFormsViewContext.changeDomainModel(EObject)
or trigger an event that fires a notification.- Specified by:
reactivate
in interfaceViewModelContext
-
-