com.mucommander.ui.main.table
Class FileTableColumnModel

java.lang.Object
  extended by com.mucommander.ui.main.table.FileTableColumnModel
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.table.TableColumnModel

public class FileTableColumnModel
extends java.lang.Object
implements javax.swing.table.TableColumnModel, java.beans.PropertyChangeListener

Used to keep track of a file table's columns position and visibility settings.

Author:
Nicolas Rinaudo, Maxence Bernard

Constructor Summary
FileTableColumnModel(FileTableConfiguration conf)
          Creates a new file table column model.
 
Method Summary
 void addColumn(javax.swing.table.TableColumn column)
          Adds the specified column to the model.
 void addColumnModelListener(javax.swing.event.TableColumnModelListener listener)
          Registers the specified column model listener.
 java.util.Enumeration getAllColumns()
           
 javax.swing.table.TableColumn getColumn(int index)
          Returns the specified column.
 int getColumnCount()
          Returns the number of columns currently displayed.
 javax.swing.table.TableColumn getColumnFromId(int id)
           
 int getColumnIndex(java.lang.Object identifier)
           
 int getColumnIndexAtX(int x)
          Returns the index of the column at the specified position.
 int getColumnMargin()
          Returns 0.
 int getColumnPosition(int id)
           
 java.util.Enumeration getColumns()
          Returns an enumeration on all visible columns.
 boolean getColumnSelectionAllowed()
          Returns false.
 FileTableConfiguration getConfiguration()
           
 int getSelectedColumnCount()
          Returns 0.
 int[] getSelectedColumns()
          Returns an integer array of size 0.
 javax.swing.ListSelectionModel getSelectionModel()
          Returns a default list selection model.
 int getTotalColumnWidth()
          Returns the total width of the table column model.
 boolean isColumnEnabled(int id)
          Returns true if the specified column is enabled.
 boolean isColumnVisible(int id)
          Returns true if the specified column is visible.
 void moveColumn(int from, int to)
          Moves a column.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Invalidates the width cache if a column's width has changed.
 void removeColumn(javax.swing.table.TableColumn column)
          Removes the specified column from the model.
 void removeColumnModelListener(javax.swing.event.TableColumnModelListener listener)
          Removes the specified column model listener.
 void setColumnEnabled(int id, boolean enabled)
          Sets the specified column's enabled state.
 void setColumnMargin(int margin)
          Ignored.
 void setColumnSelectionAllowed(boolean flag)
          Ignored.
 void setSelectionModel(javax.swing.ListSelectionModel model)
          Ignored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileTableColumnModel

public FileTableColumnModel(FileTableConfiguration conf)
Creates a new file table column model.

Method Detail

getConfiguration

public FileTableConfiguration getConfiguration()

isColumnEnabled

public boolean isColumnEnabled(int id)
Returns true if the specified column is enabled.

Parameters:
id - a column identifier, see Columns for allowed values.
Returns:
true if the column is enabled, false if disabled.

setColumnEnabled

public void setColumnEnabled(int id,
                             boolean enabled)
Sets the specified column's enabled state.

Parameters:
id - a column identifier, see Columns for allowed values.
enabled - true to enable the column, false to disable it.

isColumnVisible

public boolean isColumnVisible(int id)
Returns true if the specified column is visible.

Parameters:
id - identifier of the column as definied in Columns.
Returns:
true if the specified column is visible, false otherwise.

addColumn

public void addColumn(javax.swing.table.TableColumn column)
Adds the specified column to the model.

Specified by:
addColumn in interface javax.swing.table.TableColumnModel
Parameters:
column - column to add to the model.

removeColumn

public void removeColumn(javax.swing.table.TableColumn column)
Removes the specified column from the model.

Specified by:
removeColumn in interface javax.swing.table.TableColumnModel
Parameters:
column - column to remove from the model.

getColumn

public javax.swing.table.TableColumn getColumn(int index)
Returns the specified column.

