Subversion Repositories svn.mios

Rev

Rev 246 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidedit.gui;
22
 
23
import javax.swing.table.AbstractTableModel;
24
 
628 adamjking 25
public class WTTableModel extends AbstractTableModel {
26
    private String[] columnNames = { "Pos", "Value", "Control" };
213 tk 27
    private Object[][] data;
28
    private int wtSteps = 128;
29
    private int wtNumber;
628 adamjking 30
 
31
    public WTTableModel(int wtNumber) {
213 tk 32
        this.wtNumber = wtNumber;
628 adamjking 33
 
34
        data = new Object[wtSteps][wtNumber + 2];
213 tk 35
        for (int c = 0; c < wtSteps; c++) {
628 adamjking 36
            data[c][0] = Integer.toString(c);
37
            data[c][wtNumber + 1] = Integer.toString(0);
38
        }
213 tk 39
    }
40
 
628 adamjking 41
    public int getColumnCount() {
42
        return wtNumber + 2;
43
    }
213 tk 44
 
628 adamjking 45
    public int getRowCount() {
46
        return data.length;
47
    }
213 tk 48
 
628 adamjking 49
    public String getColumnName(int col) {
50
        if (col == 0) {
51
            return columnNames[0];
52
        } else if (col <= wtNumber) {
53
            return Integer.toString(col);
54
        } else if (col > wtNumber) {
55
            return columnNames[col - wtNumber];
56
        } else {
57
            return "Unknown";
58
        }
59
    }
213 tk 60
 
628 adamjking 61
    public Object getValueAt(int row, int col) {
62
        return data[row][col];
63
    }
64
 
65
    public boolean isCellEditable(int row, int col) {
66
        if (col == wtNumber + 1) {
67
            return true;
68
        } else {
69
            return false;
70
        }
71
    }
72
 
73
    public void setValueAt(Object value, int row, int col) {
74
        data[row][col] = value;
75
        fireTableCellUpdated(row, col);
76
    }
213 tk 77
}