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 int
ABOVE
Constant denoting the cell above current one (value is 1).static int
BELOW
Constant denoting the cell below current one (value is 2).static int
LEFT
Constant denoting the cell to the left of the current one (value is 4).static int
RIGHT
Constant 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 boolean
equals(Object obj)
Color
getBackground()
Gets the background color of the cell.Rectangle
getBounds()
Get the bounds of the cell.int
getColumnIndex()
Get the index of the cell.Control
getControl()
Get the control for this cell.Object
getElement()
Get the element this row represents.Font
getFont()
Gets the font of the cell.Color
getForeground()
Gets the foreground color of the cell.Image
getImage()
Return the Image for the cell.Rectangle
getImageBounds()
Returns the location and bounds of the area where the image is drawnWidget
getItem()
Return the item for the receiver.ViewerCell
getNeighbor(int directionMask, boolean sameLevel)
Returns the specified neighbor of this cell, ornull
if no neighbor exists in the given direction.StyleRange[]
getStyleRanges()
Returns the style ranges to be applied on the text label ornull
if no style ranges have been set.String
getText()
Return the text for the cell.Rectangle
getTextBounds()
The location and bounds of the area where the text is drawn depends on various things (image displayed, control with SWT.CHECK)ViewerRow
getViewerRow()
int
getVisualIndex()
Get the current index.int
hashCode()
boolean
scrollIntoView()
Scroll the cell into viewvoid
setBackground(Color background)
Set the background color of the cell.void
setFont(Font font)
Set the font of the cell.void
setForeground(Color foreground)
Set the foreground color of the cell.void
setImage(Image image)
Set the Image for the cell.void
setStyleRanges(StyleRange[] styleRanges)
Set the style ranges to be applied on the text label Note: RequiresStyledCellLabelProvider
with owner draw enabled.void
setText(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: RequiresStyledCellLabelProvider
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 ornull
if 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, ornull
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 passingABOVE
|LEFT
. IfsameLevel
istrue
, 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
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
-
scrollIntoView
public boolean scrollIntoView()
Scroll the cell into view- Returns:
- true if the cell was scrolled into view
- Since:
- 3.5
-
-