/plugins/LaTeXTools/tags/plugin_release_0-5/latextools/uk/co/antroy/latextools/parsers/LabelTableModel.java

# · Java · 92 lines · 43 code · 28 blank · 21 comment · 1 complexity · 902410348dacec6a49d799ad79b2d42a MD5 · raw file

  1. /*:folding=indent:
  2. * LabelTableModel.java - Label Table View Model
  3. * Copyright (C) 2002 Anthony Roy
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package uk.co.antroy.latextools.parsers;
  20. import java.util.List;
  21. import javax.swing.table.AbstractTableModel;
  22. public class LabelTableModel
  23. extends AbstractTableModel {
  24. //~ Instance/static variables .............................................
  25. private List rows;
  26. private String[] columnNames = { "Reference", "Section", "File" };
  27. //~ Constructors ..........................................................
  28. public LabelTableModel(List rows) {
  29. this.rows = rows;
  30. }
  31. //~ Methods ...............................................................
  32. public int getColumnCount() {
  33. return columnNames.length;
  34. }
  35. public String getColumnName(int column) {
  36. return column < getColumnCount() ? columnNames[column] : null;
  37. }
  38. public int getRowCount() {
  39. return rows.size();
  40. }
  41. public LaTeXAsset getRowEntry(int row) {
  42. return (LaTeXAsset)rows.get(row);
  43. }
  44. public Object getValueAt(int row, int column) {
  45. Object out = null;
  46. LaTeXAsset be = (LaTeXAsset)rows.get(row);
  47. switch (column) {
  48. case 0:
  49. out = be.getShortString();
  50. break;
  51. case 1:
  52. out = be.getSection();
  53. break;
  54. case 2:
  55. out = be.getFile().getName();
  56. break;
  57. default:
  58. System.err.println(
  59. "LabelTableModel.getValueAt(): Column " +
  60. column + " does not exist!");
  61. }
  62. return out;
  63. }
  64. }