1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* JSampler is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with JSampler; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
package org.jsampler.view; |
23 |
|
24 |
import javax.swing.table.AbstractTableModel; |
25 |
import org.jsampler.CC; |
26 |
import org.jsampler.EffectList; |
27 |
import org.linuxsampler.lscp.Effect; |
28 |
|
29 |
import static org.jsampler.JSI18n.i18n; |
30 |
|
31 |
|
32 |
/** |
33 |
* |
34 |
* @author Grigor Iliev |
35 |
*/ |
36 |
public class EffectTableModel extends AbstractTableModel { |
37 |
public |
38 |
EffectTableModel() { |
39 |
|
40 |
} |
41 |
|
42 |
/** |
43 |
* Gets the number of columns in the model. |
44 |
* @return The number of columns in the model. |
45 |
*/ |
46 |
@Override |
47 |
public int |
48 |
getColumnCount() { return 4; } |
49 |
|
50 |
/** |
51 |
* Gets the number of rows in the model. |
52 |
* @return The number of rows in the model. |
53 |
*/ |
54 |
@Override |
55 |
public int |
56 |
getRowCount() { return CC.getSamplerModel().getEffects().getEffectCount(); } |
57 |
|
58 |
/** |
59 |
* Gets the value for the cell at <code>columnIndex</code> and |
60 |
* <code>rowIndex</code>. |
61 |
* @param row The row whose value is to be queried. |
62 |
* @param col The column whose value is to be queried. |
63 |
* @return The value for the cell at <code>columnIndex</code> and |
64 |
* <code>rowIndex</code>. |
65 |
*/ |
66 |
@Override |
67 |
public Object |
68 |
getValueAt(int row, int col) { |
69 |
EffectList effects = CC.getSamplerModel().getEffects(); |
70 |
switch(col) { |
71 |
case 0: return effects.getEffect(row).getDescription(); |
72 |
case 1: return effects.getEffect(row).getSystem(); |
73 |
case 2: return effects.getEffect(row).getModule(); |
74 |
case 3: return effects.getEffect(row).getName(); |
75 |
default: return effects.getEffect(row).getDescription(); |
76 |
} |
77 |
} |
78 |
|
79 |
/** |
80 |
* Gets the name of the column at <code>columnIndex</code>. |
81 |
* @return The name of the column at <code>columnIndex</code>. |
82 |
*/ |
83 |
@Override |
84 |
public String |
85 |
getColumnName(int col) { |
86 |
switch(col) { |
87 |
case 1: return i18n.getLabel("EffectTableModel.type"); |
88 |
case 2: return i18n.getLabel("EffectTableModel.file"); |
89 |
case 3: return i18n.getLabel("EffectTableModel.id"); |
90 |
default: return i18n.getLabel("EffectTableModel.effect"); |
91 |
} |
92 |
} |
93 |
/** |
94 |
* Determines whether the specified column is sortable. |
95 |
* @return <code>true</code> if the specified column is |
96 |
* sortable, <code>false</code> otherwise. |
97 |
*/ |
98 |
public boolean |
99 |
isSortable(int col) { return true; } |
100 |
|
101 |
public Effect |
102 |
getEffect(int row) { return CC.getSamplerModel().getEffects().getEffect(row); } |
103 |
} |