MovieLibrary
Class MyTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by MovieLibrary.MyTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class MyTableModel
extends javax.swing.table.AbstractTableModel

Custom table model used as main media library table model

Author:
Alex
See Also:
Serialized Form

Constructor Summary
MyTableModel()
          Constructor calls super() and initializes the data array
 
Method Summary
 void addValue(VideoObject value)
          add given value to the data in the table model
 int getColumnCount()
          gets the number of columns
 java.lang.String getColumnName(int col)
          gets column name of given column
 boolean[] getColumnsShown()
          get the columns shown of this table model
 int[] getColumnWidths()
          gets the column widths of this table model
 java.lang.Object[][] getData()
          gets the data from the data model
 int[] getDefaultColumnWidths()
          gets the default colum widths of the table model
 int getRowCount()
          gets the number of rows
 boolean[] getValidLinks()
          get array of link validity for videos in this table model
 java.lang.Object getValueAt(int row, int col)
          get value of data in the model at give position
 int getVideoID(int row)
          get video ID of video on given row
 java.lang.String getVideoPath(int row)
          gets video path of video on row given
 void removeAll()
          remove all videos from table model
 void setColumnShown(int columnIndex, boolean columnIsShown)
          sets given column shown/hidden
 void setColumnsShown(boolean[] reqColumnsShown)
          sets the columns shown values to the new values
 void setColumnsWidths(int[] reqColumnsWidths)
          sets column widths of this table with new given values
 void setColumnWidth(int columnIndex, int columnWidth)
          sets column width of given column with given width
 void setData(java.lang.Object[][] reqData)
          sets the data of the data model
 void setRows(int rownumber)
          sets the number of rows in the table model
 void setValidLinks(boolean[] reqValidLinks)
          sets the links validity of the videos in the table model
 void setValidLinks(int index, boolean validity)
          set link at given row with validity given (true=link valid)
 void setValueAt(java.lang.Object value, int row, int col)
          sets value of data in the model at given position
 void updateValue(VideoObject value, int row)
          update value on given row with given value
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyTableModel

public MyTableModel()
Constructor calls super() and initializes the data array

Method Detail

getColumnCount

public int getColumnCount()
gets the number of columns


getRowCount

public int getRowCount()
gets the number of rows


getColumnName

public java.lang.String getColumnName(int col)
gets column name of given column

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
get value of data in the model at give position


setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
sets value of data in the model at given position

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getVideoPath

public java.lang.String getVideoPath(int row)
gets video path of video on row given

Parameters:
row - given row where the video path we want is located
Returns:
video path for the video on the given row

getVideoID

public int getVideoID(int row)
get video ID of video on given row

Parameters:
row - row where the video we want the ID from is located
Returns:
video ID of the video on the given row

addValue

public void addValue(VideoObject value)
add given value to the data in the table model

Parameters:
value - value to be added to this table model

updateValue

public void updateValue(VideoObject value,
                        int row)
update value on given row with given value

Parameters:
value - new value to replace old value on given row
row - row where old value is to be replaced with new value

removeAll

public void removeAll()
remove all videos from table model


getValidLinks

public boolean[] getValidLinks()
get array of link validity for videos in this table model

Returns:
array of link validity for videos in this table model

setValidLinks

public void setValidLinks(int index,
                          boolean validity)
set link at given row with validity given (true=link valid)

Parameters:
index - row on which the link validity value is to be updated
validity - value of link validity to be updated to

getColumnWidths

public int[] getColumnWidths()
gets the column widths of this table model

Returns:
column widths of this table model

getColumnsShown

public boolean[] getColumnsShown()
get the columns shown of this table model

Returns:
array of values (true/false) for columns shown or hidden

setColumnsShown

public void setColumnsShown(boolean[] reqColumnsShown)
sets the columns shown values to the new values

Parameters:
reqColumnsShown - new values for columns show to replace old ones

setColumnsWidths

public void setColumnsWidths(int[] reqColumnsWidths)
sets column widths of this table with new given values

Parameters:
reqColumnsWidths - new values given to replace the old column widths

setColumnWidth

public void setColumnWidth(int columnIndex,
                           int columnWidth)
sets column width of given column with given width

Parameters:
columnIndex - column index of column to resize
columnWidth - new width to replace the old width of given column

getData

public java.lang.Object[][] getData()
gets the data from the data model

Returns:
data array from the data model

setData

public void setData(java.lang.Object[][] reqData)
sets the data of the data model

Parameters:
reqData - new data to replace data in the data model

setValidLinks

public void setValidLinks(boolean[] reqValidLinks)
sets the links validity of the videos in the table model

Parameters:
reqValidLinks - links validity values

setColumnShown

public void setColumnShown(int columnIndex,
                           boolean columnIsShown)
sets given column shown/hidden

Parameters:
columnIndex - column to hide/show
columnIsShown - columnvisibility value, shown/hidden

getDefaultColumnWidths

public int[] getDefaultColumnWidths()
gets the default colum widths of the table model

Returns:
the default column widths of the table model

setRows

public void setRows(int rownumber)
sets the number of rows in the table model

Parameters:
rownumber - new number of rows in table model