Class EMFFormsSpreadsheetViewModelContext
- java.lang.Object
-
- org.eclipse.emfforms.internal.spreadsheet.core.EMFFormsSpreadsheetViewModelContext
-
- All Implemented Interfaces:
ViewModelContext
,EMFFormsViewContext
public class EMFFormsSpreadsheetViewModelContext extends java.lang.Object implements ViewModelContext
Spreadsheet specific implementation of theViewModelContext
. This implementation doesn't do anything, it serves only as a container for aVView
and theEObject
.- Author:
- Eugen Neufeld
-
-
Constructor Summary
Constructors Constructor Description EMFFormsSpreadsheetViewModelContext(VView view, org.eclipse.emf.ecore.EObject domainModel)
Default Constructor.EMFFormsSpreadsheetViewModelContext(VView view, org.eclipse.emf.ecore.EObject domainModel, ViewModelContext parentContext)
Default Constructor for child contexts.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addContextUser(java.lang.Object user)
Adds a user of the context.void
changeDomainModel(org.eclipse.emf.ecore.EObject newDomainModel)
Changes the domain model of this view context to the givenEObject
.void
dispose()
Disposes the context.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
.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
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)
Removes a 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
-
EMFFormsSpreadsheetViewModelContext
public EMFFormsSpreadsheetViewModelContext(VView view, org.eclipse.emf.ecore.EObject domainModel)
Default Constructor.- Parameters:
view
- TheVView
domainModel
- TheEObject
-
EMFFormsSpreadsheetViewModelContext
public EMFFormsSpreadsheetViewModelContext(VView view, org.eclipse.emf.ecore.EObject domainModel, ViewModelContext parentContext)
Default Constructor for child contexts.- Parameters:
view
- TheVView
domainModel
- TheEObject
parentContext
- The parentViewModelContext
-
-
Method Detail
-
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
-
getViewModel
public VElement getViewModel()
Description copied from interface:ViewModelContext
Gets the view model.- Specified by:
getViewModel
in interfaceEMFFormsViewContext
- Specified by:
getViewModel
in interfaceViewModelContext
- Returns:
- the view model
-
getDomainModel
public org.eclipse.emf.ecore.EObject getDomainModel()
Description copied from interface:ViewModelContext
Gets the domain model.- Specified by:
getDomainModel
in interfaceEMFFormsViewContext
- Specified by:
getDomainModel
in interfaceViewModelContext
- Returns:
- the domain model
-
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
-
dispose
public void dispose()
Description copied from interface:ViewModelContext
Disposes the context.- Specified by:
dispose
in interfaceViewModelContext
-
hasService
public <T> boolean hasService(java.lang.Class<T> serviceType)
Description copied from interface:ViewModelContext
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
-
getService
public <T> T getService(java.lang.Class<T> serviceType)
Description copied from interface:ViewModelContext
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
-
getControlsFor
@Deprecated public java.util.Set<VControl> getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Deprecated.Description copied from interface:ViewModelContext
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
-
getControlsFor
@Deprecated public java.util.Set<VElement> getControlsFor(UniqueSetting setting)
Deprecated.Description copied from interface:ViewModelContext
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
-
getContextValue
public java.lang.Object getContextValue(java.lang.String key)
Description copied from interface:ViewModelContext
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
-
putContextValue
public void putContextValue(java.lang.String key, java.lang.Object value)
Description copied from interface:ViewModelContext
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
-
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
-
registerDisposeListener
public void registerDisposeListener(ViewModelContextDisposeListener listener)
Description copied from interface:ViewModelContext
Allows to register a dispose listener.- Specified by:
registerDisposeListener
in interfaceViewModelContext
- Parameters:
listener
- TheViewModelContextDisposeListener
to register
-
addContextUser
public void addContextUser(java.lang.Object user)
Description copied from interface:ViewModelContext
Adds a user of the context.- Specified by:
addContextUser
in interfaceViewModelContext
- Parameters:
user
- The context user to add
-
removeContextUser
public void removeContextUser(java.lang.Object user)
Description copied from interface:ViewModelContext
Removes a context user.- Specified by:
removeContextUser
in interfaceViewModelContext
- Parameters:
user
- The context user to remove
-
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
-
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
-
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)
Description copied from interface:EMFFormsViewContext
Register aRootDomainModelChangeListener
.- Specified by:
registerRootDomainModelChangeListener
in interfaceEMFFormsViewContext
- Parameters:
rootDomainModelChangeListener
- TheRootDomainModelChangeListener
to register
-
unregisterRootDomainModelChangeListener
public void unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Description copied from interface:EMFFormsViewContext
Unregister aRootDomainModelChangeListener
.- Specified by:
unregisterRootDomainModelChangeListener
in interfaceEMFFormsViewContext
- Parameters:
rootDomainModelChangeListener
- TheRootDomainModelChangeListener
to unregister
-
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
-
-