org.gudy.azureus2.plugins.ui.tables
Interface TableCell

All Known Subinterfaces:
TableCellCore, TableCellSWT
All Known Implementing Classes:
FakeTableCell, TableCellPainted, TableCellSWTBase

public interface TableCell

This interface provides access to an Azureus table cell.

Since:
2.0.8.5
Author:
Oliver (Original PeerTableItem Code), TuxPaper (Generic-izing)
See Also:
TableManager

Method Summary
 void addDisposeListener(TableCellDisposeListener listener)
          Adds a listener that triggers when the TableCell has been disposed
 void addListeners(Object listenerObject)
          A listener is added for every type of cell listener the supplied object implements
 void addMouseListener(TableCellMouseListener listener)
          Adds a listener that triggers when a TableCell that belongs to this column has a mouse event.
 void addRefreshListener(TableCellRefreshListener listener)
          Adds a listener that triggers when the TableCell needs refreshing
 void addToolTipListener(TableCellToolTipListener listener)
          Adds a listener related to tooltip actions
 int[] getBackground()
          Get the background color of the cell
 Graphic getBackgroundGraphic()
          Returns a Graphic of what's behind the cell
 String getClipboardText()
          Returns text that's meant for the clipboard
 Object getDataSource()
          Retrieve the data object associated with the current table row and cell.
 int[] getForeground()
          Get the foreground color of the cell
 Graphic getGraphic()
          Retrieve the SWT graphic related to this table item for TableColumn objects of TYPE_GRAPHIC only.
 int getHeight()
          Retrieve the height of the cell's drawing area (excluding any margin) for TableColumn objects of TYPE_GRAPHIC only.
 int getMarginHeight()
           
 int getMarginWidth()
           
 int getMaxLines()
          Retrieves the number of lines available for setting text
 int[] getMouseOffset()
          Return the position of the mouse relative to the cell.
 Comparable getSortValue()
          Retrieves the sorting value
 TableColumn getTableColumn()
          Retreive the TableColumn that this cell belongs to
 String getTableID()
          Returns which table the cell is being displayed in.
 TableRow getTableRow()
          Retrieve the TableRow that this cell belongs to
 String getText()
          Retrieve the Cell's text
 Object getToolTip()
          Retrieve the tooltip object assigned to this cell
 int getWidth()
          Retrieve the width of the cell's drawing area (excluding any margin) for TableColumn objects of TYPE_GRAPHIC only.
 void invalidate()
          Sets the cell to invalid.
 boolean isDisposed()
          Retrieve whether the cell has been disposed.
 boolean isShown()
          Determines if the user has chosen to display the cell
 boolean isValid()
          Validility of the cell's text.
 void removeDisposeListener(TableCellDisposeListener listener)
          Remove a previously added TableCellDisposeListener
 void removeMouseListener(TableCellMouseListener listener)
          Remove a previously added TableCellMouseListener
 void removeRefreshListener(TableCellRefreshListener listener)
          Remove a previously added TableCellRefreshListener
 void removeToolTipListener(TableCellToolTipListener listener)
          Remove a previously added TableCellToolTipListener
 void setFillCell(boolean bFillCell)
          Sets whether the graphic fills the whole cell for TableColumn objects of TYPE_GRAPHIC only.
 boolean setForeground(int[] rgb)
          Change the cell's foreground color
 boolean setForeground(int red, int green, int blue)
          Change the cell's foreground color.
 boolean setForegroundToErrorColor()
          Change the cell's foreground color to the user's defined "error" color.
 boolean setGraphic(Graphic img)
          Sets the image to be drawn.
 void setMarginHeight(int height)
          Specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout for TableColumn objects of TYPE_GRAPHIC only.
 void setMarginWidth(int width)
          Specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the layout for TableColumn object of TYPE_GRAPHIC only.
 boolean setSortValue(Comparable valueToSort)
          Sets a Comparable object that column sorting will act on.
 boolean setSortValue(float valueToSort)
          Sets a float value that the column sorting will act upon.
 boolean setSortValue(long valueToSort)
          Sets a long value that the column sorting will act on.
 boolean setText(String text)
          This method is called to set the cell's text.
 void setToolTip(Object tooltip)
          Set the cell's tooltip display.
 

Method Detail

getDataSource

Object getDataSource()
Retrieve the data object associated with the current table row and cell. The results of this method MUST NOT BE CACHED. The link between a table cell and a DataSource is not persistent and can change from call to call (for example when the table is re-ordered, the link may be modified)

