52 |
|
|
53 |
import net.sf.juife.Wizard; |
import net.sf.juife.Wizard; |
54 |
|
|
55 |
|
import net.sf.juife.event.TaskEvent; |
56 |
|
import net.sf.juife.event.TaskListener; |
57 |
|
|
58 |
import net.sf.juife.wizard.DefaultWizardModel; |
import net.sf.juife.wizard.DefaultWizardModel; |
59 |
import net.sf.juife.wizard.UserInputPage; |
import net.sf.juife.wizard.UserInputPage; |
60 |
import net.sf.juife.wizard.WizardPage; |
import net.sf.juife.wizard.WizardPage; |
61 |
|
|
62 |
import org.jsampler.CC; |
import org.jsampler.CC; |
63 |
import org.jsampler.Instrument; |
import org.jsampler.OrchestraInstrument; |
64 |
import org.jsampler.JSPrefs; |
import org.jsampler.JSPrefs; |
65 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
66 |
import org.jsampler.OrchestraModel; |
import org.jsampler.OrchestraModel; |
67 |
|
|
68 |
|
import org.jsampler.task.Global; |
69 |
|
|
70 |
|
import org.linuxsampler.lscp.Instrument; |
71 |
import org.linuxsampler.lscp.MidiInstrumentEntry; |
import org.linuxsampler.lscp.MidiInstrumentEntry; |
72 |
import org.linuxsampler.lscp.MidiInstrumentInfo; |
import org.linuxsampler.lscp.MidiInstrumentInfo; |
73 |
import org.linuxsampler.lscp.SamplerEngine; |
import org.linuxsampler.lscp.SamplerEngine; |
128 |
|
|
129 |
public String |
public String |
130 |
getInstrumentName() { |
getInstrumentName() { |
131 |
if(!instrLocationMethodWizardPage.isOrchestraMethodSelected()) return null; |
if(!instrLocationMethodWizardPage.isOrchestraMethodSelected()) { |
132 |
Instrument instr = orchestraSelectWizardPage.getInstrument(); |
return manualSelectWizardPage.getInstrumentName(); |
133 |
|
} |
134 |
|
OrchestraInstrument instr = orchestraSelectWizardPage.getInstrument(); |
135 |
if(instr == null) return null; |
if(instr == null) return null; |
136 |
return instr.getName(); |
return instr.getName(); |
137 |
} |
} |
177 |
mapInstrument() { |
mapInstrument() { |
178 |
MidiInstrumentInfo instr = new MidiInstrumentInfo(); |
MidiInstrumentInfo instr = new MidiInstrumentInfo(); |
179 |
if(instrLocationMethodWizardPage.isOrchestraMethodSelected()) { |
if(instrLocationMethodWizardPage.isOrchestraMethodSelected()) { |
180 |
Instrument i = orchestraSelectWizardPage.getInstrument(); |
OrchestraInstrument i = orchestraSelectWizardPage.getInstrument(); |
181 |
instr.setFilePath(i.getPath()); |
instr.setFilePath(i.getFilePath()); |
182 |
instr.setInstrumentIndex(i.getInstrumentIndex()); |
instr.setInstrumentIndex(i.getInstrumentIndex()); |
183 |
instr.setEngine(i.getEngine()); |
instr.setEngine(i.getEngine()); |
184 |
instr.setLoadMode(orchestraSelectWizardPage.getLoadMode()); |
instr.setLoadMode(orchestraSelectWizardPage.getLoadMode()); |
434 |
|
|
435 |
private void |
private void |
436 |
instrumentChanged() { |
instrumentChanged() { |
437 |
Instrument instr = (Instrument)cbInstruments.getSelectedItem(); |
OrchestraInstrument instr = (OrchestraInstrument)cbInstruments.getSelectedItem(); |
438 |
String s = instr == null ? null : instr.getDescription(); |
String s = instr == null ? null : instr.getDescription(); |
439 |
if(s != null && s.length() == 0) s = null; |
if(s != null && s.length() == 0) s = null; |
440 |
cbInstruments.setToolTipText(s); |
cbInstruments.setToolTipText(s); |
450 |
/** |
/** |
451 |
* Gets the selected instrument. |
* Gets the selected instrument. |
452 |
*/ |
*/ |
453 |
public Instrument |
public OrchestraInstrument |
454 |
getInstrument() { return (Instrument)cbInstruments.getSelectedItem(); } |
getInstrument() { return (OrchestraInstrument)cbInstruments.getSelectedItem(); } |
455 |
|
|
456 |
/** |
/** |
457 |
* Gets the selected load mode. |
* Gets the selected load mode. |
472 |
new JLabel(i18n.getLabel("ManualSelectWizardPage.lLoadMode")); |
new JLabel(i18n.getLabel("ManualSelectWizardPage.lLoadMode")); |
473 |
|
|
474 |
private final JComboBox cbFilename = new JComboBox(); |
private final JComboBox cbFilename = new JComboBox(); |
475 |
private final JSpinner spinnerIndex = new JSpinner(new SpinnerNumberModel(0, 0, 500, 1)); |
private final JComboBox cbIndex = new JComboBox(); |
476 |
|
|
477 |
private final JButton btnBrowse; |
private final JButton btnBrowse; |
478 |
|
|
531 |
c.anchor = GridBagConstraints.WEST; |
c.anchor = GridBagConstraints.WEST; |
532 |
gridbag.setConstraints(cbFilename, c); |
gridbag.setConstraints(cbFilename, c); |
533 |
mainPane.add(cbFilename); |
mainPane.add(cbFilename); |
534 |
|
|
535 |
|
for(int i = 0; i < 101; i++) cbIndex.addItem(i); |
536 |
|
|
537 |
c.gridx = 1; |
c.gridx = 1; |
538 |
c.gridy = 1; |
c.gridy = 1; |
539 |
gridbag.setConstraints(spinnerIndex, c); |
gridbag.setConstraints(cbIndex, c); |
540 |
mainPane.add(spinnerIndex); |
mainPane.add(cbIndex); |
541 |
|
|
542 |
c.gridx = 1; |
c.gridx = 1; |
543 |
c.gridy = 2; |
c.gridy = 2; |
570 |
|
|
571 |
cbFilename.addActionListener(new ActionListener() { |
cbFilename.addActionListener(new ActionListener() { |
572 |
public void |
public void |
573 |
actionPerformed(ActionEvent e) { updateState(); } |
actionPerformed(ActionEvent e) { |
574 |
|
updateState(); |
575 |
|
updateFileInstruments(); |
576 |
|
} |
577 |
}); |
}); |
578 |
|
|
579 |
btnBrowse.addActionListener(new ActionListener() { |
btnBrowse.addActionListener(new ActionListener() { |
626 |
Object o = cbFilename.getSelectedItem(); |
Object o = cbFilename.getSelectedItem(); |
627 |
if(o == null) b = false; |
if(o == null) b = false; |
628 |
else b = o.toString().length() > 0; |
else b = o.toString().length() > 0; |
629 |
|
|
630 |
|
o = cbIndex.getSelectedItem(); |
631 |
|
if(o == null || o.toString().length() == 0) b = false; |
632 |
|
|
633 |
getWizard().enableNextButton(b); |
getWizard().enableNextButton(b); |
634 |
} |
} |
635 |
|
|
636 |
|
private void |
637 |
|
updateFileInstruments() { |
638 |
|
Object o = cbFilename.getSelectedItem(); |
639 |
|
if(o == null) return; |
640 |
|
String s = o.toString(); |
641 |
|
final Global.GetFileInstruments t = new Global.GetFileInstruments(s); |
642 |
|
|
643 |
|
t.addTaskListener(new TaskListener() { |
644 |
|
public void |
645 |
|
taskPerformed(TaskEvent e) { |
646 |
|
Instrument[] instrs = t.getResult(); |
647 |
|
if(instrs == null) { |
648 |
|
cbIndex.removeAllItems(); |
649 |
|
for(int i = 0; i < 101; i++) cbIndex.addItem(i); |
650 |
|
return; |
651 |
|
} else { |
652 |
|
|
653 |
|
cbIndex.removeAllItems(); |
654 |
|
for(int i = 0; i < instrs.length; i++) { |
655 |
|
cbIndex.addItem(i + " - " + instrs[i].getName()); |
656 |
|
} |
657 |
|
} |
658 |
|
} |
659 |
|
}); |
660 |
|
|
661 |
|
CC.getTaskQueue().add(t); |
662 |
|
} |
663 |
|
|
664 |
|
public String |
665 |
|
getInstrumentName() { |
666 |
|
if(cbIndex.getSelectedItem() == null) return null; |
667 |
|
String s = cbIndex.getSelectedItem().toString(); |
668 |
|
int i = s.indexOf(" - "); |
669 |
|
if(i == -1) return null; |
670 |
|
return s.substring(i + 3); |
671 |
|
} |
672 |
|
|
673 |
public void |
public void |
674 |
postinitPage() { |
postinitPage() { |
675 |
updateState(); |
updateState(); |
687 |
* @return The index of the instrument in the instrument file. |
* @return The index of the instrument in the instrument file. |
688 |
*/ |
*/ |
689 |
public int |
public int |
690 |
getInstrumentIndex() { return Integer.parseInt(spinnerIndex.getValue().toString()); } |
getInstrumentIndex() { return cbIndex.getSelectedIndex(); } |
691 |
|
|
692 |
/** |
/** |
693 |
* Gets the selected engine. |
* Gets the selected engine. |
733 |
private final JComboBox cbMap = new JComboBox(); |
private final JComboBox cbMap = new JComboBox(); |
734 |
private final JSpinner spinnerBank = new JSpinner(new SpinnerNumberModel(0, 0, 16383, 1)); |
private final JSpinner spinnerBank = new JSpinner(new SpinnerNumberModel(0, 0, 16383, 1)); |
735 |
private final JComboBox cbProgram = new JComboBox(); |
private final JComboBox cbProgram = new JComboBox(); |
736 |
private final JSlider slVolume = new JSlider(0, 100, 100); |
private final JSlider slVolume = StdUtils.createVolumeSlider(); |
737 |
|
|
738 |
private final NewMidiInstrumentWizardModel wizardModel; |
private final NewMidiInstrumentWizardModel wizardModel; |
739 |
|
|
874 |
postinitPage() { |
postinitPage() { |
875 |
String s = wizardModel.getInstrumentName(); |
String s = wizardModel.getInstrumentName(); |
876 |
if(s != null) tfName.setText(s); |
if(s != null) tfName.setText(s); |
877 |
|
else tfName.setText(""); |
878 |
if(wizardModel.getDefaultMap() != null) { |
if(wizardModel.getDefaultMap() != null) { |
879 |
cbMap.setSelectedItem(wizardModel.getDefaultMap()); |
cbMap.setSelectedItem(wizardModel.getDefaultMap()); |
880 |
} |
} |