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

Annotation of /jsampler/trunk/src/org/jsampler/view/fantasia/A4n.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (hide annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 4 months ago) by iliev
File size: 7850 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 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4     * Copyright (C) 2005-2007 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.fantasia;
24    
25     import java.awt.event.ActionEvent;
26    
27     import javax.swing.AbstractAction;
28     import javax.swing.Action;
29    
30     import org.jsampler.CC;
31     import org.jsampler.HF;
32 iliev 1818 import org.jsampler.view.JSChannel;
33 iliev 1286 import org.jsampler.view.std.JSNewAudioDeviceDlg;
34     import org.jsampler.view.std.JSNewMidiDeviceDlg;
35     import org.jsampler.view.std.StdA4n;
36    
37     import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
38     import static org.jsampler.view.std.StdPrefs.*;
39    
40     /**
41     *
42     * @author Grigor Iliev
43     */
44     public class A4n extends StdA4n {
45     protected static A4n a4n = new A4n();
46    
47     /** Forbids the instantiation of <code>A4n</code> */
48     private A4n() {
49     refresh.putValue(Action.SMALL_ICON, Res.iconReload32);
50     resetSampler.putValue(Action.SMALL_ICON, Res.iconReset32);
51     exportSamplerConfig.putValue(Action.SMALL_ICON, Res.iconSave32);
52     //exportMidiInstrumentMaps.putValue(Action.SMALL_ICON, Res.icon);
53     }
54    
55 iliev 1818 @Override
56 iliev 1286 protected FantasiaPrefs
57 iliev 1818 preferences() { return FantasiaPrefs.preferences(); }
58 iliev 1286
59     public final Action samplerInfo = new SamplerInfo();
60    
61     private static class SamplerInfo extends AbstractAction {
62     SamplerInfo() {
63     super(i18n.getMenuLabel("actions.samplerInfo"));
64    
65     putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.samplerInfo.tt"));
66     putValue(Action.SMALL_ICON, Res.iconSamplerInfo32);
67     }
68    
69 iliev 1818 @Override
70 iliev 1286 public void
71     actionPerformed(ActionEvent e) {
72     new SamplerInfoDlg(CC.getMainFrame()).setVisible(true);
73     }
74     }
75    
76     public final Action loadScript = new LoadLscpScript();
77    
78     private class LoadLscpScript extends AbstractAction {
79     LoadLscpScript() {
80     super(i18n.getMenuLabel("actions.runScript"));
81    
82     putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.runScript.tt"));
83     putValue(Action.SMALL_ICON, Res.iconOpen32);
84     }
85    
86 iliev 1818 @Override
87 iliev 1286 public void
88     actionPerformed(ActionEvent e) {
89 iliev 1688 if(!((MainFrame)CC.getMainFrame()).runScript()) return;
90 iliev 1286
91     if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) {
92     windowLSConsole.actionPerformed(null);
93     }
94     }
95     }
96    
97     public final Action createMidiDevice = new CreateMidiDevice();
98    
99     private class CreateMidiDevice extends AbstractAction {
100     CreateMidiDevice() {
101 iliev 1323 super(i18n.getMenuLabel("edit.createMidiDevice"));
102 iliev 1286
103 iliev 1323 String s = i18n.getMenuLabel("edit.createMidiDevice.tt");
104 iliev 1286 putValue(SHORT_DESCRIPTION, s);
105     //putValue(Action.SMALL_ICON, Res.iconNew16);
106     }
107    
108 iliev 1818 @Override
109 iliev 1286 public void
110     actionPerformed(ActionEvent e) {
111 iliev 1688 if(!CC.verifyConnection()) return;
112 iliev 1286 new JSNewMidiDeviceDlg(CC.getMainFrame()).setVisible(true);
113     }
114     }
115    
116     public final Action createAudioDevice = new CreateAudioDevice();
117    
118     private class CreateAudioDevice extends AbstractAction {
119     CreateAudioDevice() {
120 iliev 1323 super(i18n.getMenuLabel("edit.createAudioDevice"));
121 iliev 1286
122 iliev 1323 String s = i18n.getMenuLabel("edit.createAudioDevice.tt");
123 iliev 1286 putValue(SHORT_DESCRIPTION, s);
124     //putValue(Action.SMALL_ICON, Res.iconNew16);
125     }
126    
127 iliev 1818 @Override
128 iliev 1286 public void
129     actionPerformed(ActionEvent e) {
130 iliev 1688 if(!CC.verifyConnection()) return;
131 iliev 1286 new JSNewAudioDeviceDlg(CC.getMainFrame()).setVisible(true);
132     }
133     }
134    
135     // EDIT
136    
137     public final Action editPreferences = new EditPreferences();
138    
139     private class EditPreferences extends AbstractAction {
140     EditPreferences() {
141     super(i18n.getMenuLabel("edit.preferences"));
142    
143     putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("edit.preferences.tt"));
144     putValue(Action.SMALL_ICON, Res.iconPreferences32);
145     }
146    
147 iliev 1818 @Override
148 iliev 1286 public void
149     actionPerformed(ActionEvent e) { new PrefsDlg(CC.getMainFrame()).setVisible(true); }
150     }
151    
152 iliev 1818
153     // CHANNELS
154    
155     public final Action setSmallView = new SetView(ChannelView.Type.SMALL);
156     public final Action setNormalView = new SetView(ChannelView.Type.NORMAL);
157    
158     public static class SetView extends AbstractAction {
159     private ChannelView.Type type;
160    
161     SetView(ChannelView.Type type) {
162     this.type = type;
163    
164     switch(type) {
165     case SMALL:
166     putValue(Action.NAME, i18n.getMenuLabel("channels.smallView"));
167     break;
168     case NORMAL:
169     putValue(Action.NAME, i18n.getMenuLabel("channels.normalView"));
170     break;
171     }
172     }
173    
174     @Override
175     public void
176     actionPerformed(ActionEvent e) {
177     JSChannel[] channels =
178     CC.getMainFrame().getSelectedChannelsPane().getSelectedChannels();
179    
180     for(JSChannel c : channels) {
181     Channel c2 = (Channel)c;
182     if(c2.getViewTracker().getOriginalView().getType() == type) {
183     continue;
184     }
185    
186     c2.getViewTracker().setView(createView(type, c2));
187     }
188    
189     MenuManager.getMenuManager().updateChannelViewGroups();
190     }
191    
192     public static int
193     getViewCount(ChannelView.Type type) {
194     int count = 0;
195    
196     JSChannel[] channels =
197     CC.getMainFrame().getSelectedChannelsPane().getSelectedChannels();
198    
199     for(JSChannel c : channels) {
200     Channel c2 = (Channel)c;
201     if(c2.getViewTracker().getOriginalView().getType() == type) {
202     count++;
203     }
204     }
205    
206     return count;
207     }
208    
209     public ChannelView
210     createView(ChannelView.Type type, Channel channel) {
211     switch(type) {
212     case SMALL: return new SmallChannelView(channel);
213     case NORMAL: return new NormalChannelView(channel);
214     }
215    
216     throw new IllegalArgumentException("Unknown channel type");
217     }
218     }
219    
220 iliev 1286 // WINDOW
221     public final Action windowLSConsole = new WindowLSConsole();
222    
223     private class WindowLSConsole extends AbstractAction {
224     WindowLSConsole() {
225     super(i18n.getMenuLabel("window.lsConsole"));
226     putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.lsConsole.tt"));
227     putValue(Action.SMALL_ICON, Res.iconLSConsole32);
228     }
229    
230 iliev 1818 @Override
231 iliev 1286 public void
232     actionPerformed(ActionEvent e) {
233     LSConsoleFrame console = ((MainFrame)CC.getMainFrame()).getLSConsoleFrame();
234    
235     if(console.isVisible()) console.setVisible(false);
236    
237     console.setVisible(true);
238     }
239     }
240    
241     public final Action windowInstrumentsDb = new WindowInstrumentsDb();
242    
243     private class WindowInstrumentsDb extends AbstractAction {
244     InstrumentsDbFrame instrumentsDbFrame = null;
245    
246     WindowInstrumentsDb() {
247     super(i18n.getMenuLabel("window.instrumentsDb"));
248     putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.instrumentsDb.tt"));
249     putValue(Action.SMALL_ICON, Res.iconDb32);
250     }
251    
252 iliev 1818 @Override
253 iliev 1286 public void
254     actionPerformed(ActionEvent e) {
255 iliev 1688 if(!CC.verifyConnection()) return;
256    
257 iliev 1286 if(CC.getInstrumentsDbTreeModel() == null) {
258     String s = i18n.getMessage("A4n.noInstrumentsDbSupport!");
259     HF.showErrorMessage(s, CC.getMainFrame());
260     return;
261     }
262    
263     if(instrumentsDbFrame != null && instrumentsDbFrame.isVisible()) {
264     instrumentsDbFrame.setVisible(false);
265     instrumentsDbFrame.setVisible(true);
266     return;
267     }
268    
269     instrumentsDbFrame = new InstrumentsDbFrame();
270     instrumentsDbFrame.setVisible(true);
271     }
272     }
273    
274     // HELP
275     public final Action helpAbout = new HelpAbout();
276    
277     private class HelpAbout extends AbstractAction {
278     HelpAbout() {
279     super(i18n.getMenuLabel("help.about", "Fantasia"));
280     }
281    
282 iliev 1818 @Override
283 iliev 1286 public void
284     actionPerformed(ActionEvent e) {
285     new HelpAboutDlg(CC.getMainFrame()).setVisible(true);
286     }
287     }
288     }

  ViewVC Help
Powered by ViewVC