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

Contents of /jsampler/trunk/src/org/jsampler/view/std/StdMainFrame.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 3 months ago) by iliev
File size: 3866 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

1 /*
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.std;
24
25 import javax.swing.Action;
26
27 import javax.swing.event.ListSelectionEvent;
28 import javax.swing.event.ListSelectionListener;
29
30 import org.jsampler.view.JSChannel;
31 import org.jsampler.view.JSChannelsPane;
32 import org.jsampler.view.JSMainFrame;
33
34 import static org.jsampler.view.std.StdI18n.i18n;
35
36 /**
37 *
38 * @author Grigor Iliev
39 */
40 public abstract class StdMainFrame extends JSMainFrame implements ListSelectionListener {
41 public
42 StdMainFrame() {
43 addChannelsPaneSelectionListener(this);
44 }
45
46 @Override
47 public void
48 addChannelsPane(JSChannelsPane chnPane) {
49 super.addChannelsPane(chnPane);
50 chnPane.addListSelectionListener(this);
51 }
52
53 @Override
54 public boolean
55 removeChannelsPane(JSChannelsPane chnPane) {
56 chnPane.removeListSelectionListener(this);
57 return super.removeChannelsPane(chnPane);
58 }
59
60 @Override
61 public void
62 valueChanged(ListSelectionEvent e) {
63 if(e.getValueIsAdjusting()) return;
64
65 checkChannelSelection(getSelectedChannelsPane());
66 }
67
68 public StdA4n
69 getA4n() { return StdA4n.a4n; }
70
71 private void
72 checkChannelSelection(JSChannelsPane pane) {
73 if(!pane.hasSelectedChannel()) {
74 getA4n().duplicateChannels.putValue (
75 Action.NAME, i18n.getMenuLabel("channels.duplicate")
76 );
77 getA4n().duplicateChannels.setEnabled(false);
78
79 getA4n().removeChannels.putValue (
80 Action.NAME, i18n.getMenuLabel("channels.removeChannel")
81 );
82 getA4n().removeChannels.setEnabled(false);
83
84 getA4n().moveChannelsOnTop.setEnabled(false);
85 getA4n().moveChannelsUp.setEnabled(false);
86 getA4n().moveChannelsDown.setEnabled(false);
87 getA4n().moveChannelsAtBottom.setEnabled(false);
88
89 return;
90 }
91
92 getA4n().duplicateChannels.setEnabled(true);
93 getA4n().removeChannels.setEnabled(true);
94
95 if(pane.getSelectedChannelCount() > 1) {
96 getA4n().duplicateChannels.putValue (
97 Action.NAME, i18n.getMenuLabel("channels.duplicateChannels")
98 );
99 getA4n().removeChannels.putValue (
100 Action.NAME, i18n.getMenuLabel("channels.removeChannels")
101 );
102 } else {
103 getA4n().duplicateChannels.putValue (
104 Action.NAME, i18n.getMenuLabel("channels.duplicate")
105 );
106 getA4n().removeChannels.putValue (
107 Action.NAME, i18n.getMenuLabel("channels.removeChannel")
108 );
109 }
110
111 getA4n().moveChannelsOnTop.setEnabled(false);
112 getA4n().moveChannelsUp.setEnabled(true);
113 getA4n().moveChannelsDown.setEnabled(true);
114 getA4n().moveChannelsAtBottom.setEnabled(false);
115
116 JSChannel[] chns = pane.getSelectedChannels();
117
118 for(int i = 0; i < chns.length; i++) {
119 if(pane.getChannel(i) != chns[i]) {
120 getA4n().moveChannelsOnTop.setEnabled(true);
121 break;
122 }
123 }
124
125 if(chns[0] == pane.getFirstChannel()) getA4n().moveChannelsUp.setEnabled(false);
126
127 if(chns[chns.length - 1] == pane.getLastChannel())
128 getA4n().moveChannelsDown.setEnabled(false);
129
130 for(int i = chns.length - 1, j = pane.getChannelCount() - 1; i >= 0; i--, j--) {
131 if(pane.getChannel(j) != chns[i]) {
132 getA4n().moveChannelsAtBottom.setEnabled(true);
133 break;
134 }
135 }
136 }
137 }

  ViewVC Help
Powered by ViewVC