|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.AbstractTableModel | +--guk.editIM.MapTable
An abstract implementation of the data model for the unicode keymap editor tables in terms of an AbstractTableModel. Contains additional methods for controlling the data and importing and exporting it in form of AssignObject objects. Also contains renderer and editor code, note the unusual place! Allowing them to access internal data that way.
Field Summary | |
protected java.util.Vector |
assignments
The table data, can grow on demand using our addRow() method. |
protected boolean |
changedFlag
|
protected javax.swing.table.DefaultTableCellRenderer |
tcRenderer
A standard renderer which we tune below. |
protected int |
transferFormat
Format to be used by getValueAt and setValueAt (and therefore by Cell Editors, too!). |
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary | |
MapTable()
The default constructor does not do much. |
Method Summary | |
boolean |
addEntry(AssignObject ao)
Merges an entry into the table, returns false on failure Normally, merge succeeds, but in the GlyphTable implementation, further constraints have to be followed. |
void |
addRow()
Add a row to the table. |
void |
clearChanged()
Clear change flag. |
boolean |
flushTable()
Removes all entries, returns false on failure |
java.lang.Class |
getColumnClass(int col)
Fetches the column data types, which Java uses to select a renderer component for the column. |
int |
getColumnCount()
Checks how many columns the table contains. |
java.lang.String |
getColumnName(int col)
Fetches the column names for the headers and for finding columns. |
int |
getRowCount()
Checks how many rows the table contains. |
java.awt.Component |
getTableCellRendererComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column)
Returns a component that renders the given cell. |
java.lang.Object |
getValueAt(int row,
int col)
Fetch the contents of a certain table cell. |
boolean |
isCellEditable(int row,
int col)
Tells whether a certain cell can be edited. |
boolean |
isChanged()
Checks if the table contains unsaved changes. |
void |
processCommand(java.lang.String command,
int modifiers,
boolean checked)
The generic MapTable does not process any commands yet: Implementing classes are likely to override this method, so that you can send them commands. |
java.util.Collection |
readTable()
Returns the Collection with all entries (for saving them). |
boolean |
removeEntry(AssignObject ao)
Finds and removes an entry from the table, returns false on failure |
void |
setValueAt(java.lang.Object val,
int row,
int col)
Update a cell value. |
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
|
Field Detail |
protected javax.swing.table.DefaultTableCellRenderer tcRenderer
protected final int transferFormat
protected java.util.Vector assignments
protected boolean changedFlag
Constructor Detail |
public MapTable()
Method Detail |
public boolean flushTable()
public java.util.Collection readTable()
public boolean addEntry(AssignObject ao)
public boolean removeEntry(AssignObject ao)
public boolean isChanged()
public void clearChanged()
public int getRowCount()
getRowCount
in class javax.swing.table.AbstractTableModel
public int getColumnCount()
getColumnCount
in class javax.swing.table.AbstractTableModel
public java.lang.Object getValueAt(int row, int col)
getValueAt
in class javax.swing.table.AbstractTableModel
row
- The table row, selecting an AssignObject.col
- The column, selecting the part of the AssignObject.public java.lang.String getColumnName(int col)
getColumnName
in class javax.swing.table.AbstractTableModel
col
- The column for which you want to know the name.public java.lang.Class getColumnClass(int col)
getColumnClass
in class javax.swing.table.AbstractTableModel
col
- The column for which you want to know the type.public boolean isCellEditable(int row, int col)
isCellEditable
in class javax.swing.table.AbstractTableModel
row
- The affected row (not likely to matter)col
- The affected column: implementing classes
may return false for columns where they do not want Java
to allow the user to activate the editor component.public void setValueAt(java.lang.Object val, int row, int col)
setValueAt
in class javax.swing.table.AbstractTableModel
val
- Usually a string with the new value for that cell.row
- The row where the value is to be stored.col
- The column where the value is to be stored.public void addRow()
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
This table model provides its own renderer, which sets the color according to which unicode range holds the affected row
WARNING: TableModels normally do not implement TableCellRenderer and this exception (activated via table.setDefaultRenderer(...)) means that we have to be CAREFUL with coordinates: JTable and renderer stuff uses VIEW coordinates, but the Model uses MODEL coordinates. The user may have swapped (by dragging) the columns!
getTableCellRendererComponent
in interface javax.swing.table.TableCellRenderer
TableCellRenderer
public void processCommand(java.lang.String command, int modifiers, boolean checked)
command
- A textual representation of something that
should happen with the table data.modifiers
- ActionEvent modifiers which may affect
the command.checked
- A boolean value that may affect the command.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |