1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
24 |
|
|
25 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
26 |
|
|
27 |
|
import java.io.File; |
28 |
import java.io.FileOutputStream; |
import java.io.FileOutputStream; |
29 |
|
|
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.JFileChooser; |
|
34 |
|
|
35 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
36 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
47 |
|
|
48 |
import org.jsampler.view.JSChannel; |
import org.jsampler.view.JSChannel; |
49 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
|
import org.jsampler.view.LscpFileFilter; |
|
50 |
|
|
51 |
import static org.jsampler.view.std.StdI18n.i18n; |
import static org.jsampler.view.std.StdI18n.i18n; |
52 |
|
|
64 |
|
|
65 |
protected void |
protected void |
66 |
exportSamplerConfig() { |
exportSamplerConfig() { |
67 |
String s = preferences().getStringProperty("lastScriptLocation"); |
File f = StdUtils.showSaveLscpFileChooser(); |
68 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return; |
69 |
fc.setFileFilter(new LscpFileFilter()); |
if(f.exists()) { |
70 |
int result = fc.showSaveDialog(CC.getMainFrame()); |
String msg = i18n.getMessage("StdA4n.overwriteFile?"); |
71 |
if(result != JFileChooser.APPROVE_OPTION) return; |
if(!HF.showYesNoDialog(CC.getMainFrame(), msg)) return; |
72 |
|
} |
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastScriptLocation", path); |
|
73 |
|
|
74 |
try { |
try { |
75 |
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
FileOutputStream fos = new FileOutputStream(f); |
76 |
fos.write(CC.exportSessionToLscpScript().getBytes("US-ASCII")); |
fos.write(CC.exportSessionToLscpScript().getBytes("US-ASCII")); |
77 |
fos.close(); |
fos.close(); |
78 |
} catch(Exception x) { |
} catch(Exception x) { |
83 |
|
|
84 |
protected void |
protected void |
85 |
exportMidiInstrumentMaps() { |
exportMidiInstrumentMaps() { |
86 |
String s = preferences().getStringProperty("lastScriptLocation"); |
File f = StdUtils.showSaveLscpFileChooser(); |
87 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return; |
88 |
fc.setFileFilter(new LscpFileFilter()); |
|
89 |
int result = fc.showSaveDialog(CC.getMainFrame()); |
if(f.exists()) { |
90 |
if(result != JFileChooser.APPROVE_OPTION) return; |
String msg = i18n.getMessage("StdA4n.overwriteFile?"); |
91 |
|
if(!HF.showYesNoDialog(CC.getMainFrame(), msg)) return; |
92 |
String path = fc.getCurrentDirectory().getAbsolutePath(); |
} |
|
preferences().setStringProperty("lastScriptLocation", path); |
|
93 |
|
|
94 |
try { |
try { |
95 |
FileOutputStream fos = new FileOutputStream(fc.getSelectedFile()); |
FileOutputStream fos = new FileOutputStream(f); |
96 |
fos.write(CC.exportInstrMapsToLscpScript().getBytes("US-ASCII")); |
fos.write(CC.exportInstrMapsToLscpScript().getBytes("US-ASCII")); |
97 |
fos.close(); |
fos.close(); |
98 |
} catch(Exception x) { |
} catch(Exception x) { |
290 |
setEnabled(false); |
setEnabled(false); |
291 |
} |
} |
292 |
|
|
293 |
|
@Override |
294 |
public void |
public void |
295 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
296 |
JSChannel[] channels = |
JSChannel[] channels = |
320 |
setEnabled(false); |
setEnabled(false); |
321 |
} |
} |
322 |
|
|
323 |
|
@Override |
324 |
public void |
public void |
325 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
326 |
JSChannelsPane p = CC.getMainFrame().getSelectedChannelsPane(); |
JSChannelsPane p = CC.getMainFrame().getSelectedChannelsPane(); |