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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1323 - (show annotations) (download)
Tue Sep 4 15:41:13 2007 UTC (16 years, 7 months ago) by iliev
File size: 6206 byte(s)
* Fantasia: added new menu items - Edit/Add Channel,
  Edit/Create MIDI Device, Edit/Create Audio Device,
  View/Toolbar, View/Side Pane, View/Devices Pane

1 /*
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
33 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 protected FantasiaPrefs
56 preferences() {
57 return FantasiaPrefs.preferences();
58 }
59
60 private static boolean
61 verifyConnection() {
62 if(!CC.getClient().isConnected()) {
63 HF.showErrorMessage(i18n.getError("A4n.notConnected"));
64 return false;
65 }
66
67 return true;
68 }
69
70 public final Action samplerInfo = new SamplerInfo();
71
72 private static class SamplerInfo extends AbstractAction {
73 SamplerInfo() {
74 super(i18n.getMenuLabel("actions.samplerInfo"));
75
76 putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.samplerInfo.tt"));
77 putValue(Action.SMALL_ICON, Res.iconSamplerInfo32);
78 }
79
80 public void
81 actionPerformed(ActionEvent e) {
82 new SamplerInfoDlg(CC.getMainFrame()).setVisible(true);
83 }
84 }
85
86 public final Action loadScript = new LoadLscpScript();
87
88 private class LoadLscpScript extends AbstractAction {
89 LoadLscpScript() {
90 super(i18n.getMenuLabel("actions.runScript"));
91
92 putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("actions.runScript.tt"));
93 putValue(Action.SMALL_ICON, Res.iconOpen32);
94 }
95
96 public void
97 actionPerformed(ActionEvent e) {
98 ((MainFrame)CC.getMainFrame()).runScript();
99
100 if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) {
101 windowLSConsole.actionPerformed(null);
102 }
103 }
104 }
105
106 public final Action createMidiDevice = new CreateMidiDevice();
107
108 private class CreateMidiDevice extends AbstractAction {
109 CreateMidiDevice() {
110 super(i18n.getMenuLabel("edit.createMidiDevice"));
111
112 String s = i18n.getMenuLabel("edit.createMidiDevice.tt");
113 putValue(SHORT_DESCRIPTION, s);
114 //putValue(Action.SMALL_ICON, Res.iconNew16);
115 }
116
117 public void
118 actionPerformed(ActionEvent e) {
119 if(!verifyConnection()) return;
120 new JSNewMidiDeviceDlg(CC.getMainFrame()).setVisible(true);
121 }
122 }
123
124 public final Action createAudioDevice = new CreateAudioDevice();
125
126 private class CreateAudioDevice extends AbstractAction {
127 CreateAudioDevice() {
128 super(i18n.getMenuLabel("edit.createAudioDevice"));
129
130 String s = i18n.getMenuLabel("edit.createAudioDevice.tt");
131 putValue(SHORT_DESCRIPTION, s);
132 //putValue(Action.SMALL_ICON, Res.iconNew16);
133 }
134
135 public void
136 actionPerformed(ActionEvent e) {
137 if(!verifyConnection()) return;
138 new JSNewAudioDeviceDlg(CC.getMainFrame()).setVisible(true);
139 }
140 }
141
142 // EDIT
143
144 public final Action editPreferences = new EditPreferences();
145
146 private class EditPreferences extends AbstractAction {
147 EditPreferences() {
148 super(i18n.getMenuLabel("edit.preferences"));
149
150 putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("edit.preferences.tt"));
151 putValue(Action.SMALL_ICON, Res.iconPreferences32);
152 }
153
154 public void
155 actionPerformed(ActionEvent e) { new PrefsDlg(CC.getMainFrame()).setVisible(true); }
156 }
157
158 // WINDOW
159 public final Action windowLSConsole = new WindowLSConsole();
160
161 private class WindowLSConsole extends AbstractAction {
162 WindowLSConsole() {
163 super(i18n.getMenuLabel("window.lsConsole"));
164 putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.lsConsole.tt"));
165 putValue(Action.SMALL_ICON, Res.iconLSConsole32);
166 }
167
168 public void
169 actionPerformed(ActionEvent e) {
170 LSConsoleFrame console = ((MainFrame)CC.getMainFrame()).getLSConsoleFrame();
171
172 if(console.isVisible()) console.setVisible(false);
173
174 console.setVisible(true);
175 }
176 }
177
178 public final Action windowInstrumentsDb = new WindowInstrumentsDb();
179
180 private class WindowInstrumentsDb extends AbstractAction {
181 InstrumentsDbFrame instrumentsDbFrame = null;
182
183 WindowInstrumentsDb() {
184 super(i18n.getMenuLabel("window.instrumentsDb"));
185 putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("window.instrumentsDb.tt"));
186 putValue(Action.SMALL_ICON, Res.iconDb32);
187 }
188
189 public void
190 actionPerformed(ActionEvent e) {
191 if(CC.getInstrumentsDbTreeModel() == null) {
192 String s = i18n.getMessage("A4n.noInstrumentsDbSupport!");
193 HF.showErrorMessage(s, CC.getMainFrame());
194 return;
195 }
196
197 if(instrumentsDbFrame != null && instrumentsDbFrame.isVisible()) {
198 instrumentsDbFrame.setVisible(false);
199 instrumentsDbFrame.setVisible(true);
200 return;
201 }
202
203 instrumentsDbFrame = new InstrumentsDbFrame();
204 instrumentsDbFrame.setVisible(true);
205 }
206 }
207
208 // HELP
209 public final Action helpAbout = new HelpAbout();
210
211 private class HelpAbout extends AbstractAction {
212 HelpAbout() {
213 super(i18n.getMenuLabel("help.about", "Fantasia"));
214 }
215
216 public void
217 actionPerformed(ActionEvent e) {
218 new HelpAboutDlg(CC.getMainFrame()).setVisible(true);
219 }
220 }
221 }

  ViewVC Help
Powered by ViewVC