/[svn]/jsampler/trunk/src/org/jsampler/view/classic/ChannelOutputRoutingDlg.java
ViewVC logotype

Annotation of /jsampler/trunk/src/org/jsampler/view/classic/ChannelOutputRoutingDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 787 - (hide annotations) (download)
Mon Oct 10 16:03:12 2005 UTC (18 years, 6 months ago) by iliev
File size: 4162 byte(s)
* The first alpha-release of JSampler

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.classic;
24    
25     import java.awt.Dimension;
26     import java.awt.Frame;
27    
28     import javax.swing.DefaultCellEditor;
29     import javax.swing.JComboBox;
30     import javax.swing.JScrollPane;
31     import javax.swing.JTable;
32    
33     import javax.swing.table.AbstractTableModel;
34     import javax.swing.table.TableColumn;
35     import javax.swing.table.JTableHeader;
36    
37     import net.sf.juife.InformationDialog;
38     import net.sf.juife.JuifeUtils;
39    
40     import org.jsampler.CC;
41     import org.jsampler.task.SetChannelAudioOutputChannel;
42    
43     import org.linuxsampler.lscp.SamplerChannel;
44    
45     import static org.jsampler.view.classic.ClassicI18n.i18n;
46    
47    
48     /**
49     *
50     * @author Grigor Iliev
51     */
52     public class ChannelOutputRoutingDlg extends InformationDialog {
53     private final ChannelRoutingTable channelRoutingTable;
54     private SamplerChannel channel;
55    
56    
57     /** Creates a new instance of ChannelOutputRoutingDlg */
58     public
59     ChannelOutputRoutingDlg(Frame owner, SamplerChannel channel) {
60     super(owner, i18n.getLabel("ChannelOutputRoutingDlg.title"));
61     this.channel = channel;
62    
63     channelRoutingTable = new ChannelRoutingTable();
64     JScrollPane sp = new JScrollPane(channelRoutingTable);
65    
66     sp.setPreferredSize (
67     JuifeUtils.getUnionSize(sp.getMinimumSize(), new Dimension(200, 150))
68     );
69    
70     setMainPane(sp);
71    
72    
73     }
74    
75     class ChannelRoutingTable extends JTable {
76     private String[] columnToolTips = {
77     i18n.getLabel("ChannelOutputRoutingDlg.ttChannel", channel.getChannelID()),
78     i18n.getLabel("ChannelOutputRoutingDlg.ttDevice"),
79     };
80    
81     ChannelRoutingTable() {
82     super(new ChannelRoutingTableModel());
83    
84     JComboBox cb = new JComboBox();
85     for(Integer i = 0; i < channel.getAudioOutputChannels(); i++) {
86     cb.addItem(i);
87     }
88    
89     TableColumn column = getColumnModel().getColumn(1);
90     column.setCellEditor(new DefaultCellEditor(cb));
91     }
92    
93     protected JTableHeader
94     createDefaultTableHeader() {
95     return new JTableHeader(columnModel) {
96     public String getToolTipText(java.awt.event.MouseEvent e) {
97     java.awt.Point p = e.getPoint();
98     int i = columnModel.getColumnIndexAtX(p.x);
99     i = columnModel.getColumn(i).getModelIndex();
100     return columnToolTips[i];
101     }
102     };
103     }
104     }
105    
106     class ChannelRoutingTableModel extends AbstractTableModel {
107     private String[] columnNames = {
108     i18n.getLabel("ChannelOutputRoutingDlg.audioOut"),
109     i18n.getLabel("ChannelOutputRoutingDlg.audioIn")
110     };
111    
112     ChannelRoutingTableModel() {
113    
114     }
115    
116     public int
117     getColumnCount() { return columnNames.length; }
118    
119     public String
120     getColumnName(int column) { return columnNames[column]; }
121    
122     public int
123     getRowCount() { return channel.getAudioOutputChannels(); }
124    
125     public Object
126     getValueAt(int row, int column) {
127     switch(column) {
128     case 0:
129     return row;
130     case 1:
131     return channel.getAudioOutputRouting()[row];
132     default: return null;
133     }
134    
135     }
136    
137     public boolean
138     isCellEditable(int row, int column) {
139     switch(column) {
140     case 0:
141     return false;
142     case 1:
143     return true;
144     default: return false;
145     }
146     }
147    
148     public void
149     setValueAt(Object value, int row, int column) {
150     if(column == 0) return;
151     int c = channel.getChannelID();
152     int o = (Integer)getValueAt(row, 0);
153     int i = (Integer)value;
154     CC.getTaskQueue().add(new SetChannelAudioOutputChannel(c, o, i));
155     channel.getAudioOutputRouting()[row] = i;
156    
157     fireTableCellUpdated(row, column);
158     }
159     }
160     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC