org.eclipse.emfforms.internal.spreadsheet.core
Class EMFFormsSpreadsheetViewModelContext

java.lang.Object
  extended by org.eclipse.emfforms.internal.spreadsheet.core.EMFFormsSpreadsheetViewModelContext
All Implemented Interfaces:
ViewModelContext

public class EMFFormsSpreadsheetViewModelContext
extends Object
implements ViewModelContext

Spreadsheet specific implementation of the ViewModelContext. This implementation doesn't do anything, it serves only as a container for a VView and the EObject.

Author:
Eugen Neufeld

Constructor Summary
EMFFormsSpreadsheetViewModelContext(VView view, org.eclipse.emf.ecore.EObject domainModel)
          Default Constructor.
 
Method Summary
 void addContextUser(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 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)
          Removes a 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

EMFFormsSpreadsheetViewModelContext

public EMFFormsSpreadsheetViewModelContext(VView view,
                                           org.eclipse.emf.ecore.EObject domainModel)
Default Constructor.

Parameters:
view - The VView
domainModel - The EObject
Method Detail

registerDomainChangeListener

public void registerDomainChangeListener(ModelChangeListener modelChangeListener)
Register domain change listener.

Specified by:
registerDomainChangeListener in interface ViewModelContext
Parameters:
modelChangeListener - the model change listener
See Also:
ViewModelContext.registerDomainChangeListener(org.eclipse.emf.ecp.view.spi.model.ModelChangeListener)

unregisterDomainChangeListener

public void unregisterDomainChangeListener(ModelChangeListener modelChangeListener)
Unregister domain change listener.

Specified by:
unregisterDomainChangeListener in interface ViewModelContext
Parameters:
modelChangeListener - the model change listener
See Also:
ViewModelContext.unregisterDomainChangeListener(org.eclipse.emf.ecp.view.spi.model.ModelChangeListener)

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()

registerViewChangeListener

public void registerViewChangeListener(ModelChangeListener modelChangeListener)
Register view change listener.

Specified by:
registerViewChangeListener in interface ViewModelContext
Parameters:
modelChangeListener - the model change listener
See Also:
ViewModelContext.registerViewChangeListener(org.eclipse.emf.ecp.view.spi.model.ModelChangeListener)

unregisterViewChangeListener

public void unregisterViewChangeListener(ModelChangeListener modelChangeListener)
Unregister view change listener.

Specified by:
unregisterViewChangeListener in interface ViewModelContext
Parameters:
modelChangeListener - the model change listener
See Also:
ViewModelContext.unregisterViewChangeListener(org.eclipse.emf.ecp.view.spi.model.ModelChangeListener)

dispose

public void dispose()
Disposes the context.

Specified by:
dispose in interface ViewModelContext
See Also:
ViewModelContext.dispose()

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)

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)

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)
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
See Also:
ViewModelContext.getChildContext(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecp.view.spi.model.VElement, org.eclipse.emf.ecp.view.spi.model.VView, org.eclipse.emf.ecp.view.spi.context.ViewModelService[])

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)

addContextUser

public void addContextUser(Object user)
Adds a user of the context.

Specified by:
addContextUser in interface ViewModelContext
Parameters:
user - The context user to add
See Also:
ViewModelContext.addContextUser(java.lang.Object)

removeContextUser

public void removeContextUser(Object user)
Removes a context user.

Specified by:
removeContextUser in interface ViewModelContext
Parameters:
user - The context user to remove
See Also:
ViewModelContext.removeContextUser(java.lang.Object)


Copyright © 2015. All Rights Reserved.