org.eclipse.emf.ecp.view.internal.context
Class ViewModelContextImpl

java.lang.Object
  extended by org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl
All Implemented Interfaces:
ViewModelContext
Direct Known Subclasses:
DiffMergeModelContextImpl

public class ViewModelContextImpl
extends Object
implements ViewModelContext

The Class ViewModelContextImpl.

Author:
Eugen Neufeld

Constructor Summary
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, 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)
          Instantiates a new view model context impl.
ViewModelContextImpl(VElement view, org.eclipse.emf.ecore.EObject domainObject, ViewModelService... modelServices)
          Instantiates a new view model context impl.
 
Method Summary
 void addContextUser(Object user)
          Inner method for registering context users (not ViewModelService).
 void dispose()
          Dispose.
 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.
 Object getContextValue(String key)
          Returns the value of the context for the passed key.
 Set<VControl> getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
          Returns all controls which are associated with the provided EStructuralFeature.Setting.
 Set<VElement> getControlsFor(UniqueSetting setting)
          Returns all controls which are associated with the provided UniqueSetting.
 org.eclipse.emf.ecore.EObject getDomainModel()
          Gets the domain model.
<T> T
getService(Class<T> serviceType)
          Retrieve an ViewModelService of type serviceType.
 VElement getViewModel()
          Gets the view model.
<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 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 unregisterViewChangeListener(ModelChangeListener modelChangeListener)
          Unregister view change listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewModelContextImpl

public ViewModelContextImpl(VElement view,
                            org.eclipse.emf.ecore.EObject domainObject)
Instantiates a new view model context impl.

Parameters:
view - the view
domainObject - 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 view
domainObject - the domain object

ViewModelContextImpl

public ViewModelContextImpl(VElement view,
                            org.eclipse.emf.ecore.EObject domainObject,
                            ViewModelService... modelServices)
Instantiates a new view model context impl.

Parameters:
view - the view
domainObject - the domain object
modelServices - an array of services to use in the ViewModelContext

ViewModelContextImpl

public ViewModelContextImpl(VElement view,
                            org.eclipse.emf.ecore.EObject domainObject,
                            ViewModelContext parent,
                            VElement parentVElement,
                            ViewModelService... modelServices)
Instantiates a new view model context impl.

Parameters:
view - the view
domainObject - the domain object
modelServices - an array of services to use in the ViewModelContext
Method Detail

getControlsFor

public Set<VControl> getControlsFor(org.eclipse.emf.ecore.EStructuralFeature.Setting setting)
Returns all controls which are associated with the provided EStructuralFeature.Setting. The EStructuralFeature.Setting is converted to a UniqueSetting.

Specified by:
getControlsFor in interface ViewModelContext
Parameters:
setting - the EStructuralFeature.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

public Set<VElement> getControlsFor(UniqueSetting setting)
Returns all controls which are associated with the provided UniqueSetting.

Specified by:
getControlsFor in interface ViewModelContext
Parameters:
setting - the UniqueSetting 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 interface ViewModelContext
Returns:
the view model
See Also:
ViewModelContext.getViewModel()

getDomainModel

public org.eclipse.emf.ecore.EObject getDomainModel()
Gets the domain model.

Specified by:
getDomainModel in interface ViewModelContext
Returns:
the domain model
See Also:
ViewModelContext.getDomainModel()

dispose

public void dispose()
Dispose.

Specified by:
dispose in interface ViewModelContext

registerViewChangeListener

public void registerViewChangeListener(ModelChangeListener modelChangeListener)
Description copied from interface: ViewModelContext
Register view change listener.

Specified by:
registerViewChangeListener in interface ViewModelContext
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 interface ViewModelContext
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 interface ViewModelContext
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 interface ViewModelContext
Parameters:
modelChangeListener - the model change listener

hasService

public <T> boolean hasService(Class<T> serviceType)
Whether the context has a service of the given type serviceType.

Specified by:
hasService in interface ViewModelContext
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(Class<T> serviceType)
Retrieve an ViewModelService of type serviceType.

Specified by:
getService in interface ViewModelContext
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)

addContextUser

public void addContextUser(Object user)
Inner method for registering context users (not ViewModelService).

Specified by:
addContextUser in interface ViewModelContext
Parameters:
user - the user of the context

removeContextUser

public void removeContextUser(Object user)
Inner method for unregistering the context user.

Specified by:
removeContextUser in interface ViewModelContext
Parameters:
user - the user of the context

getContextValue

public Object getContextValue(String key)
Returns the value of the context for the passed key.

Specified by:
getContextValue in interface ViewModelContext
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(String key,
                            Object value)
Puts the value for the provided key into the context.

Specified by:
putContextValue in interface ViewModelContext
Parameters:
key - the key to set
value - the Object to set into the context
See Also:
ViewModelContext.putContextValue(java.lang.String, java.lang.Object)

getChildContext

public ViewModelContext getChildContext(org.eclipse.emf.ecore.EObject eObject,
                                        VElement parent,
                                        VView vView,
                                        ViewModelService... viewModelServices)
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 new ViewModelContext will be created.

Specified by:
getChildContext in interface ViewModelContext
Parameters:
eObject - The EObject to get the child context for
parent - The VElement which requests the child context
vView - The VView of the EObject
viewModelServices - The list of ViewModelService which should be part of a child context
Returns:
a ViewModelContext witch is a child of the current context

registerDisposeListener

public void registerDisposeListener(ViewModelContextDisposeListener listener)
Allows to register a dispose listener.

Specified by:
registerDisposeListener in interface ViewModelContext
Parameters:
listener - The ViewModelContextDisposeListener to register
See Also:
ViewModelContext.registerDisposeListener(org.eclipse.emf.ecp.view.spi.context.ViewModelContextDisposeListener)


Copyright © 2015. All Rights Reserved.