Returns:
The return type is dependent upon which table the cell is for:
TABLE_MYTORRENTS_*: Download object for the current row
TABLE_TORRENT_PEERS: Peer object for the current row
TABLE_TORRENT_FILES: DiskManagerFileInfo object for the current row
TABLE_MYTRACKER: TrackerTorrent object for the current row
TABLE_MYSHARES: ShareResource object for the current row
remaining TABLE_* constants: undefined or null

getTableColumn

TableColumn getTableColumn()
Retreive the TableColumn that this cell belongs to

Returns:
this cell's TableColumn

getTableRow

TableRow getTableRow()
Retrieve the TableRow that this cell belongs to

Returns:
this cell's TableRow

getTableID

String getTableID()
Returns which table the cell is being displayed in.

Returns:
TableManager.TABLE_* constant

setText

boolean setText(String text)
This method is called to set the cell's text. Caching is done, so that if same text is used several times, there won't be any 'flickering' effect. Ie the text is only updated if it's different from current value.

This function must be called from the same thread that the GUI is running under. Listeners like TableCellAddedListener do not always get called on the GUI thread.

If you wish to set the text and not worry about changing to the GUI thread, use invalidate(), and set the text in the TableCellRefreshListener

Parameters:
text - the text to be set
Returns:
True - the text was updated.
False - the text was the same and not modified.

getText

String getText()
Retrieve the Cell's text

Returns:
Cell's text

setForeground

boolean setForeground(int red,
                      int green,
                      int blue)
Change the cell's foreground color.

pass -1 to return color back to default

Parameters:
red - red value (0 - 255)
green - green value (0 - 255)
blue - blue value (0 - 255)
Returns:
True - Color changed.
False - Color was already set.

setForeground

boolean setForeground(int[] rgb)
Change the cell's foreground color

Parameters:
rgb - int array containing red, green, and blue values, respectively. null to return color back to default
Returns:
Since:
3.0.4.3

setForegroundToErrorColor

boolean setForegroundToErrorColor()
Change the cell's foreground color to the user's defined "error" color.

Returns:
True - Color changed.
False - Color was already set.
Since:
3.0.3.5

getForeground

int[] getForeground()
Get the foreground color of the cell

Returns:
array containing red, green, and blue color
Since:
2.5.0.1

getBackground

int[] getBackground()
Get the background color of the cell

Returns:
array containing red, green, and blue color. Might be null
Since:
3.0.3.5

setSortValue

boolean setSortValue(Comparable valueToSort)
Sets a Comparable object that column sorting will act on. If you never call setSortValue, your column will be sorted by the cell's text.

Parameters:
valueToSort - the object that will be used when the column cell's are compared to each other
Returns:
True - Sort Value changed.
False - Sort Value was already set to object supplied.

setSortValue

boolean setSortValue(long valueToSort)
Sets a long value that the column sorting will act on.

Parameters:
valueToSort - sorting value.
Returns:
True - Sort Value changed.
False - Sort Value was already set to value supplied.

setSortValue

boolean setSortValue(float valueToSort)
Sets a float value that the column sorting will act upon.

Parameters:
valueToSort - float sort value
Returns:
true if sort value changed, or false if sort value already set to value supplied

getSortValue

Comparable getSortValue()
Retrieves the sorting value

Returns:
Object that will be sorted on

isShown

boolean isShown()
Determines if the user has chosen to display the cell

Returns:
True - User has chosen to display cell

isValid

boolean isValid()
Validility of the cell's text.

Returns:
True - Text is the same as last call. You do not need to update unless you have new text to display.
False - Cell-to-Datasource link has changed, and the text is definitely not valid.

invalidate

void invalidate()
Sets the cell to invalid. This will result in a refresh on the next scheduled interval.

Since:
2.3.0.7

setToolTip

void setToolTip(Object tooltip)
Set the cell's tooltip display.

Parameters:
tooltip - Object to display. Currently, only String is supported
Since:
2.1.0.2
See Also:
addToolTipListener(TableCellToolTipListener)

getToolTip

Object getToolTip()
Retrieve the tooltip object assigned to this cell

Returns:
tooltip object
Since:
2.1.0.2
See Also:
addToolTipListener(TableCellToolTipListener)

isDisposed

boolean isDisposed()
Retrieve whether the cell has been disposed. This will return true after the TableCellDisposeListener is triggered.

