Package org.eclipse.jface.viewers
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 Summary
Fields Modifier and Type Field Description static intABOVEConstant denoting the cell above current one (value is 1).static intBELOWConstant denoting the cell below current one (value is 2).static intLEFTConstant denoting the cell to the left of the current one (value is 4).static intRIGHTConstant denoting the cell to the right of the current one (value is 8).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)ColorgetBackground()Gets the background color of the cell.RectanglegetBounds()Get the bounds of the cell.intgetColumnIndex()Get the index of the cell.ControlgetControl()Get the control for this cell.ObjectgetElement()Get the element this row represents.FontgetFont()Gets the font of the cell.ColorgetForeground()Gets the foreground color of the cell.ImagegetImage()Return the Image for the cell.RectanglegetImageBounds()Returns the location and bounds of the area where the image is drawnWidgetgetItem()Return the item for the receiver.ViewerCellgetNeighbor(int directionMask, boolean sameLevel)Returns the specified neighbor of this cell, ornullif no neighbor exists in the given direction.StyleRange[]getStyleRanges()Returns the style ranges to be applied on the text label ornullif no style ranges have been set.StringgetText()Return the text for the cell.RectanglegetTextBounds()The location and bounds of the area where the text is drawn depends on various things (image displayed, control with SWT.CHECK)ViewerRowgetViewerRow()intgetVisualIndex()Get the current index.inthashCode()booleanscrollIntoView()Scroll the cell into viewvoidsetBackground(Color background)Set the background color of the cell.voidsetFont(Font font)Set the font of the cell.voidsetForeground(Color foreground)Set the foreground color of the cell.voidsetImage(Image image)Set the Image for the cell.voidsetStyleRanges(StyleRange[] styleRanges)Set the style ranges to be applied on the text label Note: RequiresStyledCellLabelProviderwith owner draw enabled.voidsetText(String text)Set the text for the cell.
-
-
-
Field Detail
-
ABOVE
public static int ABOVE
Constant denoting the cell above current one (value is 1).
-
BELOW
public static int BELOW
Constant denoting the cell below current one (value is 2).
-
LEFT
public static int LEFT
Constant denoting the cell to the left of the current one (value is 4).
-
RIGHT
public static int RIGHT
Constant denoting the cell to the right of the current one (value is 8).
-
-
Method Detail
-
getColumnIndex
public int getColumnIndex()
Get the index of the cell.- Returns:
- the index
-
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: RequiresStyledCellLabelProviderwith 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 ornullif no style ranges have been set.- Returns:
- styleRanges the styled ranges
- Since:
- 3.4
-
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, ornullif 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 passingABOVE|LEFT. IfsameLevelistrue, only cells in sibling rows (under the same parent) will be considered.- Parameters:
directionMask- the direction mask used to identify the requested neighbor cellsameLevel- iftrue, only consider cells from sibling rows- Returns:
- the requested neighbor cell, or
nullif 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
nullif 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
nullif 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
nullfor the default foreground - Since:
- 3.4
-
getBackground
public Color getBackground()
Gets the background color of the cell.- Returns:
- the background of the cell or
nullfor the default background - Since:
- 3.4
-
getFont
public Font getFont()
Gets the font of the cell.- Returns:
- the font of the cell or
nullfor the default font - Since:
- 3.4
-
scrollIntoView
public boolean scrollIntoView()
Scroll the cell into view- Returns:
- true if the cell was scrolled into view
- Since:
- 3.5
-
-