File: GLPjobTableModel.java

package info (click to toggle)
cupsys 1.2.7-4%2Betch9
  • links: PTS
  • area: main
  • in suites: etch
  • size: 20,436 kB
  • ctags: 10,404
  • sloc: ansic: 97,130; cpp: 49,167; java: 6,199; sh: 4,723; makefile: 1,918; lisp: 232; perl: 145; python: 119; php: 28
file content (104 lines) | stat: -rw-r--r-- 2,398 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

import javax.swing.table.*; 
import javax.swing.event.TableModelListener; 
import javax.swing.event.TableModelEvent; 
import com.easysw.cups.*;

public class GLPjobTableModel extends AbstractTableModel 
                      implements TableModelListener 
{
    protected TableModel model; 
    private final Object[][] rowData;
    private final String[]   colNames;
    private int rowCount = 0;
    private int colCount = 0;

    public GLPjobTableModel( int num_rows, int num_cols )
    {
       rowData  = new Object[num_rows][num_cols];
       colNames = new String[num_cols];
       rowCount = num_rows;
       colCount = num_cols;
    }

    public TableModel getModel() 
    {
        return model;
    }

    public void setModel(TableModel model) 
    {
        this.model = model; 
        model.addTableModelListener(this); 
    }

    // By default, implement TableModel by forwarding all messages 
    // to the model. 

    public Object getValueAt(int aRow, int aColumn) 
    {
        if (rowCount >= aRow && colCount >= aColumn)
          return (rowData[aRow][aColumn]); 
        else
          return(null);
    }
        
    public void setValueAt(Object aValue, int aRow, int aColumn) 
    {
        if (rowCount >= aRow && colCount >= aColumn)
          rowData[aRow][aColumn] = aValue;
    }

    public int getRowCount() 
    {
        return (rowCount);
    }

    public int getColumnCount() 
    {
        return (colCount);
    }
        
    public void setColumnName(int aColumn, String aName) 
    {
        if (colCount >= aColumn)
        {
          colNames[aColumn] = aName;
        }
    }
        
    public String getColumnName(int aColumn) 
    {
        if (colCount >= aColumn)
          return (colNames[aColumn]); 
        else
          return("");
    }

    public Class getColumnClass(int aColumn) 
    {
        if (colCount >= aColumn)
        {
         if (rowData[0][aColumn] != null)
           return (rowData[0][aColumn].getClass()); 
         else
           return( null );
        }
        else return(null);
    }
        
    public boolean isCellEditable(int row, int column) 
    {
         return(false); 
    }


//
// Implementation of the TableModelListener interface, 
//
    // By default forward all events to all the listeners. 
    public void tableChanged(TableModelEvent e) 
    {
        fireTableChanged(e);
    }
}