61 |
import org.jsampler.event.SamplerChannelListListener; |
import org.jsampler.event.SamplerChannelListListener; |
62 |
|
|
63 |
import org.jsampler.view.InstrumentTable; |
import org.jsampler.view.InstrumentTable; |
|
import org.jsampler.view.InstrumentTableModel; |
|
|
|
|
|
import org.linuxsampler.lscp.MidiInstrumentEntry; |
|
|
import org.linuxsampler.lscp.MidiInstrumentInfo; |
|
64 |
|
|
65 |
import static org.jsampler.view.std.StdI18n.i18n; |
import static org.jsampler.view.std.StdI18n.i18n; |
66 |
|
|
169 |
} |
} |
170 |
|
|
171 |
private class InstrumentSelectionHandler implements ListSelectionListener { |
private class InstrumentSelectionHandler implements ListSelectionListener { |
172 |
|
@Override |
173 |
public void |
public void |
174 |
valueChanged(ListSelectionEvent e) { |
valueChanged(ListSelectionEvent e) { |
175 |
if(e.getValueIsAdjusting()) return; |
if(e.getValueIsAdjusting()) return; |
199 |
putValue(SHORT_DESCRIPTION, s); |
putValue(SHORT_DESCRIPTION, s); |
200 |
} |
} |
201 |
|
|
202 |
|
@Override |
203 |
public void |
public void |
204 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
205 |
OrchestraInstrument instr = createInstrument(); |
OrchestraInstrument instr = createInstrument(); |
218 |
setEnabled(false); |
setEnabled(false); |
219 |
} |
} |
220 |
|
|
221 |
|
@Override |
222 |
public void |
public void |
223 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
224 |
editInstrument(instrumentTable.getSelectedInstrument()); |
editInstrument(instrumentTable.getSelectedInstrument()); |
235 |
setEnabled(false); |
setEnabled(false); |
236 |
} |
} |
237 |
|
|
238 |
|
@Override |
239 |
public void |
public void |
240 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
241 |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
259 |
setEnabled(false); |
setEnabled(false); |
260 |
} |
} |
261 |
|
|
262 |
|
@Override |
263 |
public void |
public void |
264 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
265 |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
278 |
setEnabled(false); |
setEnabled(false); |
279 |
} |
} |
280 |
|
|
281 |
|
@Override |
282 |
public void |
public void |
283 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
284 |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
private class LoadInstrumentAction extends AbstractAction { |
private class LoadInstrumentAction extends StdA4n.LoadInstrumentAction { |
293 |
private final SamplerChannelModel channelModel; |
LoadInstrumentAction(SamplerChannelModel model, boolean onPanel) { |
294 |
|
super(model, onPanel); |
|
LoadInstrumentAction(SamplerChannelModel model) { |
|
|
String s = "instrumentsdb.actions.loadInstrument.onChannel"; |
|
|
int i = CC.getSamplerModel().getChannelIndex(model) + 1; |
|
|
putValue(Action.NAME, i18n.getMenuLabel(s, i)); |
|
|
channelModel = model; |
|
295 |
} |
} |
296 |
|
|
297 |
|
@Override |
298 |
public void |
public void |
299 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
300 |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
306 |
} |
} |
307 |
} |
} |
308 |
|
|
309 |
|
private LoadInstrumentActionFactory loadInstrActionFactory = new LoadInstrumentActionFactory(); |
310 |
|
|
311 |
|
class LoadInstrumentActionFactory implements StdA4n.LoadInstrumentActionFactory { |
312 |
|
public StdA4n.LoadInstrumentAction |
313 |
|
createLoadInstrumentAction(SamplerChannelModel model, boolean onPanel) { |
314 |
|
return new LoadInstrumentAction(model, onPanel); |
315 |
|
} |
316 |
|
} |
317 |
|
|
318 |
class AddToMidiMapAction extends AbstractAction { |
class AddToMidiMapAction extends AbstractAction { |
319 |
private final MidiInstrumentMap midiMap; |
private final MidiInstrumentMap midiMap; |
320 |
|
|
323 |
midiMap = map; |
midiMap = map; |
324 |
} |
} |
325 |
|
|
326 |
|
@Override |
327 |
public void |
public void |
328 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
329 |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
OrchestraInstrument instr = instrumentTable.getSelectedInstrument(); |
394 |
} |
} |
395 |
}; |
}; |
396 |
|
|
397 |
CC.getSamplerModel().addMidiInstrumentMapListListener(l); |
CC.getSamplerModel().addMidiInstrumentMapListListener(l); |
398 |
|
|
399 |
|
CC.getMainFrame().addChannelsPaneSelectionListener(new ListSelectionListener() { |
400 |
|
public void |
401 |
|
valueChanged(ListSelectionEvent e) { |
402 |
|
updateLoadInstrumentMenu(mLoadInstrument); |
403 |
|
} |
404 |
|
}); |
405 |
} |
} |
406 |
|
|
407 |
private void |
private void |
408 |
updateLoadInstrumentMenu(JMenu menu) { |
updateLoadInstrumentMenu(JMenu menu) { |
409 |
menu.removeAll(); |
menu.removeAll(); |
|
for(SamplerChannelModel m : CC.getSamplerModel().getChannels()) { |
|
|
menu.add(new JMenuItem(new LoadInstrumentAction(m))); |
|
|
} |
|
410 |
|
|
411 |
|
StdA4n.updateLoadInstrumentMenu(menu, loadInstrActionFactory); |
412 |
updateLoadInstrumentMenuState(menu); |
updateLoadInstrumentMenuState(menu); |
413 |
} |
} |
414 |
|
|
439 |
menu.setEnabled(!b); |
menu.setEnabled(!b); |
440 |
} |
} |
441 |
|
|
442 |
|
@Override |
443 |
public void |
public void |
444 |
valueChanged(ListSelectionEvent e) { |
valueChanged(ListSelectionEvent e) { |
445 |
updateLoadInstrumentMenuState(mLoadInstrument); |
updateLoadInstrumentMenuState(mLoadInstrument); |
446 |
updateAddToMidiMapMenuState(mMapInstrument); |
updateAddToMidiMapMenuState(mMapInstrument); |
447 |
} |
} |
448 |
|
|
449 |
|
@Override |
450 |
public void |
public void |
451 |
channelAdded(SamplerChannelListEvent e) { |
channelAdded(SamplerChannelListEvent e) { |
452 |
if(CC.getSamplerModel().getChannelListIsAdjusting()) return; |
if(CC.getSamplerModel().getChannelListIsAdjusting()) return; |
453 |
updateLoadInstrumentMenu(mLoadInstrument); |
updateLoadInstrumentMenu(mLoadInstrument); |
454 |
} |
} |
455 |
|
|
456 |
|
@Override |
457 |
public void |
public void |
458 |
channelRemoved(SamplerChannelListEvent e) { |
channelRemoved(SamplerChannelListEvent e) { |
459 |
updateLoadInstrumentMenu(mLoadInstrument); |
updateLoadInstrumentMenu(mLoadInstrument); |
460 |
} |
} |
461 |
|
|
462 |
|
@Override |
463 |
public void |
public void |
464 |
mousePressed(MouseEvent e) { |
mousePressed(MouseEvent e) { |
465 |
if(e.isPopupTrigger()) show(e); |
if(e.isPopupTrigger()) show(e); |
466 |
} |
} |
467 |
|
|
468 |
|
@Override |
469 |
public void |
public void |
470 |
mouseReleased(MouseEvent e) { |
mouseReleased(MouseEvent e) { |
471 |
if(e.isPopupTrigger()) show(e); |
if(e.isPopupTrigger()) show(e); |