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

Annotation of /jsampler/trunk/src/org/jsampler/view/ServerTableModel.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1688 - (hide annotations) (download)
Thu Feb 14 16:52:36 2008 UTC (16 years, 3 months ago) by iliev
File size: 3475 byte(s)
* Implemented a backend list with option to manually choose a backend
  to connect on startup(Edit/Preferences, then click the `Backend' tab)
  and option to change the backend without restarting JSampler
  (Actions/Change Backend or Ctrl + B)

* Added confirmation messages for removing sampler channels and
  audio/MIDI devices (Edit/Preferences, then click the `View' tab)

1 iliev 1688 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4     * Copyright (C) 2005-2008 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    
23     package org.jsampler.view;
24    
25     import javax.swing.event.ChangeEvent;
26     import javax.swing.event.ChangeListener;
27    
28     import javax.swing.table.AbstractTableModel;
29    
30     import org.jsampler.Server;
31     import org.jsampler.ServerList;
32    
33     /**
34     *
35     * @author Grigor Iliev
36     */
37     public class ServerTableModel extends AbstractTableModel {
38     private ServerList serverList;
39    
40     /**
41     * Creates a new instance of <code>ServerTableModel</code>.
42     * @param serverList The server list,
43     * which this table model should represent.
44     * @throws IllegalArgumentException If <code>serverList</code> is <code>null</code>.
45     */
46     public
47     ServerTableModel(ServerList serverList) {
48     setServerList(serverList);
49     }
50    
51     /**
52     * Gets the server list, represented by this table model.
53     */
54     public ServerList
55     getServerList() { return serverList; }
56    
57     /**
58     * Sets the server list, represented by this table model.
59     * @param serverList The new server list,
60     * represented by this table model.
61     * @throws IllegalArgumentException If <code>serverList</code> is <code>null</code>.
62     */
63     public void
64     setServerList(ServerList serverList) {
65     if(serverList == null)
66     throw new IllegalArgumentException("serverList should be non-null!");
67    
68     if(getServerList() != null)
69     getServerList().removeChangeListener(getHandler());
70    
71     this.serverList = serverList;
72     serverList.addChangeListener(getHandler());
73    
74     fireTableStructureChanged();
75     fireTableDataChanged();
76     }
77    
78     /**
79     * Gets the number of columns in the model.
80     * @return The number of columns in the model.
81     */
82     public int
83     getColumnCount() { return 1; }
84    
85     /**
86     * Gets the name of the column at <code>columnIndex</code>.
87     * @return The name of the column at <code>columnIndex</code>.
88     */
89     public String
90     getColumnName(int col) { return " "; }
91    
92     /**
93     * Gets the number of rows in the model.
94     * @return The number of rows in the model.
95     */
96     public int
97     getRowCount() { return serverList.getServerCount(); }
98    
99     /**
100     * Gets the value for the cell at <code>columnIndex</code> and
101     * <code>rowIndex</code>.
102     * @param row The row whose value is to be queried.
103     * @param col The column whose value is to be queried.
104     * @return The value for the cell at <code>columnIndex</code> and
105     * <code>rowIndex</code>.
106     */
107     public Object
108     getValueAt(int row, int col) {
109     return serverList.getServer(row);
110     }
111    
112     public Server
113     getServerAt(int index) { return serverList.getServer(index); }
114    
115     private final Handler eventHandler = new Handler();
116    
117     private Handler
118     getHandler() { return eventHandler; }
119    
120     private class Handler implements ChangeListener {
121     public void
122     stateChanged(ChangeEvent e) {
123     fireTableDataChanged();
124     }
125     }
126     }

  ViewVC Help
Powered by ViewVC