Returns:
disposal state
Since:
2.3.0.7

getMaxLines

int getMaxLines()
Retrieves the number of lines available for setting text

Returns:
# of lines available, -1 if unknown
Since:
3.0.1.1

getWidth

int getWidth()
Retrieve the width of the cell's drawing area (excluding any margin) for TableColumn objects of TYPE_GRAPHIC only.

Returns:
if you are filling the cell, this is the width your image should be

getHeight

int getHeight()
Retrieve the height of the cell's drawing area (excluding any margin) for TableColumn objects of TYPE_GRAPHIC only.

Returns:
if you are filling the cell, this is the height your image should be

setGraphic

boolean setGraphic(Graphic img)
Sets the image to be drawn.

From 3.0.1.1, setting the graphic to the same Graphic object will not redraw the image. You need to invalidate() the cell if you know the image bits have changed (or you could pass a new Graphic object in each time a new image is generated)

Previously, setting the graphic to the same object resulted in a repaint. Plugins were naughty and would do this on every refresh, causing horrible repaint slowdowns.

Parameters:
img - image to be stored & drawn
Returns:
true - image was changed.
false = image was the same

getGraphic

Graphic getGraphic()
Retrieve the SWT graphic related to this table item for TableColumn objects of TYPE_GRAPHIC only.

Returns:
the Image that is draw in the cell, or null if there is none.

setFillCell

void setFillCell(boolean bFillCell)
Sets whether the graphic fills the whole cell for TableColumn objects of TYPE_GRAPHIC only. This may effect how often a refresh of the cell is needed, and effects alignment.

Parameters:
bFillCell - true - the whole cell is filled by the graphic

getMarginHeight

int getMarginHeight()
Returns:
Since:
3.0.5.3

setMarginHeight

void setMarginHeight(int height)
Specifies the number of pixels of vertical margin that will be placed along the top and bottom edges of the layout for TableColumn objects of TYPE_GRAPHIC only.

The default is 1.

Parameters:
height - new margin height

getMarginWidth

int getMarginWidth()
Returns:
Since:
3.0.5.3

setMarginWidth

void setMarginWidth(int width)
Specifies the number of pixels of horizontal margin that will be placed along the left and right edges of the layout for TableColumn object of TYPE_GRAPHIC only.

The default is 1.

Parameters:
width - new margin width

addRefreshListener

void addRefreshListener(TableCellRefreshListener listener)
Adds a listener that triggers when the TableCell needs refreshing

Parameters:
listener - Listener Object to be called when refresh is needed.

removeRefreshListener

void removeRefreshListener(TableCellRefreshListener listener)
Remove a previously added TableCellRefreshListener

Parameters:
listener - Previously added listener

addDisposeListener

void addDisposeListener(TableCellDisposeListener listener)
Adds a listener that triggers when the TableCell has been disposed

Parameters:
listener - listener object to be called

removeDisposeListener

void removeDisposeListener(TableCellDisposeListener listener)
Remove a previously added TableCellDisposeListener

Parameters:
listener - Previously added listener

addToolTipListener

void addToolTipListener(TableCellToolTipListener listener)
Adds a listener related to tooltip actions

Parameters:
listener - listener object to be called

removeToolTipListener

void removeToolTipListener(TableCellToolTipListener listener)
Remove a previously added TableCellToolTipListener

Parameters:
listener - Previously added listener

addMouseListener

void addMouseListener(TableCellMouseListener listener)
Adds a listener that triggers when a TableCell that belongs to this column has a mouse event.

Parameters:
listener -
Since:
2.3.0.7

removeMouseListener

void removeMouseListener(TableCellMouseListener listener)
Remove a previously added TableCellMouseListener

Parameters:
listener - Previously added listener
Since:
2.3.0.7

addListeners

void addListeners(Object listenerObject)
A listener is added for every type of cell listener the supplied object implements

Parameters:
listenerObject - Object implementing some cell listeneters

getBackgroundGraphic

Graphic getBackgroundGraphic()
Returns a Graphic of what's behind the cell

Returns:
Since:
3.0.3.5

getMouseOffset

int[] getMouseOffset()
Return the position of the mouse relative to the cell.

Returns:
array of 2 containing x and y position position relative to cell. null if cell doesn't have mouse.
Since:
3.0.4.3

getClipboardText

String getClipboardText()
Returns text that's meant for the clipboard

Since:
4.3.1.5