org.gudy.azureus2.ui.swt.components
Class BufferedTableRow

java.lang.Object
  extended by org.gudy.azureus2.ui.swt.components.BufferedTableRow
Direct Known Subclasses:
TableRowImpl

public class BufferedTableRow
extends Object

A buffered Table Row.

We buffer certain properties of TableRow to save CPU cycles. For example, foreground_colors is cached because TableItem.getForegroundColor is expensive when there is no color set, and setForegroundColor is always expensive.

Text is not buffered as SWT does a good job of buffering it already.

Author:
parg
, TuxPaper (SWT.Virtual Stuff)

Field Summary
protected  ColorCache2.CachedColor foreground_cache
           
protected  org.eclipse.swt.graphics.Color[] foreground_colors
           
protected  org.eclipse.swt.graphics.Image[] image_values
           
protected  TableItemOrTreeItem item
           
protected  ColorCache2.CachedColor ourForeground_cache
           
static int REQUIRE_TABLEITEM
           
static int REQUIRE_TABLEITEM_INITIALIZED
           
static int REQUIRE_VISIBILITY
           
protected  TableOrTreeSWT table
           
 
Constructor Summary
BufferedTableRow(TableOrTreeSWT _table)
          Default constructor
 
Method Summary
 boolean checkWidget(int checkFlags)
          Checks if the widget is valid
 void dispose()
          Disposes of underlying SWT TableItem.
 org.eclipse.swt.graphics.Color getBackground()
           
 org.eclipse.swt.graphics.Image getBackgroundImage()
           
 org.eclipse.swt.graphics.Rectangle getBounds(int index)
           
 org.eclipse.swt.graphics.Color getForeground()
           
 org.eclipse.swt.graphics.Color getForeground(int index)
           
 int getHeight()
           
 org.eclipse.swt.graphics.Image getImage(int index)
           
 int getIndex()
          The Index is this item's the position in list.
 TableItemOrTreeItem getItem()
           
 int getSubItemCount()
           
 TableItemOrTreeItem[] getSubItems()
           
protected  TableOrTreeSWT getTable()
           
protected  String getText(int index)
           
 boolean inPaintItem()
           
 void invalidate()
          Overridable function that is called when row needs invalidation.
 boolean isExpanded()
           
 boolean isSelected()
           
 boolean isVisible()
          Whether the row is currently visible to the user
 boolean isVisibleNoSWT()
           
 void setBackgroundImage(org.eclipse.swt.graphics.Image image)
           
 void setExpanded(boolean b)
           
 boolean setForeground(org.eclipse.swt.graphics.Color c)
           
 boolean setForeground(int index, org.eclipse.swt.graphics.Color new_color)
           
 void setForeground(int red, int green, int blue)
           
 boolean setHeight(int iHeight)
           
 boolean setIconSize(org.eclipse.swt.graphics.Point pt)
           
 void setImage(int index, org.eclipse.swt.graphics.Image new_image)
          Sets the receiver's image at a column.
 void setSelected(boolean bSelected)
           
 void setSubItemCount(int i)
           
 boolean setTableItem(int newIndex, boolean isVisible)
           
 boolean setTableItem(TableItemOrTreeItem newRow, boolean isVisible)
           
 boolean setText(int index, String new_value)
           
 void swt_setForeground(int red, int green, int blue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUIRE_TABLEITEM

public static final int REQUIRE_TABLEITEM
See Also:
Constant Field Values

REQUIRE_TABLEITEM_INITIALIZED

public static final int REQUIRE_TABLEITEM_INITIALIZED
See Also:
Constant Field Values

REQUIRE_VISIBILITY

public static final int REQUIRE_VISIBILITY
See Also:
Constant Field Values

table

protected TableOrTreeSWT table

item

protected TableItemOrTreeItem item

image_values

protected org.eclipse.swt.graphics.Image[] image_values

foreground_colors

protected org.eclipse.swt.graphics.Color[] foreground_colors

foreground_cache

protected ColorCache2.CachedColor foreground_cache

ourForeground_cache

protected ColorCache2.CachedColor ourForeground_cache
Constructor Detail

BufferedTableRow

public BufferedTableRow(TableOrTreeSWT _table)
Default constructor

Parameters:
_table -
Method Detail

dispose

public void dispose()
Disposes of underlying SWT TableItem. If no TableItem has been assigned to the row yet, an unused TableItem will be disposed of, if available.

Disposing of fonts, colors and other resources are the responsibilty of the caller.


setImage

public void setImage(int index,
                     org.eclipse.swt.graphics.Image new_image)
Sets the receiver's image at a column.

Parameters:
index - the column index
new_image - the new image

getImage

public org.eclipse.swt.graphics.Image getImage(int index)

checkWidget

public boolean checkWidget(int checkFlags)
Checks if the widget is valid

Parameters:
checkFlags - REQUIRE_* flags (OR'd)
Returns:
True: Ok; False: Not ok

getForeground

public org.eclipse.swt.graphics.Color getForeground()

setForeground

public boolean setForeground(org.eclipse.swt.graphics.Color c)

setForeground

public void setForeground(int red,
                          int green,
                          int blue)

swt_setForeground

public void swt_setForeground(int red,
                              int green,
                              int blue)

setForeground

public boolean setForeground(int index,
                             org.eclipse.swt.graphics.Color new_color)

getForeground

public org.eclipse.swt.graphics.Color getForeground(int index)

getText

protected String getText(int index)

setText

public boolean setText(int index,
                       String new_value)
Parameters:
index -
new_value -
Returns:
true if the item has been updated

getBounds

public org.eclipse.swt.graphics.Rectangle getBounds(int index)

getTable

protected TableOrTreeSWT getTable()

getBackground

public org.eclipse.swt.graphics.Color getBackground()

getIndex

public int getIndex()
The Index is this item's the position in list.

Returns:
Item's Position

isSelected

public boolean isSelected()

setSelected

public void setSelected(boolean bSelected)

setTableItem

public boolean setTableItem(int newIndex,
                            boolean isVisible)

setTableItem

public boolean setTableItem(TableItemOrTreeItem newRow,
                            boolean isVisible)

setHeight

public boolean setHeight(int iHeight)

getHeight

public int getHeight()

setIconSize

public boolean setIconSize(org.eclipse.swt.graphics.Point pt)

isVisible

public boolean isVisible()
Whether the row is currently visible to the user

Returns:
visibility

invalidate

public void invalidate()
Overridable function that is called when row needs invalidation.


setBackgroundImage

public void setBackgroundImage(org.eclipse.swt.graphics.Image image)

getBackgroundImage

public org.eclipse.swt.graphics.Image getBackgroundImage()

setSubItemCount

public void setSubItemCount(int i)

getSubItemCount

public int getSubItemCount()

getSubItems

public TableItemOrTreeItem[] getSubItems()

setExpanded

public void setExpanded(boolean b)

isExpanded

public boolean isExpanded()

inPaintItem

public boolean inPaintItem()
Returns:
Since:
4.4.0.5

isVisibleNoSWT

public boolean isVisibleNoSWT()

getItem

public TableItemOrTreeItem getItem()