Class MappingGridContentProvider<T extends IGridItem,ME,M extends IGridModel<ME>>
- java.lang.Object
-
- com._1c.g5.v8.dt.ui.aef.providers.MappingGridContentProvider<T,ME,M>
-
- Type Parameters:
T
- the type of view model (extendsIGridItem
).ME
- the type of model elements.M
- the type of grid model (extendsIGridModel
).
- All Implemented Interfaces:
IAefGridContentProvider<T>
public abstract class MappingGridContentProvider<T extends IGridItem,ME,M extends IGridModel<ME>> extends Object implements IAefGridContentProvider<T>
The implementation ofIAefGridContentProvider
that maps domain model elements to view model items.
-
-
Constructor Summary
Constructors Constructor Description MappingGridContentProvider(M model)
Creates a new provider.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
createItem(ME element)
Creates an item for the given {code element}.void
dispose()
Disposes the provider.Collection<T>
getChildren(T parentElement)
Retrieves collection of children for a givenparentElement
.Collection<T>
getElements()
Retrieves collection of top level elements.protected M
getModel()
Returns the grid model.T
getParent(T element)
Returns the parent of the givenelement
.boolean
hasChildren(T element)
Returnstrue
if the element has children.ME
mapItemToModel(T item)
Maps the item to element.T
mapModelToItem(ME element)
Maps the model element to item.protected static org.eclipse.swt.graphics.Image
updateItemImageForColor(IGridItem item, org.eclipse.emf.ecore.EStructuralFeature imageFeature, Color color)
Updates the image of givenitem
for the specifiedcolor
.protected abstract void
updateMappedItem(ME element, T item)
Updates the givenitem
by the givenelement
.
-
-
-
Constructor Detail
-
MappingGridContentProvider
public MappingGridContentProvider(M model)
Creates a new provider.- Parameters:
model
- theIGridModel
, cannot benull
.
-
-
Method Detail
-
getElements
public Collection<T> getElements()
Description copied from interface:IAefGridContentProvider
Retrieves collection of top level elements.- Specified by:
getElements
in interfaceIAefGridContentProvider<T extends IGridItem>
- Returns:
- the top level elements, never
null
.
-
getChildren
public Collection<T> getChildren(T parentElement)
Description copied from interface:IAefGridContentProvider
Retrieves collection of children for a givenparentElement
.- Specified by:
getChildren
in interfaceIAefGridContentProvider<T extends IGridItem>
- Parameters:
parentElement
- the parent element, cannot benull
.- Returns:
- the collection of children of the parent element, never
null
.
-
getParent
public T getParent(T element)
Description copied from interface:IAefGridContentProvider
Returns the parent of the givenelement
.- Specified by:
getParent
in interfaceIAefGridContentProvider<T extends IGridItem>
- Parameters:
element
- the element, cannot benull
.- Returns:
- the parent element or
null
.
-
hasChildren
public boolean hasChildren(T element)
Description copied from interface:IAefGridContentProvider
Returnstrue
if the element has children.- Specified by:
hasChildren
in interfaceIAefGridContentProvider<T extends IGridItem>
- Parameters:
element
- the element, cannot benull
.- Returns:
true
if the element has children
-
dispose
public void dispose()
Description copied from interface:IAefGridContentProvider
Disposes the provider.- Specified by:
dispose
in interfaceIAefGridContentProvider<T extends IGridItem>
-
mapModelToItem
public T mapModelToItem(ME element)
Maps the model element to item.- Parameters:
element
- the model element, cannot benull
.- Returns:
- the view model item.
-
mapItemToModel
public ME mapItemToModel(T item)
Maps the item to element.- Parameters:
item
- the item, cannot benull
.- Returns:
- the mapped element.
-
createItem
protected abstract T createItem(ME element)
Creates an item for the given {code element}.- Parameters:
element
- the element, cannot benull
.- Returns:
- the created item.
-
updateMappedItem
protected abstract void updateMappedItem(ME element, T item)
Updates the givenitem
by the givenelement
.- Parameters:
element
- the element, cannot benull
.item
- the item, cannot benull
.
-
getModel
protected M getModel()
Returns the grid model.- Returns:
- the grid model, never
null
.
-
updateItemImageForColor
protected static org.eclipse.swt.graphics.Image updateItemImageForColor(IGridItem item, org.eclipse.emf.ecore.EStructuralFeature imageFeature, Color color)
Updates the image of givenitem
for the specifiedcolor
.Function caller is responsible for disposing of created image.
- Parameters:
item
- the grid item, cannot benull
.imageFeature
- the feature, cannot benull
.color
- the color.- Returns:
- a newly created image for the specified
color
.
-
-