[Jreepad-CVS] jreepad/src/jreepad/editor TableViewer.java,1.1,1.2
Brought to you by:
danstowell
From: PeWu <pe...@us...> - 2007-02-07 21:19:16
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22782/src/jreepad/editor Modified Files: TableViewer.java Log Message: refactoring: Moved TableViewer to ArticleView interface Index: TableViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/TableViewer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TableViewer.java 6 Feb 2007 18:33:08 -0000 1.1 --- TableViewer.java 7 Feb 2007 21:19:11 -0000 1.2 *************** *** 22,25 **** --- 22,26 ---- import java.awt.Color; + import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; *************** *** 34,60 **** * Converts CSV content to table view. */ ! public class TableViewer extends JTable { ! private JreepadArticle article; public TableViewer(JreepadArticle article) { ! super(getTableModel(article)); ! this.article = article; ! setAutoResizeMode(JTable.AUTO_RESIZE_OFF); ! setGridColor(Color.GRAY); ! setShowGrid(true); ! setShowVerticalLines(true); ! setShowHorizontalLines(true); } ! public void setArticle(JreepadArticle article) { ! this.article = article; ! reloadArticle(); } public void reloadArticle() { ! setModel(getTableModel(article)); } --- 35,61 ---- * Converts CSV content to table view. */ ! public class TableViewer extends AbstractArticleView { ! private JTable table; public TableViewer(JreepadArticle article) { ! super(article); ! table = new JTable(getTableModel(article)); ! table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); ! table.setGridColor(Color.GRAY); ! table.setShowGrid(true); ! table.setShowVerticalLines(true); ! table.setShowHorizontalLines(true); } ! public JComponent getComponent() { ! return table; } + public void reloadArticle() { ! table.setModel(getTableModel(article)); } *************** *** 70,75 **** public String getText() { ! int w = getColumnCount(); ! int h = getRowCount(); StringBuffer csv = new StringBuffer(); String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; --- 71,76 ---- public String getText() { ! int w = table.getColumnCount(); ! int h = table.getRowCount(); StringBuffer csv = new StringBuffer(); String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; *************** *** 77,84 **** { for (int j = 0; j < (w - 1); j++) ! csv.append(quoteMark + (String) getValueAt(i, j) + quoteMark ! + ","); ! csv.append(quoteMark + (String) getValueAt(i, w - 1) + quoteMark ! + "\n"); } return csv.toString(); --- 78,83 ---- { for (int j = 0; j < (w - 1); j++) ! csv.append(quoteMark + (String) table.getValueAt(i, j) + quoteMark + ","); ! csv.append(quoteMark + (String) table.getValueAt(i, w - 1) + quoteMark + "\n"); } return csv.toString(); *************** *** 87,95 **** public String getSelectedText() { ! int x = getSelectedColumn(); ! int y = getSelectedRow(); if(x==-1 || y ==-1) return ""; ! return getValueAt(y,x).toString(); } --- 86,94 ---- public String getSelectedText() { ! int x = table.getSelectedColumn(); ! int y = table.getSelectedRow(); if(x==-1 || y ==-1) return ""; ! return table.getValueAt(y,x).toString(); } |