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.JPanel; |
26 |
|
|
import javax.swing.event.ListSelectionListener; |
27 |
|
|
|
28 |
|
|
import org.jsampler.SamplerChannelModel; |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
/** |
32 |
iliev |
911 |
* This class defines the skeleton of a pane containg sampler channels. |
33 |
iliev |
787 |
* @author Grigor Iliev |
34 |
|
|
*/ |
35 |
|
|
public abstract class JSChannelsPane extends JPanel { |
36 |
iliev |
911 |
/** The key used for reporting title's property change. */ |
37 |
iliev |
787 |
public final static String TITLE = "ChannelsPaneTitle"; |
38 |
|
|
|
39 |
|
|
private String title; |
40 |
|
|
|
41 |
iliev |
911 |
/** Creates a new instance of <code>JSChannelsPane</code>. */ |
42 |
iliev |
787 |
public |
43 |
|
|
JSChannelsPane(String title) { this.title = title; } |
44 |
|
|
|
45 |
iliev |
911 |
/** |
46 |
|
|
* Returns the title of this <code>JSChannelsPane</code>. |
47 |
|
|
* @return The title of this <code>JSChannelsPane</code>. |
48 |
|
|
*/ |
49 |
iliev |
787 |
public String |
50 |
|
|
getTitle() { return title; } |
51 |
|
|
|
52 |
iliev |
911 |
/** |
53 |
|
|
* Sets the title of this <code>JSChannelsPane</code>. |
54 |
|
|
* @param title The new title of this <code>JSChannelsPane</code>. |
55 |
|
|
*/ |
56 |
iliev |
787 |
public void |
57 |
|
|
setTitle(String title) { |
58 |
|
|
if(this.title.equals(title)) return; |
59 |
|
|
|
60 |
|
|
String oldTitle = this.title; |
61 |
|
|
this.title = title; |
62 |
|
|
firePropertyChange(TITLE, oldTitle, title); |
63 |
|
|
} |
64 |
|
|
|
65 |
iliev |
911 |
/** |
66 |
|
|
* Returns the title of this <code>JSChannelsPane</code>. |
67 |
|
|
* @return The title of this <code>JSChannelsPane</code>. |
68 |
|
|
*/ |
69 |
iliev |
787 |
public String |
70 |
|
|
toString() { return getTitle(); } |
71 |
|
|
|
72 |
|
|
/** |
73 |
|
|
* Adds new channel to this channels pane. |
74 |
|
|
* @param channelModel The sampler channel model to be used by the new channel. |
75 |
|
|
*/ |
76 |
|
|
public abstract void addChannel(SamplerChannelModel channelModel); |
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* Adds the specified channels to this channels pane. |
80 |
|
|
* @param chns The channels to be added. |
81 |
|
|
*/ |
82 |
|
|
public abstract void addChannels(JSChannel[] chns); |
83 |
|
|
|
84 |
|
|
/** |
85 |
|
|
* Removes the specified channel from this channels pane. |
86 |
|
|
* This method is invoked when a sampler channel is removed in the back-end. |
87 |
|
|
* @param chn The channel to be removed from this channels pane. |
88 |
|
|
*/ |
89 |
|
|
public abstract void removeChannel(JSChannel chn); |
90 |
|
|
|
91 |
|
|
/** |
92 |
|
|
* Determines whether there is at least one selected channel. |
93 |
|
|
* @return <code>true</code> if there is at least one selected channel, |
94 |
|
|
* <code>false</code> otherwise. |
95 |
|
|
*/ |
96 |
|
|
public abstract boolean hasSelectedChannel(); |
97 |
|
|
|
98 |
|
|
/** |
99 |
|
|
* Gets the first channel in this channels pane. |
100 |
|
|
* @return The first channel in this channels pane or <code>null</code> if |
101 |
|
|
* the channels pane is empty. |
102 |
|
|
*/ |
103 |
|
|
public abstract JSChannel getFirstChannel(); |
104 |
|
|
|
105 |
|
|
/** |
106 |
|
|
* Gets the last channel in this channels pane. |
107 |
|
|
* @return The last channel in this channels pane or <code>null</code> if |
108 |
|
|
* the channels pane is empty. |
109 |
|
|
*/ |
110 |
|
|
public abstract JSChannel getLastChannel(); |
111 |
|
|
|
112 |
|
|
/** |
113 |
|
|
* Gets the channel at the specified index. |
114 |
|
|
* @return The channel at the specified index. |
115 |
|
|
* @throws ArrayIndexOutOfBoundsException If the index is out of range. |
116 |
|
|
*/ |
117 |
|
|
public abstract JSChannel getChannel(int idx); |
118 |
|
|
|
119 |
|
|
/** |
120 |
|
|
* Gets an array of all channels in this channels pane. |
121 |
|
|
* @return An array of all channels in this channels pane. |
122 |
|
|
*/ |
123 |
|
|
public abstract JSChannel[] getChannels(); |
124 |
|
|
|
125 |
|
|
/** |
126 |
|
|
* Gets the number of channels in this channels pane. |
127 |
|
|
* @return The number of channels in this channels pane. |
128 |
|
|
*/ |
129 |
|
|
public abstract int getChannelCount(); |
130 |
|
|
|
131 |
|
|
/** |
132 |
|
|
* Gets an array of all selected channels. |
133 |
|
|
* The channels are sorted in increasing index order. |
134 |
|
|
* @return The selected channels or an empty array if nothing is selected. |
135 |
|
|
*/ |
136 |
|
|
public abstract JSChannel[] getSelectedChannels(); |
137 |
|
|
|
138 |
|
|
/** |
139 |
|
|
* Gets the number of the selected channels. |
140 |
|
|
* @return The number of the selected channels. |
141 |
|
|
*/ |
142 |
|
|
public abstract int getSelectedChannelCount(); |
143 |
|
|
|
144 |
|
|
/** |
145 |
|
|
* Removes all selected channels in this channels pane. |
146 |
|
|
* Notice that this method does not remove any channels in the back-end. |
147 |
|
|
* It is invoked after the channels are already removed in the back-end. |
148 |
|
|
* @return The number of removed channels. |
149 |
|
|
*/ |
150 |
|
|
public abstract int removeSelectedChannels(); |
151 |
|
|
|
152 |
iliev |
911 |
/** |
153 |
|
|
* Registers the specified listener for receiving list selection events. |
154 |
|
|
* @param listener The <code>ListSelectionListener</code> to register. |
155 |
|
|
*/ |
156 |
iliev |
787 |
public abstract void addListSelectionListener(ListSelectionListener listener); |
157 |
iliev |
911 |
|
158 |
|
|
/** |
159 |
|
|
* Removes the specified listener. |
160 |
|
|
* @param listener The <code>ListSelectionListener</code> to remove. |
161 |
|
|
*/ |
162 |
iliev |
787 |
public abstract void removeListSelectionListener(ListSelectionListener listener); |
163 |
|
|
} |