45 |
|
|
46 |
import net.sf.juife.OkCancelDialog; |
import net.sf.juife.OkCancelDialog; |
47 |
|
|
48 |
|
import net.sf.juife.event.TaskEvent; |
49 |
|
import net.sf.juife.event.TaskListener; |
50 |
|
|
51 |
import org.jsampler.CC; |
import org.jsampler.CC; |
52 |
import org.jsampler.JSPrefs; |
import org.jsampler.JSPrefs; |
53 |
|
import org.jsampler.MidiInstrumentMap; |
54 |
|
|
55 |
|
import org.jsampler.task.Midi; |
56 |
|
|
57 |
|
import org.linuxsampler.lscp.Instrument; |
58 |
|
import org.linuxsampler.lscp.MidiInstrumentEntry; |
59 |
import org.linuxsampler.lscp.MidiInstrumentInfo; |
import org.linuxsampler.lscp.MidiInstrumentInfo; |
60 |
|
|
61 |
import static org.jsampler.view.std.StdI18n.i18n; |
import static org.jsampler.view.std.StdI18n.i18n; |
79 |
private final JSlider slVolume = new JSlider(0, 100, 100); |
private final JSlider slVolume = new JSlider(0, 100, 100); |
80 |
private final JComboBox cbLoadMode = new JComboBox(); |
private final JComboBox cbLoadMode = new JComboBox(); |
81 |
|
|
82 |
|
private MidiInstrumentMap map; |
83 |
|
private Instrument instr; |
84 |
|
|
85 |
/** |
/** |
86 |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
87 |
*/ |
*/ |
88 |
public |
public |
89 |
JSAddMidiInstrumentDlg(Frame owner) { |
JSAddMidiInstrumentDlg(Frame owner, MidiInstrumentMap map, Instrument instr) { |
90 |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
91 |
initAddMidiInstrumentDlg(); |
initAddMidiInstrumentDlg(map, instr); |
92 |
} |
} |
93 |
|
|
94 |
/** |
/** |
95 |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
96 |
*/ |
*/ |
97 |
public |
public |
98 |
JSAddMidiInstrumentDlg(Dialog owner) { |
JSAddMidiInstrumentDlg(Dialog owner, MidiInstrumentMap map, Instrument instr) { |
99 |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
100 |
initAddMidiInstrumentDlg(); |
initAddMidiInstrumentDlg(map, instr); |
101 |
} |
} |
102 |
|
|
103 |
private void |
private void |
104 |
initAddMidiInstrumentDlg() { |
initAddMidiInstrumentDlg(MidiInstrumentMap map, Instrument instr) { |
105 |
|
this.map = map; |
106 |
|
this.instr = instr; |
107 |
|
|
108 |
JPanel mainPane = new JPanel(); |
JPanel mainPane = new JPanel(); |
109 |
GridBagLayout gridbag = new GridBagLayout(); |
GridBagLayout gridbag = new GridBagLayout(); |
110 |
GridBagConstraints c = new GridBagConstraints(); |
GridBagConstraints c = new GridBagConstraints(); |
196 |
}); |
}); |
197 |
|
|
198 |
tfName.getDocument().addDocumentListener(getHandler()); |
tfName.getDocument().addDocumentListener(getHandler()); |
199 |
|
|
200 |
|
setInstrumentName(instr.getName()); |
201 |
|
setMidiInstrumentEntry(map.getAvailableEntry()); |
202 |
} |
} |
203 |
|
|
204 |
protected JSPrefs |
protected JSPrefs |
205 |
preferences() { return CC.getViewConfig().preferences(); } |
preferences() { return CC.getViewConfig().preferences(); } |
206 |
|
|
207 |
/** |
/** |
208 |
|
* Sets the MIDI bank and MIDI program of the dialog. |
209 |
|
*/ |
210 |
|
public void |
211 |
|
setMidiInstrumentEntry(MidiInstrumentEntry entry) { |
212 |
|
if(entry == null) return; |
213 |
|
setMidiBank(entry.getMidiBank()); |
214 |
|
setMidiProgram(entry.getMidiProgram()); |
215 |
|
} |
216 |
|
|
217 |
|
/** |
218 |
* Gets the selected MIDI bank. |
* Gets the selected MIDI bank. |
219 |
*/ |
*/ |
220 |
public int |
public int |
270 |
protected void |
protected void |
271 |
onOk() { |
onOk() { |
272 |
if(!btnOk.isEnabled()) return; |
if(!btnOk.isEnabled()) return; |
273 |
|
|
274 |
|
btnOk.setEnabled(false); |
275 |
preferences().setIntProperty("lastUsedMidiBank", getMidiBank()); |
preferences().setIntProperty("lastUsedMidiBank", getMidiBank()); |
276 |
setCancelled(false); |
|
277 |
setVisible(false); |
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
278 |
|
instrInfo.setName(getInstrumentName()); |
279 |
|
instrInfo.setFilePath(instr.getFilePath()); |
280 |
|
instrInfo.setInstrumentIndex(instr.getInstrumentIndex()); |
281 |
|
instrInfo.setEngine(instr.getEngine()); |
282 |
|
instrInfo.setVolume(getVolume()); |
283 |
|
instrInfo.setLoadMode(getLoadMode()); |
284 |
|
|
285 |
|
int id = map.getMapId(); |
286 |
|
int b = getMidiBank(); |
287 |
|
int p = getMidiProgram(); |
288 |
|
final Midi.MapInstrument t = new Midi.MapInstrument(id, b, p, instrInfo); |
289 |
|
|
290 |
|
t.addTaskListener(new TaskListener() { |
291 |
|
public void |
292 |
|
taskPerformed(TaskEvent e) { |
293 |
|
btnOk.setEnabled(true); |
294 |
|
if(t.doneWithErrors()) return; |
295 |
|
setCancelled(false); |
296 |
|
setVisible(false); |
297 |
|
} |
298 |
|
}); |
299 |
|
|
300 |
|
CC.getTaskQueue().add(t); |
301 |
} |
} |
302 |
|
|
303 |
protected void |
protected void |