Subversion Repositories svn.mios

Rev

Rev 213 | 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.sidlibr.gui;
22
 
23
import javax.swing.table.AbstractTableModel;
24
 
628 adamjking 25
import org.midibox.sidlibr.Bank;
26
 
27
public class EnsBankTableModel extends AbstractTableModel {
28
    private String[] columnNames = { "#", "Patch Name", "Engine" };
213 tk 29
    private Object[][] data;
628 adamjking 30
 
31
    public EnsBankTableModel(Bank b) {
213 tk 32
        data = new Object[b.bankSize][3];
33
        for (int c = 0; c < b.bankSize; c++) {
628 adamjking 34
            data[c][0] = intToStr3(c + 1);
213 tk 35
            data[c][1] = b.getPatchAt(c).getPatchName();
36
            data[c][2] = b.getPatchAt(c).getEngineStr();
628 adamjking 37
        }
213 tk 38
    }
39
 
628 adamjking 40
    public int getColumnCount() {
41
        return columnNames.length;
42
    }
213 tk 43
 
628 adamjking 44
    public int getRowCount() {
45
        return data.length;
46
    }
213 tk 47
 
628 adamjking 48
    public String getColumnName(int col) {
49
        return columnNames[col];
50
    }
213 tk 51
 
628 adamjking 52
    public Object getValueAt(int row, int col) {
53
        return data[row][col];
54
    }
55
 
56
    public boolean isCellEditable(int row, int col) {
57
        if (col == 1) {
58
            return true;
59
        } else {
60
            return false;
61
        }
62
    }
63
 
64
    public void setValueAt(Object value, int row, int col) {
65
        data[row][col] = value;
66
        fireTableCellUpdated(row, col);
67
    }
68
 
69
    private String intToStr3(int i) {
70
        String s = Integer.toString(i);
71
        switch (s.length()) {
72
        case 1:
73
            s = "00" + s;
74
            break;
75
        case 2:
76
            s = "0" + s;
77
            break;
78
        }
79
        return s;
80
    }
213 tk 81
}