Class ViewerCell

java.lang.Object
org.eclipse.jface.viewers.ViewerCell

public class ViewerCell extends Object
The ViewerCell is the JFace representation of a cell entry in a ViewerRow.
Since:
3.3
  • Field Details

    • ABOVE

      public static final int ABOVE
      Constant denoting the cell above current one (value is 1).
      See Also:
    • BELOW

      public static final int BELOW
      Constant denoting the cell below current one (value is 2).
      See Also:
    • LEFT

      public static final int LEFT
      Constant denoting the cell to the left of the current one (value is 4).
      See Also:
  • Method Details

    • getColumnIndex

      public int getColumnIndex()
      Get the index of the cell.
      Returns:
      the index
    • getBounds

      public Rectangle getBounds()
      Get the bounds of the cell.
      Returns:
      Rectangle
    • getElement

      public Object getElement()
      Get the element this row represents.
      Returns:
      Object
    • getText

      public String getText()
      Return the text for the cell.
      Returns:
      String
    • getImage

      public Image getImage()
      Return the Image for the cell.
      Returns:
      Image or null
    • setBackground

      public void setBackground(Color background)
      Set the background color of the cell.
      Parameters:
      background - color to set
    • setForeground

      public void setForeground(Color foreground)
      Set the foreground color of the cell.
      Parameters:
      foreground - color to set
    • setFont

      public void setFont(Font font)
      Set the font of the cell.
      Parameters:
      font - font to set
    • setText

      public void setText(String text)
      Set the text for the cell.
      Parameters:
      text - text to set
    • setImage

      public void setImage(Image image)
      Set the Image for the cell.
      Parameters:
      image - image to set
    • setStyleRanges

      public void setStyleRanges(StyleRange[] styleRanges)
      Set the style ranges to be applied on the text label Note: Requires StyledCellLabelProvider with owner draw enabled.
      Parameters:
      styleRanges - the styled ranges
      Since:
      3.4
    • getStyleRanges

      public StyleRange[] getStyleRanges()
      Returns the style ranges to be applied on the text label or null if no style ranges have been set.
      Returns:
      styleRanges the styled ranges
      Since:
      3.4
    • getItem

      public Widget getItem()
      Return the item for the receiver.
      Returns:
      Item
    • getControl

      public Control getControl()
      Get the control for this cell.
      Returns:
      Control
    • getVisualIndex

      public int getVisualIndex()
      Get the current index. This can be different from the original index when columns are reordered
      Returns:
      the current index (as shown in the UI)
      Since:
      3.4
    • getNeighbor

      public ViewerCell getNeighbor(int directionMask, boolean sameLevel)
      Returns the specified neighbor of this cell, or null if no neighbor exists in the given direction. Direction constants can be combined by bitwise OR; for example, this method will return the cell to the upper-left of the current cell by passing ABOVE | LEFT. If sameLevel is true, only cells in sibling rows (under the same parent) will be considered.
      Parameters:
      directionMask - the direction mask used to identify the requested neighbor cell
      sameLevel - if true, only consider cells from sibling rows
      Returns:
      the requested neighbor cell, or null if not found
    • getViewerRow

      public ViewerRow getViewerRow()
      Returns:
      the row
    • getTextBounds

      public Rectangle getTextBounds()
      The location and bounds of the area where the text is drawn depends on various things (image displayed, control with SWT.CHECK)
      Returns:
      The bounds of the of the text area. May return null if the underlying widget implementation doesn't provide this information
      Since:
      3.4
    • getImageBounds

      public Rectangle getImageBounds()
      Returns the location and bounds of the area where the image is drawn
      Returns:
      The bounds of the of the image area. May return null if the underlying widget implementation doesn't provide this information
      Since:
      3.4
    • getForeground

      public Color getForeground()
      Gets the foreground color of the cell.
      Returns:
      the foreground of the cell or null for the default foreground
      Since:
      3.4
    • getBackground

      public Color getBackground()
      Gets the background color of the cell.
      Returns:
      the background of the cell or null for the default background
      Since:
      3.4
    • getFont

      public Font getFont()
      Gets the font of the cell.
      Returns:
      the font of the cell or null for the default font
      Since:
      3.4
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • scrollIntoView

      public boolean scrollIntoView()
      Scroll the cell into view
      Returns:
      true if the cell was scrolled into view
      Since:
      3.5