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

Contents of /jsampler/trunk/src/org/jsampler/android/view/classic/ChannelsPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2302 - (show annotations) (download)
Thu Dec 15 23:13:30 2011 UTC (12 years, 4 months ago) by iliev
File size: 5947 byte(s)
* Initial support for Android platforms (only sampler channel
  manipulation for now - see the screenshots on the website)

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
23 package org.jsampler.android.view.classic;
24
25 import org.jsampler.SamplerChannelModel;
26 import org.jsampler.android.AHF;
27 import org.jsampler.android.R;
28 import org.jsampler.android.view.AndroidChannelsPane;
29 import org.jsampler.android.view.SamplerChannelListAdapter;
30 import org.jsampler.event.ListSelectionListener;
31
32 import android.content.Context;
33 import android.content.Intent;
34 import android.view.LayoutInflater;
35 import android.view.View;
36 import android.widget.AdapterView;
37 import android.widget.ListView;
38 import android.widget.TextView;
39
40 public class ChannelsPane extends AndroidChannelsPane<Channel> {
41 public
42 ChannelsPane() { this("Untitled"); }
43
44 public
45 ChannelsPane(String title) { super(title); }
46
47 public View
48 createView() {
49 LayoutInflater inflater =
50 (LayoutInflater)AHF.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
51 View v = inflater.inflate(R.layout.sampler_channel_lane, null);
52
53 TextView tv = (TextView)v.findViewById(R.id.sampler_channel_lane_title);
54 tv.setText(getTitle());
55
56 ListView lv = (ListView)v.findViewById(R.id.sampler_channel_lane_list);
57 SamplerChannelListAdapter model = new SamplerChannelListAdapter(this);
58 lv.setAdapter(model);
59
60 lv.setOnItemClickListener(new ListView.OnItemClickListener() {
61 @Override
62 public void
63 onItemClick(AdapterView<?> parent, View view, int position, long id) {
64 Intent i = new Intent(AHF.getActivity(), ChannelPagerActivity.class);
65 i.putExtra("org.jsampler.android.SelectedChannelID", position);
66 AHF.getActivity().startActivity(i);
67 }
68 });
69
70 return v;
71 }
72
73 /**
74 * Adds new channel to this channels pane.
75 * @param channelModel The sampler channel model to be used by the new channel.
76 */
77 @Override
78 public void
79 addChannel(SamplerChannelModel channelModel) {
80 Channel chn = new Channel(channelModel);
81 channels.add(chn);
82 firePropertyChange("channelAdded", null, channelModel);
83 }
84
85 /**
86 * Determines whether there is at least one selected channel.
87 * @return <code>true</code> if there is at least one selected channel,
88 * <code>false</code> otherwise.
89 */
90 @Override
91 public boolean
92 hasSelectedChannel() {
93 return false;
94 }
95
96 /**
97 * Gets an array of all channels in this channels pane.
98 * @return An array of all channels in this channels pane.
99 */
100 @Override
101 public Channel[] getChannels() {
102 Channel[] chns = new Channel[channels.size()];
103 for(int i = 0; i < channels.size(); i++) chns[i] = channels.get(i);
104 return chns;
105 }
106
107 /**
108 * Gets an array of all selected channels.
109 * The channels are sorted in increasing index order.
110 * @return The selected channels or an empty array if nothing is selected.
111 */
112 @Override
113 public Channel[]
114 getSelectedChannels() { return new Channel[0]; }
115
116 /**
117 * Gets the number of the selected channels.
118 * @return The number of the selected channels.
119 */
120 @Override
121 public int
122 getSelectedChannelCount() { return 0; }
123
124 /**
125 * Selects the specified channel.
126 */
127 @Override
128 public void
129 setSelectedChannel(Channel channel) { }
130
131 /** Selects all channels. */
132 @Override
133 public void selectAll() { }
134
135 /** Deselects all selected channels. */
136 @Override
137 public void clearSelection() { }
138
139 /**
140 * Removes all selected channels in this channels pane.
141 * Notice that this method does not remove any channels in the back-end.
142 * It is invoked after the channels are already removed in the back-end.
143 * @return The number of removed channels.
144 */
145 @Override
146 public int removeSelectedChannels() { return 0; }
147
148 @Override
149 public void moveSelectedChannelsOnTop() { }
150
151 @Override
152 public void moveSelectedChannelsUp() { }
153
154 @Override
155 public void moveSelectedChannelsDown() { }
156
157 @Override
158 public void moveSelectedChannelsAtBottom() { }
159
160 /**
161 * Registers the specified listener for receiving list selection events.
162 * @param listener The <code>ListSelectionListener</code> to register.
163 */
164 @Override
165 public void addListSelectionListener(ListSelectionListener listener) { }
166
167 /**
168 * Removes the specified listener.
169 * @param listener The <code>ListSelectionListener</code> to remove.
170 */
171 @Override
172 public void removeListSelectionListener(ListSelectionListener listener) { }
173
174 /**
175 * Process a selection event.
176 * @param c The newly selected channel.
177 * @param controlDown Specifies whether the control key is held down during selection.
178 * @param shiftDown Specifies whether the shift key is held down during selection.
179 */
180 @Override
181 public void processChannelSelection(Channel c, boolean controlDown, boolean shiftDown) { }
182
183 /**
184 * Determines whether the channel list UI should be automatically updated
185 * when channel is added/removed. The default value is <code>true</code>.
186 * @see updateChannelListUI
187 */
188 @Override
189 public boolean getAutoUpdate() { return true; }
190
191 /**
192 * Determines whether the channel list UI should be automatically updated
193 * when channel is added/removed.
194 * @see updateChannelListUI
195 */
196 @Override
197 public void setAutoUpdate(boolean b) { }
198
199 /**
200 * Updates the channel list UI.
201 * @see setAutoUpdate
202 */
203 @Override
204 public void updateChannelListUI() { }
205 }

  ViewVC Help
Powered by ViewVC