|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel org.fife.ui.FileExplorerTableModel
public class FileExplorerTableModel
A table model that simulates the functionality found in the table used in
Windows' "details view" in Windows explorer. This is a WIP, and currently is
pretty much just a copy of FileExplorerTableModel.java
found in
java.sun.com's tutorial section.
This model currently allows the user to sort by column, and colors the cells of elements in sorted-by columns slightly darker than normal, to signify that the table is sorted by that row. Future enhancements include a right-click popup menu for the table header that allows you to add or remove columns.
NOTE: If you use this table model in an application that allows the user to change the LaF at runtime, you will get NullPointerExceptions when the user changes from the Windows LaF to another LaF, such as Metal. This is due to Sun bug 6429812. This bug is still open as of 6u18. You'll have to implement a workaround for when the LaF changes if you want to use this class in an application that allows runtime LaF changes. See 6429812 for more information. As an alternative, you can probably use Swing's built-in table sorting support, if you only support Java 6 and up.
Nested Class Summary | |
---|---|
class |
FileExplorerTableModel.SortableHeaderRenderer
A cell renderer for column headers for sorted tables. |
Field Summary | |
---|---|
static int |
ASCENDING
|
static java.util.Comparator<?> |
COMPARABLE_COMPARATOR
Compares two comparable objects by their compareTo method. |
static int |
DESCENDING
|
static java.util.Comparator<?> |
LEXICAL_COMPARATOR
Compares two objects by their string ( toString ) values. |
static int |
NOT_SORTED
|
protected javax.swing.table.TableModel |
tableModel
|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
FileExplorerTableModel()
Constructor. |
|
FileExplorerTableModel(javax.swing.table.TableModel tableModel)
Constructor. |
|
FileExplorerTableModel(javax.swing.table.TableModel tableModel,
javax.swing.table.JTableHeader tableHeader)
Constructor. |
Method Summary | |
---|---|
java.lang.Class<?> |
getColumnClass(int column)
|
int |
getColumnCount()
|
java.lang.String |
getColumnName(int column)
|
protected java.util.Comparator |
getComparator(int column)
|
protected javax.swing.Icon |
getHeaderRendererIcon(int column,
int size)
|
int |
getRowCount()
|
int |
getSortingStatus(int column)
|
javax.swing.table.JTableHeader |
getTableHeader()
Returns the table header being used. |
javax.swing.table.TableModel |
getTableModel()
Returns the table model being used. |
java.lang.Object |
getValueAt(int row,
int column)
|
boolean |
isCellEditable(int row,
int column)
|
boolean |
isSorting()
|
int |
modelIndex(int viewIndex)
|
void |
setColumnComparator(java.lang.Class<?> type,
java.util.Comparator<?> comparator)
|
void |
setSortingStatus(int column,
int status)
|
void |
setTable(javax.swing.JTable table)
Sets the table this sorter is the model for. |
void |
setTableModel(javax.swing.table.TableModel tableModel)
Sets the table model to use. |
void |
setValueAt(java.lang.Object aValue,
int row,
int column)
|
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.swing.table.TableModel tableModel
public static final int DESCENDING
public static final int NOT_SORTED
public static final int ASCENDING
public static final java.util.Comparator<?> COMPARABLE_COMPARATOR
compareTo
method.
public static final java.util.Comparator<?> LEXICAL_COMPARATOR
toString
) values.
Constructor Detail |
---|
public FileExplorerTableModel()
public FileExplorerTableModel(javax.swing.table.TableModel tableModel)
tableModel
- ???public FileExplorerTableModel(javax.swing.table.TableModel tableModel, javax.swing.table.JTableHeader tableHeader)
tableModel
- ???tableHeader
- ???Method Detail |
---|
protected java.util.Comparator getComparator(int column)
protected javax.swing.Icon getHeaderRendererIcon(int column, int size)
public int getSortingStatus(int column)
public javax.swing.table.JTableHeader getTableHeader()
public javax.swing.table.TableModel getTableModel()
setTableModel(javax.swing.table.TableModel)
public boolean isSorting()
public int modelIndex(int viewIndex)
public void setColumnComparator(java.lang.Class<?> type, java.util.Comparator<?> comparator)
public void setSortingStatus(int column, int status)
public void setTable(javax.swing.JTable table)
null
value, any columns by which the table is sorted
will be colored with a slightly-darker background (similar to how it's
done in Windows XP).
table
- The table for which this model is the model.public void setTableModel(javax.swing.table.TableModel tableModel)
tableModel
- The table model to use.getTableModel()
public int getRowCount()
public int getColumnCount()
public java.lang.String getColumnName(int column)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
public java.lang.Class<?> getColumnClass(int column)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
public boolean isCellEditable(int row, int column)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public java.lang.Object getValueAt(int row, int column)
public void setValueAt(java.lang.Object aValue, int row, int column)
setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |