1 |
iliev |
787 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005 Grigor Kirilov Iliev |
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 |
|
|
|
23 |
|
|
package org.jsampler.view; |
24 |
|
|
|
25 |
|
|
import javax.swing.DefaultCellEditor; |
26 |
|
|
import javax.swing.JComponent; |
27 |
|
|
import javax.swing.JComboBox; |
28 |
|
|
import javax.swing.JTable; |
29 |
|
|
import javax.swing.table.TableCellEditor; |
30 |
|
|
import javax.swing.table.TableCellRenderer; |
31 |
|
|
import javax.swing.table.TableModel; |
32 |
|
|
|
33 |
|
|
import org.linuxsampler.lscp.Parameter; |
34 |
|
|
import org.linuxsampler.lscp.ParameterType; |
35 |
|
|
|
36 |
|
|
|
37 |
|
|
/** |
38 |
iliev |
911 |
* A table for representing LSCP parameters. |
39 |
iliev |
787 |
* @author Grigor Iliev |
40 |
|
|
*/ |
41 |
|
|
public class ParameterTable extends JTable { |
42 |
|
|
|
43 |
iliev |
911 |
/** Creates a new instance of <code>ParameterTable</code>. */ |
44 |
|
|
public |
45 |
|
|
ParameterTable() { super(new ParameterTableModel(new Parameter[0])); } |
46 |
iliev |
787 |
|
47 |
|
|
/** |
48 |
|
|
* Gets the <code>ParameterTableModel</code> that |
49 |
|
|
* provides the data displayed by this <code>ParameterTable</code>. |
50 |
|
|
* @return The <code>ParameterTableModel</code> that |
51 |
|
|
* provides the data displayed by this <code>ParameterTable</code>. |
52 |
|
|
*/ |
53 |
|
|
public ParameterTableModel |
54 |
|
|
getModel() { return (ParameterTableModel) super.getModel(); } |
55 |
|
|
|
56 |
|
|
/** |
57 |
|
|
* Sets the data model for this table to <code>dataModel</code>. |
58 |
|
|
* @param dataModel The new data source for this table. |
59 |
|
|
*/ |
60 |
|
|
public void |
61 |
|
|
setModel(ParameterTableModel dataModel) { super.setModel(dataModel); } |
62 |
|
|
|
63 |
|
|
public TableCellEditor |
64 |
|
|
getCellEditor(int row, int column) { |
65 |
|
|
TableCellEditor editor = getModel().getCellEditor(row, column); |
66 |
|
|
return editor != null ? editor : super.getCellEditor(row, column); |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
public TableCellRenderer |
70 |
|
|
getCellRenderer(int row, int column) { |
71 |
|
|
TableCellRenderer r = getModel().getCellRenderer(row, column); |
72 |
|
|
//return r != null ? r : super.getCellRenderer(row, column); |
73 |
|
|
if(r == null) { |
74 |
|
|
r = super.getCellRenderer(row, column); |
75 |
|
|
((JComponent)r).setToolTipText(getModel().getParameter(row).getDescription()); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
return r; |
79 |
|
|
} |
80 |
|
|
} |