Specified by:
getColumn in interface javax.swing.table.TableColumnModel
Parameters:
index - index of the column in the model.
Returns:
the requested column.

getColumnFromId

public javax.swing.table.TableColumn getColumnFromId(int id)

getColumnPosition

public int getColumnPosition(int id)

getColumnCount

public int getColumnCount()
Returns the number of columns currently displayed.

Specified by:
getColumnCount in interface javax.swing.table.TableColumnModel
Returns:
the number of columns currently displayed.

moveColumn

public void moveColumn(int from,
                       int to)
Moves a column.

Specified by:
moveColumn in interface javax.swing.table.TableColumnModel
Parameters:
from - index of the column to move.
to - where to move the column.

getColumnIndex

public int getColumnIndex(java.lang.Object identifier)
Specified by:
getColumnIndex in interface javax.swing.table.TableColumnModel

getColumnIndexAtX

public int getColumnIndexAtX(int x)
Returns the index of the column at the specified position.

Specified by:
getColumnIndexAtX in interface javax.swing.table.TableColumnModel
Parameters:
x - position of the column to look for.
Returns:
the index of the column at the specified position, -1 if not found.

getTotalColumnWidth

public int getTotalColumnWidth()
Returns the total width of the table column model.

Specified by:
getTotalColumnWidth in interface javax.swing.table.TableColumnModel
Returns:
the total width of the table column model.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Invalidates the width cache if a column's width has changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getColumnMargin

public int getColumnMargin()
Returns 0.

Specified by:
getColumnMargin in interface javax.swing.table.TableColumnModel
Returns:
0.

setColumnMargin

public void setColumnMargin(int margin)
Ignored.

Specified by:
setColumnMargin in interface javax.swing.table.TableColumnModel

addColumnModelListener

public void addColumnModelListener(javax.swing.event.TableColumnModelListener listener)
Registers the specified column model listener.

Specified by:
addColumnModelListener in interface javax.swing.table.TableColumnModel
Parameters:
listener - listener to register.

removeColumnModelListener

public void removeColumnModelListener(javax.swing.event.TableColumnModelListener listener)
Removes the specified column model listener.

Specified by:
removeColumnModelListener in interface javax.swing.table.TableColumnModel
Parameters:
listener - listener to remove.

getColumnSelectionAllowed

public boolean getColumnSelectionAllowed()
Returns false.

Specified by:
getColumnSelectionAllowed in interface javax.swing.table.TableColumnModel
Returns:
false.

getSelectedColumnCount

public int getSelectedColumnCount()
Returns 0.

Specified by:
getSelectedColumnCount in interface javax.swing.table.TableColumnModel
Returns:
0.

getSelectedColumns

public int[] getSelectedColumns()
Returns an integer array of size 0.

Specified by:
getSelectedColumns in interface javax.swing.table.TableColumnModel
Returns:
an integer array of size 0.

setColumnSelectionAllowed

public void setColumnSelectionAllowed(boolean flag)
Ignored.

Specified by:
setColumnSelectionAllowed in interface javax.swing.table.TableColumnModel

getSelectionModel

public javax.swing.ListSelectionModel getSelectionModel()
Returns a default list selection model.

Ideally, we'd like to return null here, but the table API takes a dim view of this and we're forced to keep a useless reference.

Specified by:
getSelectionModel in interface javax.swing.table.TableColumnModel
Returns:
a default list selection model.

setSelectionModel

public void setSelectionModel(javax.swing.ListSelectionModel model)
Ignored.

Specified by:
setSelectionModel in interface javax.swing.table.TableColumnModel

getColumns

public java.util.Enumeration getColumns()
Returns an enumeration on all visible columns.

Specified by:
getColumns in interface javax.swing.table.TableColumnModel
Returns:
an enumeration on all visible columns.

getAllColumns

public java.util.Enumeration getAllColumns()


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard