22 |
|
|
23 |
package org.jsampler.view.classic; |
package org.jsampler.view.classic; |
24 |
|
|
|
import java.awt.MediaTracker; |
|
|
|
|
25 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
26 |
|
|
27 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
28 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
29 |
|
|
|
import java.io.FileOutputStream; |
|
|
import java.net.URL; |
|
30 |
import java.util.logging.Level; |
import java.util.logging.Level; |
31 |
|
|
32 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
33 |
import javax.swing.Action; |
import javax.swing.Action; |
|
import javax.swing.ImageIcon; |
|
34 |
import javax.swing.JFileChooser; |
import javax.swing.JFileChooser; |
35 |
|
|
36 |
import net.sf.juife.event.TaskEvent; |
import net.sf.juife.event.TaskEvent; |
43 |
import org.jsampler.view.JSChannel; |
import org.jsampler.view.JSChannel; |
44 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
45 |
import org.jsampler.view.JSMainFrame; |
import org.jsampler.view.JSMainFrame; |
46 |
import org.jsampler.view.LscpFileFilter; |
import org.jsampler.view.std.JSAddMidiInstrumentMapDlg; |
47 |
|
|
48 |
|
import org.jsampler.view.std.JSNewMidiDeviceDlg; |
49 |
|
import org.jsampler.view.std.JSNewAudioDeviceDlg; |
50 |
|
import org.jsampler.view.std.JSNewMidiInstrumentWizard; |
51 |
|
import org.jsampler.view.std.StdA4n; |
52 |
|
|
53 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
54 |
|
|
57 |
* This class provides an <code>Action</code> instances performing all needed tasks. |
* This class provides an <code>Action</code> instances performing all needed tasks. |
58 |
* @author Grigor Iliev |
* @author Grigor Iliev |
59 |
*/ |
*/ |
60 |
public class A4n { |
public class A4n extends StdA4n { |
61 |
|
protected static A4n a4n = new A4n(); |
62 |
|
|
63 |
|
/** Forbids the instantiation of <code>A4n</code> */ |
64 |
|
private A4n() { |
65 |
|
refresh.putValue(Action.SMALL_ICON, Res.iconReload32); |
66 |
|
resetSampler.putValue(Action.SMALL_ICON, Res.iconReset32); |
67 |
|
exportSamplerConfig.putValue(Action.SMALL_ICON, Res.iconExportSession32); |
68 |
|
exportMidiInstrumentMaps.putValue(Action.SMALL_ICON, Res.iconExport16); |
69 |
|
} |
70 |
|
|
71 |
|
protected ClassicPrefs |
72 |
|
preferences() { |
73 |
|
return ClassicPrefs.preferences(); |
74 |
|
} |
75 |
|
|
76 |
private static boolean |
private static boolean |
77 |
verifyConnection() { |
verifyConnection() { |
78 |
if(!CC.getClient().isConnected()) { |
if(!CC.getClient().isConnected()) { |
83 |
return true; |
return true; |
84 |
} |
} |
85 |
|
|
|
public final static Action connect = new Connect(); |
|
|
|
|
|
private static class Connect extends AbstractAction { |
|
|
Connect() { |
|
|
super(i18n.getMenuLabel("actions.connect")); |
|
|
|
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttConnect")); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { CC.reconnect(); } |
|
|
} |
|
|
|
|
86 |
public final static Action samplerInfo = new SamplerInfo(); |
public final static Action samplerInfo = new SamplerInfo(); |
87 |
|
|
88 |
private static class SamplerInfo extends AbstractAction { |
private static class SamplerInfo extends AbstractAction { |
99 |
} |
} |
100 |
} |
} |
101 |
|
|
|
public final static Action refresh = new Refresh(); |
|
|
|
|
|
private static class Refresh extends AbstractAction { |
|
|
Refresh() { |
|
|
super(i18n.getMenuLabel("actions.refresh")); |
|
|
|
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttRefresh")); |
|
|
putValue(Action.SMALL_ICON, Res.iconReload32); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { CC.initSamplerModel(); } |
|
|
} |
|
|
|
|
|
public final static Action resetSampler = new Reset(); |
|
|
|
|
|
private static class Reset extends AbstractAction { |
|
|
Reset() { |
|
|
super(i18n.getMenuLabel("actions.resetSampler")); |
|
|
|
|
|
putValue(SHORT_DESCRIPTION, i18n.getMenuLabel("ttResetSampler")); |
|
|
putValue(Action.SMALL_ICON, Res.iconReset32); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { CC.getSamplerModel().resetBackend(); } |
|
|
} |
|
|
|
|
102 |
public final static Action addMidiInstrumentMap = new AddMidiInstrumentMap(); |
public final static Action addMidiInstrumentMap = new AddMidiInstrumentMap(); |
103 |
|
|
104 |
private static class AddMidiInstrumentMap extends AbstractAction { |
private static class AddMidiInstrumentMap extends AbstractAction { |
112 |
|
|
113 |
public void |
public void |
114 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
115 |
AddMidiInstrumentMapDlg dlg = new AddMidiInstrumentMapDlg(); |
JSAddMidiInstrumentMapDlg dlg = new JSAddMidiInstrumentMapDlg(); |
116 |
dlg.setVisible(true); |
dlg.setVisible(true); |
117 |
if(dlg.isCancelled()) return; |
if(dlg.isCancelled()) return; |
118 |
|
|
155 |
|
|
156 |
public void |
public void |
157 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
158 |
NewMidiInstrumentWizard wizard = new NewMidiInstrumentWizard(); |
ClassicPrefs prefs = ClassicPrefs.preferences(); |
159 |
|
JSNewMidiInstrumentWizard wizard = |
160 |
|
new JSNewMidiInstrumentWizard(prefs, Res.iconFolderOpen16); |
161 |
|
|
162 |
wizard.getWizardDialog().setResizable(false); |
wizard.getWizardDialog().setResizable(false); |
163 |
|
|
164 |
if(ClassicPrefs.getNewMidiInstrWizardSkip1()) { |
if(prefs.getBoolProperty("NewMidiInstrumentWizard.skip1")) { |
165 |
if(wizard.getModel().getCurrentPage() == null) { |
if(wizard.getModel().getCurrentPage() == null) { |
166 |
wizard.getModel().next(); |
wizard.getModel().next(); |
167 |
} |
} |
173 |
} |
} |
174 |
} |
} |
175 |
|
|
|
public final static Action exportMidiInstrumentMaps = new ExportMidiInstrumentMaps(); |
|
|
|
|
|
private static class ExportMidiInstrumentMaps extends AbstractAction { |
|
|
ExportMidiInstrumentMaps() { |
|
|
super(i18n.getMenuLabel("actions.export.MidiInstrumentMaps")); |
|
|
|
|
|
String s = i18n.getMenuLabel("actions.export.MidiInstrumentMaps.tt"); |
|
|
putValue(SHORT_DESCRIPTION, s); |
|
|
putValue(Action.SMALL_ICON, Res.iconExport16); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
|
|
fc.setFileFilter(new LscpFileFilter()); |
|
|
int result = fc.showSaveDialog(CC.getMainFrame()); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
|
|
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
ClassicPrefs.setLastScriptLocation(path); |
|
|
|
|
|
try { |
|
|
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
|
|
fos.write(CC.exportInstrMapsToLscpScript().getBytes("US-ASCII")); |
|
|
fos.close(); |
|
|
} catch(Exception x) { |
|
|
CC.getLogger().log(Level.FINE, HF.getErrorMessage(x), x); |
|
|
HF.showErrorMessage(x); |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public final static Action exportSamplerConfig = new ExportSamplerConfig(); |
|
|
|
|
|
private static class ExportSamplerConfig extends AbstractAction { |
|
|
ExportSamplerConfig() { |
|
|
super(i18n.getMenuLabel("actions.export.samplerConfiguration")); |
|
|
|
|
|
String s = i18n.getMenuLabel("ttExportSamplerConfiguration"); |
|
|
putValue(SHORT_DESCRIPTION, s); |
|
|
putValue(Action.SMALL_ICON, Res.iconExportSession32); |
|
|
} |
|
|
|
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
JFileChooser fc = new JFileChooser(ClassicPrefs.getLastScriptLocation()); |
|
|
fc.setFileFilter(new LscpFileFilter()); |
|
|
int result = fc.showSaveDialog(CC.getMainFrame()); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
|
|
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
ClassicPrefs.setLastScriptLocation(path); |
|
|
|
|
|
try { |
|
|
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
|
|
fos.write(CC.exportSessionToLscpScript().getBytes("US-ASCII")); |
|
|
fos.close(); |
|
|
} catch(Exception x) { |
|
|
CC.getLogger().log(Level.FINE, HF.getErrorMessage(x), x); |
|
|
HF.showErrorMessage(x); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
176 |
public final static Action loadScript = new LoadLscpScript(); |
public final static Action loadScript = new LoadLscpScript(); |
177 |
|
|
178 |
private static class LoadLscpScript extends AbstractAction { |
private static class LoadLscpScript extends AbstractAction { |
202 |
public void |
public void |
203 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
204 |
if(!verifyConnection()) return; |
if(!verifyConnection()) return; |
205 |
new NewMidiDeviceDlg(CC.getMainFrame()).setVisible(true); |
new JSNewMidiDeviceDlg(CC.getMainFrame()).setVisible(true); |
206 |
} |
} |
207 |
} |
} |
208 |
|
|
219 |
public void |
public void |
220 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
221 |
if(!verifyConnection()) return; |
if(!verifyConnection()) return; |
222 |
new NewAudioDeviceDlg(CC.getMainFrame()).setVisible(true); |
new JSNewAudioDeviceDlg(CC.getMainFrame()).setVisible(true); |
223 |
} |
} |
224 |
} |
} |
225 |
|
|
628 |
} |
} |
629 |
|
|
630 |
if(instrumentsDbFrame != null && instrumentsDbFrame.isVisible()) { |
if(instrumentsDbFrame != null && instrumentsDbFrame.isVisible()) { |
631 |
instrumentsDbFrame.toFront(); |
instrumentsDbFrame.setVisible(false); |
632 |
|
instrumentsDbFrame.setVisible(true); |
633 |
return; |
return; |
634 |
} |
} |
635 |
|
|