Interface ViewModelContext
-
- All Superinterfaces:
EMFFormsViewContext
- All Known Subinterfaces:
DiffMergeModelContext
- All Known Implementing Classes:
DiffMergeModelContextImpl
,EMFFormsSpreadsheetViewModelContext
,ViewModelContextImpl
public interface ViewModelContext extends EMFFormsViewContext
The Interface ViewModelContext.- Since:
- 1.2
- Author:
- Eugen Neufeld
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addContextUser(java.lang.Object user)
Adds a user of the context.void
dispose()
Disposes the context.ViewModelContext
getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelService... viewModelServices)
This returns the childContext for the provided EObject and the providedVElement
.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
.VElement
getViewModel()
Gets the view model.<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
registerViewChangeListener(ModelChangeListener modelChangeListener)
Register view change listener.void
removeContextUser(java.lang.Object user)
Removes a context user.void
unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Unregister domain change listener.void
unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Unregister view change listener.-
Methods inherited from interface org.eclipse.emfforms.spi.core.services.view.EMFFormsViewContext
changeDomainModel, registerEMFFormsContextListener, registerRootDomainModelChangeListener, unregisterEMFFormsContextListener, unregisterRootDomainModelChangeListener
-
-
-
-
Method Detail
-
registerDomainChangeListener
void registerDomainChangeListener(ModelChangeListener modelChangeListener)
Register domain change listener.- Specified by:
registerDomainChangeListener
in interfaceEMFFormsViewContext
- Parameters:
modelChangeListener
- the model change listener- Since:
- 1.3
-
unregisterDomainChangeListener
void unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Unregister domain change listener.- Specified by:
unregisterDomainChangeListener
in interfaceEMFFormsViewContext
- Parameters:
modelChangeListener
- the model change listener- Since:
- 1.3
-
getViewModel
VElement getViewModel()
Gets the view model.- Specified by:
getViewModel
in interfaceEMFFormsViewContext
- Returns:
- the view model
-
getDomainModel
org.eclipse.emf.ecore.EObject getDomainModel()
Gets the domain model.- Specified by:
getDomainModel
in interfaceEMFFormsViewContext
- Returns:
- the domain model
-
registerViewChangeListener
void registerViewChangeListener(ModelChangeListener modelChangeListener)
Register view change listener.- Specified by:
registerViewChangeListener
in interfaceEMFFormsViewContext
- Parameters:
modelChangeListener
- the model change listener- Since:
- 1.3
-
unregisterViewChangeListener
void unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Unregister view change listener.- Specified by:
unregisterViewChangeListener
in interfaceEMFFormsViewContext
- Parameters:
modelChangeListener
- the model change listener- Since:
- 1.3
-
dispose
void dispose()
Disposes the context.
-
hasService
<T> boolean hasService(java.lang.Class<T> serviceType)
Whether the context has a service of the given typeserviceType
.- 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
-
getService
<T> T getService(java.lang.Class<T> serviceType)
Retrieve anViewModelService
of typeserviceType
.- Specified by:
getService
in interfaceEMFFormsViewContext
- Type Parameters:
T
- the type of the desired service- Parameters:
serviceType
- the type of the service to be retrieved- Returns:
- the service
-
getControlsFor
@Deprecated 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
.- 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
- Since:
- 1.3
-
getControlsFor
@Deprecated java.util.Set<VElement> getControlsFor(UniqueSetting setting)
Deprecated.Returns all controls which are associated with the providedUniqueSetting
.- 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
- Since:
- 1.5
-
getContextValue
java.lang.Object getContextValue(java.lang.String key)
Returns the value of the context for the passed key.- Parameters:
key
- the key of the value to get- Returns:
- the Object for the provided key
- Since:
- 1.4
-
putContextValue
void putContextValue(java.lang.String key, java.lang.Object value)
Puts the value for the provided key into the context.- Parameters:
key
- the key to setvalue
- the Object to set into the context- Since:
- 1.4
-
getChildContext
ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelService... viewModelServices)
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.- 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 - Since:
- 1.5
- See Also:
getChildContext(EObject, VElement, VView, ViewModelServiceProvider)
-
getChildContext
ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelServiceProvider viewModelServiceProvider)
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.- 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 - Since:
- 1.16
-
getParentContext
ViewModelContext getParentContext()
This returns the parent context. This may benull
for the topmost context.- Returns:
- the parent
- Since:
- 1.9
-
getParentVElement
VElement getParentVElement()
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
.- Returns:
- the parent
- Since:
- 1.9
-
registerDisposeListener
void registerDisposeListener(ViewModelContextDisposeListener listener)
Allows to register a dispose listener.- Parameters:
listener
- TheViewModelContextDisposeListener
to register- Since:
- 1.5
-
addContextUser
void addContextUser(java.lang.Object user)
Adds a user of the context.- Parameters:
user
- The context user to add- Since:
- 1.5
-
removeContextUser
void removeContextUser(java.lang.Object user)
Removes a context user.- Parameters:
user
- The context user to remove- Since:
- 1.5
-
pause
void pause()
Pauses the Context by not reacting to any notifications anymore.- Since:
- 1.25
-
reactivate
void reactivate()
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.- Since:
- 1.25
-
-