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 (extends IGridItem).
ME - the type of model elements.
M - the type of grid model (extends IGridModel).
All Implemented Interfaces:
IAefGridContentProvider<T>

public abstract class MappingGridContentProvider<T extends IGridItem,ME,M extends IGridModel<ME>> extends Object implements IAefGridContentProvider<T>
The implementation of IAefGridContentProvider that maps domain model elements to view model items.
  • Constructor Details

    • MappingGridContentProvider

      public MappingGridContentProvider(M model)
      Creates a new provider.
      Parameters:
      model - the IGridModel, cannot be null.
  • Method Details

    • getElements

      public Collection<T> getElements()
      Description copied from interface: IAefGridContentProvider
      Retrieves collection of top level elements.
      Specified by:
      getElements in interface IAefGridContentProvider<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 given parentElement.
      Specified by:
      getChildren in interface IAefGridContentProvider<T extends IGridItem>
      Parameters:
      parentElement - the parent element, cannot be null.
      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 given element.
      Specified by:
      getParent in interface IAefGridContentProvider<T extends IGridItem>
      Parameters:
      element - the element, cannot be null.
      Returns:
      the parent element or null.
    • hasChildren

      public boolean hasChildren(T element)
      Description copied from interface: IAefGridContentProvider
      Returns true if the element has children.
      Specified by:
      hasChildren in interface IAefGridContentProvider<T extends IGridItem>
      Parameters:
      element - the element, cannot be null.
      Returns:
      true if the element has children
    • dispose

      public void dispose()
      Description copied from interface: IAefGridContentProvider
      Disposes the provider.
      Specified by:
      dispose in interface IAefGridContentProvider<T extends IGridItem>
    • mapModelToItem

      public T mapModelToItem(ME element)
      Maps the model element to item.
      Parameters:
      element - the model element, cannot be null.
      Returns:
      the view model item.
    • mapItemToModel

      public ME mapItemToModel(T item)
      Maps the item to element.
      Parameters:
      item - the item, cannot be null.
      Returns:
      the mapped element.
    • createItem

      protected abstract T createItem(ME element)
      Creates an item for the given {code element}.
      Parameters:
      element - the element, cannot be null.
      Returns:
      the created item.
    • updateMappedItem

      protected abstract void updateMappedItem(ME element, T item)
      Updates the given item by the given element.
      Parameters:
      element - the element, cannot be null.
      item - the item, cannot be null.
    • 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 given item for the specified color.

      Function caller is responsible for disposing of created image.

      Parameters:
      item - the grid item, cannot be null.
      imageFeature - the feature, cannot be null.
      color - the color.
      Returns:
      a newly created image for the specified color.