1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
66 |
|
|
67 |
import org.jsampler.CC; |
import org.jsampler.CC; |
68 |
import org.jsampler.HF; |
import org.jsampler.HF; |
69 |
import org.jsampler.Instrument; |
import org.jsampler.OrchestraInstrument; |
70 |
import org.jsampler.MidiInstrumentMap; |
import org.jsampler.MidiInstrumentMap; |
71 |
import org.jsampler.OrchestraModel; |
import org.jsampler.OrchestraModel; |
72 |
import org.jsampler.SamplerChannelModel; |
import org.jsampler.SamplerChannelModel; |
90 |
import static org.jsampler.view.InstrumentsDbTableModel.ColumnType; |
import static org.jsampler.view.InstrumentsDbTableModel.ColumnType; |
91 |
import static org.jsampler.view.std.StdI18n.i18n; |
import static org.jsampler.view.std.StdI18n.i18n; |
92 |
|
|
93 |
|
import static org.linuxsampler.lscp.Parser.*; |
94 |
|
|
95 |
/** |
/** |
96 |
* |
* |
97 |
* @author Grigor Iliev |
* @author Grigor Iliev |
119 |
/** |
/** |
120 |
* Creates a new instance of <code>JSInstrumentsDbTable</code> |
* Creates a new instance of <code>JSInstrumentsDbTable</code> |
121 |
*/ |
*/ |
122 |
public JSInstrumentsDbTable(JSInstrumentsDbTree tree) { |
public |
123 |
|
JSInstrumentsDbTable(JSInstrumentsDbTree tree) { |
124 |
|
this(tree, ""); |
125 |
|
} |
126 |
|
|
127 |
|
/** |
128 |
|
* Creates a new instance of <code>JSInstrumentsDbTable</code> |
129 |
|
* @param columnPrefix Used to create unique property names for storing |
130 |
|
* the column preferences for different tables e.g. for DbInstrumentChooser, |
131 |
|
* InstrumentsDbFrame. |
132 |
|
*/ |
133 |
|
public |
134 |
|
JSInstrumentsDbTable(JSInstrumentsDbTree tree, String columnPrefix) { |
135 |
|
super(columnPrefix); |
136 |
|
|
137 |
instrumentsDbTree = tree; |
instrumentsDbTree = tree; |
138 |
|
|
139 |
/*for(int i = 0; i < getColumnModel().getColumnCount(); i++) { |
/*for(int i = 0; i < getColumnModel().getColumnCount(); i++) { |
436 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
437 |
DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode(); |
DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode(); |
438 |
if(n == null) return; |
if(n == null) return; |
439 |
instrumentsDbTree.refreshDirectoryContent(n.getInfo().getDirectoryPath()); |
final String path = n.getInfo().getDirectoryPath(); |
440 |
|
instrumentsDbTree.refreshDirectoryContent(path); |
441 |
|
CC.scheduleInTaskQueue(new Runnable() { |
442 |
|
public void |
443 |
|
run() { instrumentsDbTree.setSelectedDirectory(path); } |
444 |
|
}); |
445 |
} |
} |
446 |
|
|
447 |
public void |
public void |
467 |
|
|
468 |
String path = instrumentsDbTree.getSelectedDirectoryPath(); |
String path = instrumentsDbTree.getSelectedDirectoryPath(); |
469 |
if(path.length() > 1) path += "/"; |
if(path.length() > 1) path += "/"; |
470 |
path += getDirectoryName(); |
path += toEscapedFileName(getDirectoryName()); |
471 |
|
|
472 |
final InstrumentsDb.CreateDirectory t = |
final InstrumentsDb.CreateDirectory t = |
473 |
new InstrumentsDb.CreateDirectory(path); |
new InstrumentsDb.CreateDirectory(path); |
640 |
|
|
641 |
LoadInstrumentAction(SamplerChannelModel model) { |
LoadInstrumentAction(SamplerChannelModel model) { |
642 |
String s = "instrumentsdb.actions.loadInstrument.onChannel"; |
String s = "instrumentsdb.actions.loadInstrument.onChannel"; |
643 |
putValue(Action.NAME, i18n.getMenuLabel(s, model.getChannelId())); |
int i = CC.getSamplerModel().getChannelIndex(model) + 1; |
644 |
|
putValue(Action.NAME, i18n.getMenuLabel(s, i)); |
645 |
channelModel = model; |
channelModel = model; |
646 |
} |
} |
647 |
|
|
666 |
|
|
667 |
public void |
public void |
668 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
669 |
Object obj = getLeadObject(); |
DbInstrumentInfo[] instruments = getSelectedInstruments(); |
670 |
if(obj == null || !(obj instanceof DbInstrumentInfo)) return; |
int l = instruments.length; |
671 |
|
if(l == 0) return; |
672 |
DbInstrumentInfo info = (DbInstrumentInfo)obj; |
|
673 |
|
if(l > 4) { |
674 |
|
String s = "JSInstrumentsDbTable.confirmAddToMidiMap"; |
675 |
|
s = i18n.getMessage(s, l, midiMap.getName()); |
676 |
|
if(!HF.showYesNoDialog(JSInstrumentsDbTable.this, s)) return; |
677 |
|
} |
678 |
|
|
679 |
JSAddMidiInstrumentDlg dlg; |
JSAddMidiInstrumentDlg dlg; |
680 |
Window w = JuifeUtils.getWindow(JSInstrumentsDbTable.this); |
Window w = JuifeUtils.getWindow(JSInstrumentsDbTable.this); |
681 |
if(w instanceof Dialog) { |
|
682 |
dlg = new JSAddMidiInstrumentDlg((Dialog)w); |
for(DbInstrumentInfo i : instruments) { |
683 |
} else if(w instanceof Frame) { |
if(w instanceof Dialog) { |
684 |
dlg = new JSAddMidiInstrumentDlg((Frame)w); |
dlg = new JSAddMidiInstrumentDlg((Dialog)w, midiMap, i); |
685 |
} else { |
} else if(w instanceof Frame) { |
686 |
dlg = new JSAddMidiInstrumentDlg((Frame)null); |
dlg = new JSAddMidiInstrumentDlg((Frame)w, midiMap, i); |
687 |
|
} else { |
688 |
|
dlg = new JSAddMidiInstrumentDlg((Frame)null, midiMap, i); |
689 |
|
} |
690 |
|
|
691 |
|
dlg.setVisible(true); |
692 |
} |
} |
|
|
|
|
dlg.setInstrumentName(info.getName()); |
|
|
dlg.setVisible(true); |
|
|
if(dlg.isCancelled()) return; |
|
|
|
|
|
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
|
|
instrInfo.setName(dlg.getInstrumentName()); |
|
|
instrInfo.setFilePath(info.getFilePath()); |
|
|
instrInfo.setInstrumentIndex(info.getInstrumentIndex()); |
|
|
instrInfo.setEngine(info.getFormatFamily()); // TODO: this should be fixed |
|
|
instrInfo.setVolume(dlg.getVolume()); |
|
|
instrInfo.setLoadMode(dlg.getLoadMode()); |
|
|
|
|
|
int id = midiMap.getMapId(); |
|
|
int b = dlg.getMidiBank(); |
|
|
int p = dlg.getMidiProgram(); |
|
|
CC.getSamplerModel().mapBackendMidiInstrument(id, b, p, instrInfo); |
|
693 |
} |
} |
694 |
} |
} |
695 |
|
|
703 |
|
|
704 |
public void |
public void |
705 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
706 |
Object obj = getLeadObject(); |
DbInstrumentInfo[] instruments = getSelectedInstruments(); |
707 |
if(obj == null || !(obj instanceof DbInstrumentInfo)) return; |
int l = instruments.length; |
708 |
DbInstrumentInfo info = (DbInstrumentInfo)obj; |
if(l == 0) return; |
709 |
Instrument instr = new Instrument(); |
|
710 |
instr.setPath(info.getFilePath()); |
if(l > 1) { |
711 |
instr.setInstrumentIndex(info.getInstrumentIndex()); |
String s = "JSInstrumentsDbTable.confirmAddToOrchestra"; |
712 |
instr.setName(info.getName()); |
s = i18n.getMessage(s, l, orchestraModel.getName()); |
713 |
instr.setDescription(info.getDescription()); |
if(!HF.showYesNoDialog(JSInstrumentsDbTable.this, s)) return; |
714 |
instr.setEngine(info.getFormatFamily()); // TODO: this should be fixed |
} |
715 |
orchestraModel.addInstrument(instr); |
|
716 |
|
for(DbInstrumentInfo i : instruments) { |
717 |
|
OrchestraInstrument instr = new OrchestraInstrument(); |
718 |
|
instr.setFilePath(i.getFilePath()); |
719 |
|
instr.setInstrumentIndex(i.getInstrumentIndex()); |
720 |
|
instr.setName(i.getName()); |
721 |
|
instr.setDescription(i.getDescription()); |
722 |
|
instr.setEngine(i.getFormatFamily()); // TODO: this should be fixed |
723 |
|
orchestraModel.addInstrument(instr); |
724 |
|
} |
725 |
} |
} |
726 |
} |
} |
727 |
|
|
1043 |
|
|
1044 |
public void |
public void |
1045 |
channelAdded(SamplerChannelListEvent e) { |
channelAdded(SamplerChannelListEvent e) { |
1046 |
|
if(CC.getSamplerModel().getChannelListIsAdjusting()) return; |
1047 |
updateLoadInstrumentMenus(); |
updateLoadInstrumentMenus(); |
1048 |
} |
} |
1049 |
|
|