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

Diff of /jsampler/trunk/src/org/jsampler/view/classic/ChannelsPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2287 by iliev, Sun Jul 3 22:01:16 2011 UTC revision 2288 by iliev, Wed Nov 23 21:19:44 2011 UTC
# Line 41  import javax.swing.ListSelectionModel; Line 41  import javax.swing.ListSelectionModel;
41  import javax.swing.event.ListSelectionEvent;  import javax.swing.event.ListSelectionEvent;
42  import javax.swing.event.ListSelectionListener;  import javax.swing.event.ListSelectionListener;
43    
44  import net.sf.juife.ComponentList;  import net.sf.juife.swing.ComponentList;
45  import net.sf.juife.ComponentListModel;  import net.sf.juife.swing.ComponentListModel;
46  import net.sf.juife.DefaultComponentListModel;  import net.sf.juife.swing.DefaultComponentListModel;
47    
48  import org.jsampler.CC;  import org.jsampler.CC;
49  import org.jsampler.SamplerChannelModel;  import org.jsampler.SamplerChannelModel;
50    
 import org.jsampler.view.JSChannel;  
51  import org.jsampler.view.JSChannelsPane;  import org.jsampler.view.JSChannelsPane;
52    import org.jsampler.view.swing.SHF;
53    import org.jsampler.view.swing.SwingChannelsPane;
54    
55  import static org.jsampler.view.classic.A4n.a4n;  import static org.jsampler.view.classic.A4n.a4n;
56  import static org.jsampler.view.classic.ClassicI18n.i18n;  import static org.jsampler.view.classic.ClassicI18n.i18n;
# Line 59  import static org.jsampler.view.classic. Line 60  import static org.jsampler.view.classic.
60   *   *
61   * @author Grigor Iliev   * @author Grigor Iliev
62   */   */
63  public class ChannelsPane extends JSChannelsPane implements ListSelectionListener {  public class ChannelsPane extends SwingChannelsPane<Channel> implements ListSelectionListener {
64          private final ComponentList chnList = new ComponentList();          private final ComponentList chnList = new ComponentList();
65          private final DefaultComponentListModel listModel = new DefaultComponentListModel();          private final DefaultComponentListModel listModel = new DefaultComponentListModel();
66                    
# Line 94  public class ChannelsPane extends JSChan Line 95  public class ChannelsPane extends JSChan
95                    
96          @Override          @Override
97          public void          public void
98          setSelectedChannel(JSChannel channel) {          setSelectedChannel(Channel channel) {
99                  chnList.setSelectedComponent(channel, true);                  chnList.setSelectedComponent(channel, true);
100          }          }
101                    
# Line 120  public class ChannelsPane extends JSChan Line 121  public class ChannelsPane extends JSChan
121           */           */
122          @Override          @Override
123          public void          public void
124          addChannels(JSChannel[] chns) {          addChannels(Channel[] chns) {
125                  if(chns == null || chns.length == 0) return;                  if(chns == null || chns.length == 0) return;
126                                    
127                  for(JSChannel c : chns) listModel.add(c);                  for(Channel c : chns) listModel.add(c);
128                  chnList.setSelectionInterval (                  chnList.setSelectionInterval (
129                          listModel.getSize() - chns.length, listModel.getSize() - 1                          listModel.getSize() - chns.length, listModel.getSize() - 1
130                  );                  );
# Line 140  public class ChannelsPane extends JSChan Line 141  public class ChannelsPane extends JSChan
141           */           */
142          @Override          @Override
143          public void          public void
144          removeChannel(JSChannel chn) {          removeChannel(Channel chn) {
145                  listModel.remove(chn);                  listModel.remove(chn);
146                                    
147                  firePropertyChange("channelRemoved", null, chn);                  firePropertyChange("channelRemoved", null, chn);
# Line 152  public class ChannelsPane extends JSChan Line 153  public class ChannelsPane extends JSChan
153           * the channels pane is empty.           * the channels pane is empty.
154           */           */
155          @Override          @Override
156          public JSChannel          public Channel
157          getFirstChannel() { return listModel.size() == 0 ? null : (JSChannel)listModel.get(0); }          getFirstChannel() { return listModel.size() == 0 ? null : (Channel)listModel.get(0); }
158                    
159          /**          /**
160           * Gets the last channel in this channels pane.           * Gets the last channel in this channels pane.
# Line 161  public class ChannelsPane extends JSChan Line 162  public class ChannelsPane extends JSChan
162           * the channels pane is empty.           * the channels pane is empty.
163           */           */
164          @Override          @Override
165          public JSChannel          public Channel
166          getLastChannel() {          getLastChannel() {
167                  return listModel.size() == 0 ? null : (JSChannel)listModel.get(listModel.size()-1);                  return listModel.size() == 0 ? null : (Channel)listModel.get(listModel.size()-1);
168          }          }
169                    
170          /**          /**
# Line 172  public class ChannelsPane extends JSChan Line 173  public class ChannelsPane extends JSChan
173           * @throws ArrayIndexOutOfBoundsException If the index is out of range.           * @throws ArrayIndexOutOfBoundsException If the index is out of range.
174           */           */
175          @Override          @Override
176          public JSChannel          public Channel
177          getChannel(int idx) { return (JSChannel)listModel.get(idx); }          getChannel(int idx) { return (Channel)listModel.get(idx); }
178                    
179          /**          /**
180           * Gets an array with all channels in this channels pane.           * Gets an array with all channels in this channels pane.
181           * @return An array with all channels in this channels pane.           * @return An array with all channels in this channels pane.
182           */           */
183          @Override          @Override
184          public JSChannel[]          public Channel[]
185          getChannels() {          getChannels() {
186                  JSChannel[] chns = new JSChannel[listModel.size()];                  Channel[] chns = new Channel[listModel.size()];
187                  for(int i = 0; i < listModel.size(); i++) chns[i] = (JSChannel)listModel.get(i);                  for(int i = 0; i < listModel.size(); i++) chns[i] = (Channel)listModel.get(i);
188                  return chns;                  return chns;
189          }          }
190                    
# Line 218  public class ChannelsPane extends JSChan Line 219  public class ChannelsPane extends JSChan
219           * @return The selected channels or an empty array if nothing is selected.           * @return The selected channels or an empty array if nothing is selected.
220           */           */
221          @Override          @Override
222          public JSChannel[]          public Channel[]
223          getSelectedChannels() {          getSelectedChannels() {
224                  Component[] cS = chnList.getSelectedComponents();                  Component[] cS = chnList.getSelectedComponents();
225                  JSChannel[] chns = new JSChannel[cS.length];                  Channel[] chns = new Channel[cS.length];
226                  for(int i = 0; i < cS.length; i++) chns[i] = (JSChannel)cS[i];                  for(int i = 0; i < cS.length; i++) chns[i] = (Channel)cS[i];
227                  return chns;                  return chns;
228          }          }
229                    
# Line 265  public class ChannelsPane extends JSChan Line 266  public class ChannelsPane extends JSChan
266           */           */
267          @Override          @Override
268          public void          public void
269          addListSelectionListener(ListSelectionListener listener) {          addListSelectionListener(org.jsampler.event.ListSelectionListener listener) {
270                  listenerList.add(ListSelectionListener.class, listener);                  listenerList.add(org.jsampler.event.ListSelectionListener.class, listener);
271          }          }
272                    
273          /**          /**
# Line 275  public class ChannelsPane extends JSChan Line 276  public class ChannelsPane extends JSChan
276           */           */
277          @Override          @Override
278          public void          public void
279          removeListSelectionListener(ListSelectionListener listener) {          removeListSelectionListener(org.jsampler.event.ListSelectionListener listener) {
280                  listenerList.remove(ListSelectionListener.class, listener);                  listenerList.remove(org.jsampler.event.ListSelectionListener.class, listener);
281          }          }
282                    
283          /**          /**
# Line 336  public class ChannelsPane extends JSChan Line 337  public class ChannelsPane extends JSChan
337          @Override          @Override
338          public void          public void
339          moveSelectedChannelsOnTop() {          moveSelectedChannelsOnTop() {
340                  JSChannel[] chns = getSelectedChannels();                  Channel[] chns = getSelectedChannels();
341                                                    
342                  if(chns.length == 0) {                  if(chns.length == 0) {
343                          CC.getLogger().info("Can't move channel(s) at the beginning");                          CC.getLogger().info("Can't move channel(s) at the beginning");
# Line 357  public class ChannelsPane extends JSChan Line 358  public class ChannelsPane extends JSChan
358          @Override          @Override
359          public void          public void
360          moveSelectedChannelsUp() {          moveSelectedChannelsUp() {
361                  JSChannel[] chns = getSelectedChannels();                  Channel[] chns = getSelectedChannels();
362                                                    
363                  if(chns.length == 0 || chns[0] == getFirstChannel()) {                  if(chns.length == 0 || chns[0] == getFirstChannel()) {
364                          CC.getLogger().info("Can't move channel(s) up");                          CC.getLogger().info("Can't move channel(s) up");
# Line 379  public class ChannelsPane extends JSChan Line 380  public class ChannelsPane extends JSChan
380          @Override          @Override
381          public void          public void
382          moveSelectedChannelsDown() {          moveSelectedChannelsDown() {
383                  JSChannel[] chns = getSelectedChannels();                  Channel[] chns = getSelectedChannels();
384                                                    
385                  if(chns.length == 0 || chns[chns.length - 1] == getLastChannel()) {                  if(chns.length == 0 || chns[chns.length - 1] == getLastChannel()) {
386                          CC.getLogger().info("Can't move channel(s) down");                          CC.getLogger().info("Can't move channel(s) down");
# Line 399  public class ChannelsPane extends JSChan Line 400  public class ChannelsPane extends JSChan
400          @Override          @Override
401          public void          public void
402          moveSelectedChannelsAtBottom() {          moveSelectedChannelsAtBottom() {
403                  JSChannel[] chns = getSelectedChannels();                  Channel[] chns = getSelectedChannels();
404                                                    
405                  if(chns.length == 0) {                  if(chns.length == 0) {
406                          CC.getLogger().info("Can't move channel(s) at the end");                          CC.getLogger().info("Can't move channel(s) at the end");
# Line 483  public class ChannelsPane extends JSChan Line 484  public class ChannelsPane extends JSChan
484                  private void                  private void
485                  updateMenu() {                  updateMenu() {
486                          submenu.removeAll();                          submenu.removeAll();
487                          Vector<JSChannelsPane> v = CC.getMainFrame().getChannelsPaneList();                          Vector<SwingChannelsPane> v = SHF.getMainFrame().getChannelsPaneList();
488                          for(JSChannelsPane p : v)                          for(SwingChannelsPane p : v)
489                                  if(p != CC.getMainFrame().getSelectedChannelsPane())                                  if(p != CC.getMainFrame().getSelectedChannelsPane())
490                                          submenu.add(new JMenuItem(new A4n.MoveChannelsTo(p)));                                          submenu.add(new JMenuItem(new A4n.MoveChannelsTo(p)));
491                  }                  }
# Line 492  public class ChannelsPane extends JSChan Line 493  public class ChannelsPane extends JSChan
493                    
494          @Override          @Override
495          public void          public void
496          processChannelSelection(JSChannel c, boolean controlDown, boolean shiftDown) {          processChannelSelection(Channel c, boolean controlDown, boolean shiftDown) {
497                                    
498          }          }
499  }  }

Legend:
Removed from v.2287  
changed lines
  Added in v.2288

  ViewVC Help
Powered by ViewVC