net.nand.util.i18n.gui
Class PropertiesTranslatorEditor.PTSwingTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by net.nand.util.i18n.gui.PropertiesTranslatorEditor.PTSwingTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Enclosing class:
PropertiesTranslatorEditor

private class PropertiesTranslatorEditor.PTSwingTableModel
extends javax.swing.table.AbstractTableModel

Data model for viewing/editing data in jtab. Adds getCellStatus(int, int). Model row and column numbers are 0-based. Model contains 1 line for each line in pair; its row count is pair.size() + 1 for new data at the end.


Field Summary
private static int NUM_COLS
          Number of columns: key, value src, value dest
 ParsedPropsFilePair pair
           
 int sc
          Search: sr and sc are the row and column of the previous matching cell, if any.
private  java.lang.String searchText
          Search: lowercased current search text, or null if no search or no matches found
 boolean searchWrapped
          If true, and the previous call to search(String, boolean) was successful, the search wrapped around the end of the table before finding a match.
private static long serialVersionUID
           
 int sr
          Search: sr and sc are the row and column of the previous matching cell, if any.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
PropertiesTranslatorEditor.PTSwingTableModel(PropertiesTranslatorEditor pted)
          Create and populate with existing data.
 
Method Summary
 void endSearch()
          Done searching for now.
 PropertiesTranslatorEditor.CellStatus getCellStatus(int r, int c)
          Get the cell status, to visually show the user.
 int getColumnCount()
          3 columns: key, src value, dest value
 java.lang.String getColumnName(int col)
           
 java.lang.String getPTEColumnToolTip(int col)
          Show src/dest file full path; see where-used for details
 int getRowCount()
          1 row for each line in matched pair of data files, plus a blank row at the end
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          In our model this object will always be a String, or "" if the cell is empty.
 boolean isCellEditable(int r, int c)
           
 boolean isRowComment(int r)
          Is this row a comment row, not a key+value row?
 boolean search(java.lang.String txt, boolean forward)
          Case-insensitive text search.
 void setValueAt(java.lang.Object newVal, int r, int c)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

NUM_COLS

private static final int NUM_COLS
Number of columns: key, value src, value dest

See Also:
Constant Field Values

pair

public ParsedPropsFilePair pair

searchText

private java.lang.String searchText
Search: lowercased current search text, or null if no search or no matches found


sr

public int sr
Search: sr and sc are the row and column of the previous matching cell, if any. Next call to search(String, boolean) will start after this cell if the search text is the same as the previous call. To search from another cell, you can change sr and sc before calling search.

If no match was found, sr may be 0 or may be outside the valid range of rows. sc is always valid.

See Also:
searchWrapped, PropertiesTranslatorEditor.CellStatus.SEARCH_MATCH

sc

public int sc
Search: sr and sc are the row and column of the previous matching cell, if any. Next call to search(String, boolean) will start after this cell if the search text is the same as the previous call. To search from another cell, you can change sr and sc before calling search.

If no match was found, sr may be 0 or may be outside the valid range of rows. sc is always valid.

See Also:
searchWrapped, PropertiesTranslatorEditor.CellStatus.SEARCH_MATCH

searchWrapped

public boolean searchWrapped
If true, and the previous call to search(String, boolean) was successful, the search wrapped around the end of the table before finding a match.

See Also:
sr
Constructor Detail

PropertiesTranslatorEditor.PTSwingTableModel

public PropertiesTranslatorEditor.PTSwingTableModel(PropertiesTranslatorEditor pted)
Create and populate with existing data.

Method Detail

endSearch

public void endSearch()
Done searching for now. Stop highlighting matching cells.


search

public boolean search(java.lang.String txt,
                      boolean forward)
Case-insensitive text search. If matches are found, getCellStatus(int, int) will also highlight their cells. When done searching (when closing the search pane), call endSearch() to stop highlighting matches.

If continuing a previous search, keep moving from the previous match; otherwise start from top or bottom of table, depending on search direction.

If a match is found, then sr, sc, and searchWrapped are valid afterwards.

Parameters:
txt - Text to search for, or null to repeat previous search
forward - True to search top to bottom left to right, false to search bottom to top
Returns:
True if a match found, false otherwise

getRowCount

public final int getRowCount()
1 row for each line in matched pair of data files, plus a blank row at the end


getColumnCount

public final int getColumnCount()
3 columns: key, src value, dest value


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
In our model this object will always be a String, or "" if the cell is empty.


setValueAt

public void setValueAt(java.lang.Object newVal,
                       int r,
                       int c)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getColumnName

public java.lang.String getColumnName(int col)
Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

getPTEColumnToolTip

public java.lang.String getPTEColumnToolTip(int col)
Show src/dest file full path; see where-used for details


isCellEditable

public boolean isCellEditable(int r,
                              int c)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

isRowComment

public boolean isRowComment(int r)
Is this row a comment row, not a key+value row?


getCellStatus

public PropertiesTranslatorEditor.CellStatus getCellStatus(int r,
                                                           int c)
Get the cell status, to visually show the user.