public class ViewModelContextImpl extends Object implements ViewModelContext
Constructor and 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,
Map<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 the
ViewModelContextImpl(VElement, EObject, ViewModelContext, VElement, ViewModelServiceProvider)
API |
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.
|
ViewModelContextImpl(VElement view,
org.eclipse.emf.ecore.EObject domainObject,
ViewModelService... modelServices)
Deprecated.
As of 1.16, use the
ViewModelContextImpl(VElement, EObject, ViewModelServiceProvider) API |
ViewModelContextImpl(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,
Map<String,?> contextValues)
Instantiates a new view model context with initial context values.
|
Modifier and Type | Method and Description |
---|---|
void |
addContextUser(Object user)
Inner method for registering context users (not
ViewModelService ). |
void |
changeDomainModel(org.eclipse.emf.ecore.EObject newDomainModel)
Changes the domain model of this view context to the given
EObject . |
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 provided
EObject and VElement . |
Object |
getContextValue(String key)
Returns the value of the context for the passed key.
|
Set<VControl> |
getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Deprecated.
|
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 a
parent context this method will return the parent VElement
which requested the creation of this context. |
<T> T |
getService(Class<T> serviceType)
Retrieve an
ViewModelService of type serviceType . |
protected <T> T |
getServiceWithoutLog(Class<T> serviceType)
Retrieve an
ViewModelService of type serviceType 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(Class<T> serviceType)
Whether the context has a service of the given type
serviceType . |
void |
putContextValue(String key,
Object value)
Puts the value for the provided key into the context.
|
void |
registerDisposeListener(ViewModelContextDisposeListener listener)
Allows to register a dispose listener.
|
void |
registerDomainChangeListener(ModelChangeListener modelChangeListener)
Register domain change listener.
|
void |
registerEMFFormsContextListener(EMFFormsContextListener contextListener)
Register an
EMFFormsContextListener . |
void |
registerRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Register a
RootDomainModelChangeListener . |
void |
registerViewChangeListener(ModelChangeListener modelChangeListener)
Register view change listener.
|
void |
removeContextUser(Object user)
Inner method for unregistering the context user.
|
void |
unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Unregister domain change listener.
|
void |
unregisterEMFFormsContextListener(EMFFormsContextListener contextListener)
Unregister an
EMFFormsContextListener . |
void |
unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
Unregister a
RootDomainModelChangeListener . |
void |
unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Unregister view change listener.
|
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject)
view
- the viewdomainObject
- the domain objectpublic ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement)
view
- the viewdomainObject
- the domain objectparent
- The parent ViewModelContext
parentVElement
- the parent VElement
@Deprecated public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelService... modelServices)
ViewModelContextImpl(VElement, EObject, ViewModelServiceProvider)
APIview
- the viewdomainObject
- the domain objectmodelServices
- an array of services to use in the ViewModelContext
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider)
view
- the viewdomainObject
- the domain objectmodelServiceProvider
- a provider of services to use in the ViewModelContext
. May be null
if
local service overrides are not needed@Deprecated public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelService... modelServices)
ViewModelContextImpl(VElement, EObject, ViewModelContext, VElement, ViewModelServiceProvider)
APIview
- the viewdomainObject
- the domain objectparent
- The parent ViewModelContext
parentVElement
- The parent VElement
modelServices
- an array of services to use in the ViewModelContext
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelContext parent, VElement parentVElement, ViewModelServiceProvider modelServiceProvider)
view
- the viewdomainObject
- the domain objectparent
- The parent ViewModelContext
parentVElement
- The parent VElement
modelServiceProvider
- a provider of services to use in the ViewModelContext
. May be null
if
local service overrides are not neededpublic ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, Map<String,?> contextValues)
view
- the viewdomainObject
- the domain objectcontextValues
- initial context values to setgetContextValue(String)
public ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelServiceProvider modelServiceProvider, Map<String,?> contextValues)
view
- the viewdomainObject
- the domain objectmodelServiceProvider
- a provider of services to use in the ViewModelContext
. May be null
if
local service overrides are not neededcontextValues
- initial context values to setgetContextValue(String)
@Deprecated public Set<VControl> getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
EStructuralFeature.Setting
. The EStructuralFeature.Setting
is converted to
a UniqueSetting
.getControlsFor
in interface ViewModelContext
setting
- the EStructuralFeature.Setting
to search controls forViewModelContext.getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting)
@Deprecated public Set<VElement> getControlsFor(UniqueSetting setting)
UniqueSetting
.getControlsFor
in interface ViewModelContext
setting
- the UniqueSetting
to search controls forViewModelContext.getControlsFor(org.eclipse.emf.ecp.common.spi.UniqueSetting)
public VElement getViewModel()
getViewModel
in interface ViewModelContext
getViewModel
in interface EMFFormsViewContext
ViewModelContext.getViewModel()
public org.eclipse.emf.ecore.EObject getDomainModel()
getDomainModel
in interface ViewModelContext
getDomainModel
in interface EMFFormsViewContext
ViewModelContext.getDomainModel()
public void dispose()
dispose
in interface ViewModelContext
public void registerViewChangeListener(ModelChangeListener modelChangeListener)
ViewModelContext
registerViewChangeListener
in interface ViewModelContext
registerViewChangeListener
in interface EMFFormsViewContext
modelChangeListener
- the model change listenerpublic void unregisterViewChangeListener(ModelChangeListener modelChangeListener)
ViewModelContext
unregisterViewChangeListener
in interface ViewModelContext
unregisterViewChangeListener
in interface EMFFormsViewContext
modelChangeListener
- the model change listenerpublic void registerDomainChangeListener(ModelChangeListener modelChangeListener)
ViewModelContext
registerDomainChangeListener
in interface ViewModelContext
registerDomainChangeListener
in interface EMFFormsViewContext
modelChangeListener
- the model change listenerpublic void unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
ViewModelContext
unregisterDomainChangeListener
in interface ViewModelContext
unregisterDomainChangeListener
in interface EMFFormsViewContext
modelChangeListener
- the model change listenerpublic <T> boolean hasService(Class<T> serviceType)
serviceType
.hasService
in interface ViewModelContext
T
- the type of the desired serviceserviceType
- the type of the servicetrue
, if the context has a service of the given type, false
otherwiseViewModelContext.hasService(java.lang.Class)
public <T> T getService(Class<T> serviceType)
ViewModelService
of type serviceType
.getService
in interface ViewModelContext
getService
in interface EMFFormsViewContext
T
- the type of the desired serviceserviceType
- the type of the service to be retrievedViewModelContext.getService(java.lang.Class)
protected <T> T getServiceWithoutLog(Class<T> serviceType)
ViewModelService
of type serviceType
without reporting an error if none is found.T
- the type of the desired serviceserviceType
- the type of the service to be retrievedpublic void addContextUser(Object user)
ViewModelService
).addContextUser
in interface ViewModelContext
user
- the user of the contextpublic void removeContextUser(Object user)
removeContextUser
in interface ViewModelContext
user
- the user of the contextpublic Object getContextValue(String key)
getContextValue
in interface ViewModelContext
key
- the key of the value to getViewModelContext.getContextValue(java.lang.String)
public void putContextValue(String key, Object value)
putContextValue
in interface ViewModelContext
key
- the key to setvalue
- the Object to set into the contextViewModelContext.putContextValue(java.lang.String, java.lang.Object)
protected ViewModelServiceProvider getViewModelServiceProvider()
@Deprecated public ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelService... viewModelServices)
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 new ViewModelContext
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 a ViewModelServiceProvider
that can propagate the override to child contexts.
getChildContext
in interface ViewModelContext
eObject
- The EObject
to get the child context forparent
- The VElement
which requests the child contextvView
- The VView
of the EObject
viewModelServices
- The list of ViewModelService
which should be part of a child contextViewModelContext
witch is a child of the current contextViewModelContext.getChildContext(EObject, VElement, VView, ViewModelServiceProvider)
public ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject, VElement parent, VView vView, ViewModelServiceProvider viewModelServiceProvider)
ViewModelContext
EObject
and VElement
. If a child context
already exists it will be returned otherwise a new ViewModelContext
will be created.getChildContext
in interface ViewModelContext
eObject
- The EObject
to get the child context forparent
- The VElement
which requests the child contextvView
- The VView
of the EObject
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 be null
if additional local service overrides are not
neededViewModelContext
which is a child of the current contextpublic ViewModelContext getParentContext()
ViewModelContext
null
for the topmost context.getParentContext
in interface ViewModelContext
public VElement getParentVElement()
ViewModelContext
parent context
this method will return the parent VElement
which requested the creation of this context. Otherwise this method will return null
.getParentVElement
in interface ViewModelContext
public void registerDisposeListener(ViewModelContextDisposeListener listener)
registerDisposeListener
in interface ViewModelContext
listener
- The ViewModelContextDisposeListener
to registerViewModelContext.registerDisposeListener(org.eclipse.emf.ecp.view.spi.context.ViewModelContextDisposeListener)
public void registerEMFFormsContextListener(EMFFormsContextListener contextListener)
EMFFormsViewContext
EMFFormsContextListener
.registerEMFFormsContextListener
in interface EMFFormsViewContext
contextListener
- the EMFFormsContextListener
to registerpublic void unregisterEMFFormsContextListener(EMFFormsContextListener contextListener)
EMFFormsViewContext
EMFFormsContextListener
.unregisterEMFFormsContextListener
in interface EMFFormsViewContext
contextListener
- the EMFFormsContextListener
to unregisterpublic void changeDomainModel(org.eclipse.emf.ecore.EObject newDomainModel)
EMFFormsViewContext
EObject
.changeDomainModel
in interface EMFFormsViewContext
newDomainModel
- The new domain modelEMFFormsViewContext.getDomainModel()
public void registerRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
RootDomainModelChangeListener
.registerRootDomainModelChangeListener
in interface EMFFormsViewContext
rootDomainModelChangeListener
- The RootDomainModelChangeListener
to registerEMFFormsViewContext.registerRootDomainModelChangeListener(org.eclipse.emfforms.spi.core.services.view.RootDomainModelChangeListener)
public void unregisterRootDomainModelChangeListener(RootDomainModelChangeListener rootDomainModelChangeListener)
RootDomainModelChangeListener
.unregisterRootDomainModelChangeListener
in interface EMFFormsViewContext
rootDomainModelChangeListener
- The RootDomainModelChangeListener
to unregisterEMFFormsViewContext.unregisterRootDomainModelChangeListener(org.eclipse.emfforms.spi.core.services.view.RootDomainModelChangeListener)
Copyright © 2019. All rights reserved.