21 |
*/ |
*/ |
22 |
package org.jsampler.view; |
package org.jsampler.view; |
23 |
|
|
24 |
import javax.swing.event.TreeModelEvent; |
import java.beans.PropertyChangeSupport; |
|
import javax.swing.tree.TreePath; |
|
25 |
import java.util.ArrayList; |
import java.util.ArrayList; |
26 |
import java.util.Enumeration; |
import java.util.Enumeration; |
27 |
import java.util.Vector; |
import java.util.Vector; |
28 |
|
import javax.swing.SwingConstants; |
29 |
|
import javax.swing.event.TreeModelEvent; |
30 |
import javax.swing.event.TreeModelListener; |
import javax.swing.event.TreeModelListener; |
31 |
import javax.swing.tree.TreeModel; |
import javax.swing.tree.TreeModel; |
32 |
import javax.swing.tree.TreeNode; |
import javax.swing.tree.TreeNode; |
33 |
|
import javax.swing.tree.TreePath; |
34 |
|
|
35 |
import org.jsampler.AudioDeviceModel; |
import org.jsampler.AudioDeviceModel; |
36 |
import org.jsampler.CC; |
import org.jsampler.CC; |
37 |
import org.jsampler.EffectChain; |
import org.jsampler.EffectChain; |
38 |
import org.jsampler.event.AudioDeviceAdapter; |
import org.jsampler.EffectInstance; |
39 |
import org.jsampler.event.AudioDeviceEvent; |
import org.jsampler.event.AudioDeviceEvent; |
40 |
|
import org.jsampler.event.AudioDeviceListener; |
41 |
import org.jsampler.event.EffectChainEvent; |
import org.jsampler.event.EffectChainEvent; |
42 |
import org.jsampler.event.EffectChainListener; |
import org.jsampler.event.EffectChainListener; |
43 |
|
import org.jsampler.event.EffectInstanceEvent; |
44 |
|
import org.jsampler.event.EffectInstanceListener; |
45 |
import org.jsampler.event.ListEvent; |
import org.jsampler.event.ListEvent; |
46 |
import org.jsampler.event.ListListener; |
import org.jsampler.event.ListListener; |
47 |
|
|
48 |
import org.linuxsampler.lscp.Effect; |
import org.linuxsampler.lscp.Effect; |
49 |
import org.linuxsampler.lscp.EffectInstance; |
import org.linuxsampler.lscp.EffectParameter; |
50 |
|
|
51 |
import static org.jsampler.JSI18n.i18n; |
import static org.jsampler.JSI18n.i18n; |
52 |
|
|
191 |
private EventHandler |
private EventHandler |
192 |
getHandler() { return eventHandler; } |
getHandler() { return eventHandler; } |
193 |
|
|
194 |
private class EventHandler extends AudioDeviceAdapter implements ListListener<AudioDeviceModel> { |
private class EventHandler implements ListListener<AudioDeviceModel>, AudioDeviceListener { |
195 |
|
|
196 |
|
|
197 |
/** Invoked when a new entry is added to a list. */ |
/** Invoked when a new entry is added to a list. */ |
203 |
new AudioDeviceTreeNode(SamplerTreeModel.this, audioDevices, e.getEntry()); |
new AudioDeviceTreeNode(SamplerTreeModel.this, audioDevices, e.getEntry()); |
204 |
audioDevices.addChild(node); |
audioDevices.addChild(node); |
205 |
fireNodeInserted(node, audioDevices.getIndex(node)); |
fireNodeInserted(node, audioDevices.getIndex(node)); |
206 |
|
|
207 |
|
root.firePropertyChange("SamplerTreeModel.update", null, null); |
208 |
|
audioDevices.firePropertyChange("SamplerTreeModel.update", null, null); |
209 |
} |
} |
210 |
|
|
211 |
/** Invoked when an entry is removed from a list. */ |
/** Invoked when an entry is removed from a list. */ |
220 |
fireNodeRemoved(audioDevices, node, i); |
fireNodeRemoved(audioDevices, node, i); |
221 |
|
|
222 |
e.getEntry().removeAudioDeviceListener(getHandler()); |
e.getEntry().removeAudioDeviceListener(getHandler()); |
223 |
|
|
224 |
|
root.firePropertyChange("SamplerTreeModel.update", null, null); |
225 |
|
audioDevices.firePropertyChange("SamplerTreeModel.update", null, null); |
226 |
|
} |
227 |
|
|
228 |
|
@Override |
229 |
|
public void |
230 |
|
settingsChanged(AudioDeviceEvent e) { |
231 |
|
audioDevices.firePropertyChange("SamplerTreeModel.update", null, null); |
232 |
|
|
233 |
|
TreeNodeBase node = |
234 |
|
audioDevices.getChildById(e.getAudioDeviceModel().getDeviceId()); |
235 |
|
|
236 |
|
if(node != null) { |
237 |
|
node.firePropertyChange("SamplerTreeModel.update", null, null); |
238 |
|
} |
239 |
} |
} |
240 |
|
|
241 |
/** Invoked when a new send effect chain is added to the audio device. */ |
/** Invoked when a new send effect chain is added to the audio device. */ |
250 |
return; |
return; |
251 |
} |
} |
252 |
|
|
253 |
SendEffectChainTreeNode child = |
SendEffectChainsTreeNode chainsNode = node.getSendEffectChainsTreeNode(); |
254 |
new SendEffectChainTreeNode(SamplerTreeModel.this, node, e.getEffectChain()); |
|
255 |
node.addChild(child); |
SendEffectChainTreeNode child = new SendEffectChainTreeNode ( |
256 |
fireNodeInserted(child, node.getIndex(child)); |
SamplerTreeModel.this, chainsNode, e.getEffectChain() |
257 |
|
); |
258 |
|
|
259 |
|
chainsNode.addChild(child); |
260 |
|
fireNodeInserted(child, chainsNode.getIndex(child)); |
261 |
|
|
262 |
|
node.firePropertyChange("SamplerTreeModel.update", null, null); |
263 |
|
chainsNode.firePropertyChange("SamplerTreeModel.update", null, null); |
264 |
} |
} |
265 |
|
|
266 |
/** Invoked when when a send effect chain is removed from the audio device. */ |
/** Invoked when when a send effect chain is removed from the audio device. */ |
275 |
return; |
return; |
276 |
} |
} |
277 |
|
|
278 |
SendEffectChainTreeNode child = node.getChildById(e.getEffectChain().getChainId()); |
SendEffectChainsTreeNode chainsNode = node.getSendEffectChainsTreeNode(); |
279 |
|
|
280 |
|
SendEffectChainTreeNode child = chainsNode.getChildById(e.getEffectChain().getChainId()); |
281 |
if(child == null) { |
if(child == null) { |
282 |
CC.getLogger().warning("Missing send effect chain node. This is a bug!"); |
CC.getLogger().warning("Missing send effect chain node. This is a bug!"); |
283 |
return; |
return; |
284 |
} |
} |
285 |
|
|
286 |
int idx = node.getIndex(child); |
e.getEffectChain().removeEffectChainListener(child); |
287 |
node.removeChildAt(idx); |
child.uninstallListeners(); |
288 |
fireNodeRemoved(node, child, idx); |
|
289 |
|
int idx = chainsNode.getIndex(child); |
290 |
|
chainsNode.removeChildAt(idx); |
291 |
|
fireNodeRemoved(chainsNode, child, idx); |
292 |
|
|
293 |
|
node.firePropertyChange("SamplerTreeModel.update", null, null); |
294 |
|
chainsNode.firePropertyChange("SamplerTreeModel.update", null, null); |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
|
public static abstract class TreeNodeBase<T extends TreeNodeBase> |
299 |
|
extends PropertyChangeSupport implements TreeNode { |
300 |
|
|
301 |
|
public TreeNodeBase() { super(new Object()); } |
302 |
|
|
303 |
|
public abstract T getChildAt(int index); |
304 |
|
public abstract boolean isLeaf(); |
305 |
|
|
306 |
|
/** Gets the number of columns for the corresponding table model. */ |
307 |
|
public int |
308 |
|
getColumnCount() { return 1; } |
309 |
|
|
310 |
|
/** Gets the number of rows for the corresponding table model. */ |
311 |
|
public int |
312 |
|
getRowCount() { return 1; } |
313 |
|
|
314 |
|
/** |
315 |
|
* Gets the value for the cell at <code>row</code> and |
316 |
|
* <code>col</code> for the corresponding table model. |
317 |
|
*/ |
318 |
|
public Object |
319 |
|
getValueAt(int row, int col) { return "Not implemented yet"; } |
320 |
|
|
321 |
|
/** Gets the name of the column for the corresponding table model. */ |
322 |
|
public String |
323 |
|
getColumnName(int col) { return " "; } |
324 |
|
|
325 |
|
/** Gets the number of items this node contains. */ |
326 |
|
public int |
327 |
|
getItemCount() { return getRowCount(); } |
328 |
|
|
329 |
|
public String |
330 |
|
getItemCountString() { return String.valueOf(getItemCount()); } |
331 |
|
|
332 |
|
/** Determines the alignment for the cells in the specified column. */ |
333 |
|
public int |
334 |
|
getHorizontalAlignment(int column) { |
335 |
|
return column == 0 ? SwingConstants.LEFT : SwingConstants.CENTER; |
336 |
} |
} |
337 |
} |
} |
338 |
|
|
339 |
public static class AbstractTreeNode<T extends TreeNode> implements TreeNode { |
public static class AbstractTreeNode<T extends TreeNodeBase> extends TreeNodeBase<T> { |
340 |
protected final SamplerTreeModel treeModel; |
protected final SamplerTreeModel treeModel; |
341 |
private final TreeNode parent; |
private final TreeNodeBase parent; |
342 |
private final Vector<T> children = new Vector<T>(); |
private final Vector<T> children = new Vector<T>(); |
343 |
|
|
344 |
public |
public |
345 |
AbstractTreeNode(SamplerTreeModel treeModel) { this(treeModel, null); } |
AbstractTreeNode(SamplerTreeModel treeModel) { this(treeModel, null); } |
346 |
|
|
347 |
public |
public |
348 |
AbstractTreeNode(SamplerTreeModel treeModel, TreeNode parent) { |
AbstractTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) { |
349 |
this.parent = parent; |
this.parent = parent; |
350 |
this.treeModel = treeModel; |
this.treeModel = treeModel; |
351 |
} |
} |
360 |
getChildCount() { return children.size(); } |
getChildCount() { return children.size(); } |
361 |
|
|
362 |
@Override |
@Override |
363 |
public TreeNode |
public TreeNodeBase |
364 |
getParent() { return parent; } |
getParent() { return parent; } |
365 |
|
|
366 |
@Override |
@Override |
390 |
removeAllChildren() { children.removeAllElements(); } |
removeAllChildren() { children.removeAllElements(); } |
391 |
} |
} |
392 |
|
|
393 |
public static class AbstractTreeLeaf<T extends TreeNode> implements TreeNode { |
public static class AbstractTreeLeaf<T extends TreeNodeBase> extends TreeNodeBase<T> { |
394 |
private final T parent; |
private final T parent; |
395 |
|
|
396 |
public |
public |
401 |
|
|
402 |
// Tree node model methods |
// Tree node model methods |
403 |
@Override |
@Override |
404 |
public TreeNode |
public T |
405 |
getChildAt(int index) { return null; } |
getChildAt(int index) { return null; } |
406 |
|
|
407 |
@Override |
@Override |
430 |
/////// |
/////// |
431 |
} |
} |
432 |
|
|
433 |
public static class SamplerTreeNode extends AbstractTreeNode { |
public static class StandardTreeNode<T extends TreeNodeBase> extends AbstractTreeNode<T> { |
434 |
|
public |
435 |
|
StandardTreeNode(SamplerTreeModel treeModel) { this(treeModel, null); } |
436 |
|
|
437 |
|
public |
438 |
|
StandardTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) { |
439 |
|
super(treeModel, parent); |
440 |
|
} |
441 |
|
|
442 |
|
/** Gets the number of columns for the corresponding table model. */ |
443 |
|
@Override |
444 |
|
public int |
445 |
|
getColumnCount() { return 3; } |
446 |
|
|
447 |
|
/** Gets the number of rows for the corresponding table model. */ |
448 |
|
@Override |
449 |
|
public int |
450 |
|
getRowCount() { return getChildCount(); } |
451 |
|
|
452 |
|
/** |
453 |
|
* Gets the value for the cell at <code>row</code> and |
454 |
|
* <code>col</code> for the corresponding table model. |
455 |
|
*/ |
456 |
|
@Override |
457 |
|
public Object |
458 |
|
getValueAt(int row, int col) { |
459 |
|
if(col == 0) return getChildAt(row); |
460 |
|
if(col == 1) return getChildAt(row).getItemCountString(); |
461 |
|
return ""; |
462 |
|
} |
463 |
|
|
464 |
|
/** Gets the name of the column for the corresponding table model. */ |
465 |
|
@Override |
466 |
|
public String |
467 |
|
getColumnName(int col) { |
468 |
|
if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.name"); |
469 |
|
if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.itemCount"); |
470 |
|
return " "; |
471 |
|
} |
472 |
|
} |
473 |
|
|
474 |
|
public static class SamplerTreeNode extends StandardTreeNode { |
475 |
public |
public |
476 |
SamplerTreeNode(SamplerTreeModel treeModel) { |
SamplerTreeNode(SamplerTreeModel treeModel) { |
477 |
super(treeModel); |
super(treeModel); |
484 |
|
|
485 |
public static class AudioDevicesTreeNode extends AbstractTreeNode<AudioDeviceTreeNode> { |
public static class AudioDevicesTreeNode extends AbstractTreeNode<AudioDeviceTreeNode> { |
486 |
public |
public |
487 |
AudioDevicesTreeNode(SamplerTreeModel treeModel, TreeNode parent) { |
AudioDevicesTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) { |
488 |
super(treeModel, parent); |
super(treeModel, parent); |
489 |
} |
} |
490 |
|
|
496 |
|
|
497 |
return null; |
return null; |
498 |
} |
} |
499 |
|
|
500 |
|
/** Gets the number of columns for the corresponding table model. */ |
501 |
|
@Override |
502 |
|
public int |
503 |
|
getColumnCount() { return 5; } |
504 |
|
|
505 |
|
/** Gets the number of rows for the corresponding table model. */ |
506 |
|
@Override |
507 |
|
public int |
508 |
|
getRowCount() { return getChildCount(); } |
509 |
|
|
510 |
|
/** |
511 |
|
* Gets the value for the cell at <code>row</code> and |
512 |
|
* <code>col</code> for the corresponding table model. |
513 |
|
*/ |
514 |
|
@Override |
515 |
|
public Object |
516 |
|
getValueAt(int row, int col) { |
517 |
|
AudioDeviceModel m = getChildAt(row).getAudioDevice(); |
518 |
|
if(col == 0) return getChildAt(row); |
519 |
|
if(col == 1) return m.getDeviceInfo().getDriverName(); |
520 |
|
if(col == 2) return m.getDeviceInfo().getSampleRate(); |
521 |
|
if(col == 3) return m.getDeviceInfo().getChannelCount(); |
522 |
|
return ""; |
523 |
|
} |
524 |
|
|
525 |
|
/** Gets the name of the column for the corresponding table model. */ |
526 |
|
@Override |
527 |
|
public String |
528 |
|
getColumnName(int col) { |
529 |
|
if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.dev"); |
530 |
|
if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.drv"); |
531 |
|
if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.smplrate"); |
532 |
|
if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.chns"); |
533 |
|
return " "; |
534 |
|
} |
535 |
|
|
536 |
@Override |
@Override |
537 |
public String |
public String |
538 |
toString() { return i18n.getLabel("AudioDevicesTreeNode.toString"); } |
toString() { return i18n.getLabel("AudioDevicesTreeNode.toString"); } |
539 |
} |
} |
540 |
|
|
541 |
public static class AudioDeviceTreeNode extends AbstractTreeNode<SendEffectChainTreeNode> { |
public static class AudioDeviceTreeNode extends StandardTreeNode { |
542 |
private final AudioDeviceModel audioDevice; |
private final AudioDeviceModel audioDevice; |
543 |
|
private final SendEffectChainsTreeNode effectChains; |
544 |
|
|
545 |
public |
public |
546 |
AudioDeviceTreeNode ( |
AudioDeviceTreeNode ( |
547 |
SamplerTreeModel treeModel, TreeNode parent, AudioDeviceModel audioDevice |
SamplerTreeModel treeModel, TreeNodeBase parent, AudioDeviceModel audioDevice |
548 |
|
) { |
549 |
|
super(treeModel, parent); |
550 |
|
this.audioDevice = audioDevice; |
551 |
|
|
552 |
|
effectChains = new SendEffectChainsTreeNode(treeModel, this, audioDevice); |
553 |
|
addChild(effectChains); |
554 |
|
} |
555 |
|
|
556 |
|
public AudioDeviceModel |
557 |
|
getAudioDevice() { return audioDevice; } |
558 |
|
|
559 |
|
public int |
560 |
|
getAudioDeviceId() { return audioDevice.getDeviceId(); } |
561 |
|
|
562 |
|
public SendEffectChainsTreeNode |
563 |
|
getSendEffectChainsTreeNode() { return effectChains; } |
564 |
|
|
565 |
|
@Override |
566 |
|
public String |
567 |
|
toString() { return i18n.getLabel("AudioDeviceTreeNode.toString", getAudioDeviceId()); } |
568 |
|
} |
569 |
|
|
570 |
|
public static class SendEffectChainsTreeNode extends StandardTreeNode<SendEffectChainTreeNode> { |
571 |
|
private final AudioDeviceModel audioDevice; |
572 |
|
|
573 |
|
public |
574 |
|
SendEffectChainsTreeNode ( |
575 |
|
SamplerTreeModel treeModel, TreeNodeBase parent, AudioDeviceModel audioDevice |
576 |
) { |
) { |
577 |
super(treeModel, parent); |
super(treeModel, parent); |
578 |
this.audioDevice = audioDevice; |
this.audioDevice = audioDevice; |
600 |
|
|
601 |
@Override |
@Override |
602 |
public String |
public String |
603 |
toString() { return i18n.getLabel("AudioDeviceTreeNode.toString", getAudioDeviceId()); } |
toString() { return i18n.getLabel("SendEffectChainsTreeNode.toString"); } |
604 |
} |
} |
605 |
|
|
606 |
public static class SendEffectChainTreeNode extends AbstractTreeNode<EffectInstanceTreeNode> |
public static class SendEffectChainTreeNode extends AbstractTreeNode<EffectInstanceTreeNode> |
609 |
|
|
610 |
public |
public |
611 |
SendEffectChainTreeNode ( |
SendEffectChainTreeNode ( |
612 |
SamplerTreeModel treeModel, AudioDeviceTreeNode parent, EffectChain chain |
SamplerTreeModel treeModel, SendEffectChainsTreeNode parent, EffectChain chain |
613 |
) { |
) { |
614 |
super(treeModel, parent); |
super(treeModel, parent); |
615 |
this.chain = chain; |
this.chain = chain; |
616 |
chain.addAudioDeviceListener(this); |
chain.addEffectChainListener(this); |
617 |
updateEffectInstanceList(); |
updateEffectInstanceList(); |
618 |
} |
} |
619 |
/////// |
/////// |
629 |
* send effect chain represented by this tree node belongs. |
* send effect chain represented by this tree node belongs. |
630 |
*/ |
*/ |
631 |
public AudioDeviceModel |
public AudioDeviceModel |
632 |
getAudioDevice() { return ((AudioDeviceTreeNode)getParent()).getAudioDevice(); } |
getAudioDevice() { return ((SendEffectChainsTreeNode)getParent()).getAudioDevice(); } |
633 |
|
|
634 |
|
/** Gets the number of columns for the corresponding table model. */ |
635 |
|
@Override |
636 |
|
public int |
637 |
|
getColumnCount() { return 5; } |
638 |
|
|
639 |
|
/** Gets the number of rows for the corresponding table model. */ |
640 |
|
@Override |
641 |
|
public int |
642 |
|
getRowCount() { return getChildCount(); } |
643 |
|
|
644 |
|
/** |
645 |
|
* Gets the value for the cell at <code>row</code> and |
646 |
|
* <code>col</code> for the corresponding table model. |
647 |
|
*/ |
648 |
|
@Override |
649 |
|
public Object |
650 |
|
getValueAt(int row, int col) { |
651 |
|
EffectInstance e = getChildAt(row).effectInstance; |
652 |
|
if(col == 0) return getChildAt(row); |
653 |
|
if(col == 1) return e.getInfo().getSystem(); |
654 |
|
if(col == 2) return e.getInfo().getModule(); |
655 |
|
if(col == 3) return e.getInfo().getName(); |
656 |
|
return ""; |
657 |
|
} |
658 |
|
|
659 |
|
/** Gets the name of the column for the corresponding table model. */ |
660 |
|
@Override |
661 |
|
public String |
662 |
|
getColumnName(int col) { |
663 |
|
if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.effect"); |
664 |
|
if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.type"); |
665 |
|
if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.file"); |
666 |
|
if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.id"); |
667 |
|
return " "; |
668 |
|
} |
669 |
|
|
670 |
|
@Override |
671 |
|
public int |
672 |
|
getHorizontalAlignment(int column) { |
673 |
|
return column == 1 ? SwingConstants.CENTER : SwingConstants.LEFT; |
674 |
|
} |
675 |
|
|
676 |
@Override |
@Override |
677 |
public String |
public String |
682 |
effectInstanceListChanged(EffectChainEvent e) { |
effectInstanceListChanged(EffectChainEvent e) { |
683 |
updateEffectInstanceList(); |
updateEffectInstanceList(); |
684 |
treeModel.fireNodeStructureChanged(this); |
treeModel.fireNodeStructureChanged(this); |
685 |
|
|
686 |
|
firePropertyChange("SamplerTreeModel.update", null, null); |
687 |
|
getParent().firePropertyChange("SamplerTreeModel.update", null, null); |
688 |
} |
} |
689 |
|
|
690 |
private void |
private void |
691 |
updateEffectInstanceList() { |
updateEffectInstanceList() { |
692 |
|
uninstallListeners(); |
693 |
|
|
694 |
removeAllChildren(); |
removeAllChildren(); |
695 |
for(int i = 0; i < chain.getEffectInstanceCount(); i++) { |
for(int i = 0; i < chain.getEffectInstanceCount(); i++) { |
696 |
EffectInstance ei = chain.getEffectInstance(i); |
EffectInstance ei = chain.getEffectInstance(i); |
697 |
addChild(new EffectInstanceTreeNode(this, ei)); |
addChild(new EffectInstanceTreeNode(treeModel, this, ei)); |
698 |
} |
} |
699 |
|
|
700 |
|
installListeners(); |
701 |
|
} |
702 |
|
|
703 |
|
public void |
704 |
|
installListeners() { |
705 |
|
for(int i = 0; i < getChildCount(); i++) { |
706 |
|
getChildAt(i).effectInstance.addEffectInstanceListener(getChildAt(i)); |
707 |
|
} |
708 |
|
} |
709 |
|
|
710 |
|
public void |
711 |
|
uninstallListeners() { |
712 |
|
for(int i = 0; i < getChildCount(); i++) { |
713 |
|
getChildAt(i).effectInstance.removeEffectInstanceListener(getChildAt(i)); |
714 |
|
} |
715 |
} |
} |
716 |
} |
} |
717 |
|
|
718 |
public static class EffectInstanceTreeNode extends AbstractTreeLeaf<SendEffectChainTreeNode> { |
public static class EffectInstanceTreeNode extends AbstractTreeNode implements EffectInstanceListener { |
719 |
private final EffectInstance effectInstance; |
private final EffectInstance effectInstance; |
720 |
|
private EffectParameter[] params; |
721 |
|
|
722 |
public |
public |
723 |
EffectInstanceTreeNode(SendEffectChainTreeNode parent, EffectInstance ei) { |
EffectInstanceTreeNode ( |
724 |
super(parent); |
SamplerTreeModel treeModel, SendEffectChainTreeNode parent, EffectInstance ei |
725 |
|
) { |
726 |
|
super(treeModel, parent); |
727 |
effectInstance = ei; |
effectInstance = ei; |
728 |
|
params = ei.getInfo().getParameters(); |
729 |
} |
} |
730 |
|
|
731 |
|
@Override |
732 |
|
public SendEffectChainTreeNode |
733 |
|
getParent() { return (SendEffectChainTreeNode)super.getParent(); } |
734 |
|
|
735 |
public int |
public int |
736 |
getInstanceId() { return effectInstance.getInstanceId(); } |
getInstanceId() { return effectInstance.getInstanceId(); } |
737 |
|
|
738 |
|
/** Gets the number of columns for the corresponding table model. */ |
739 |
|
@Override |
740 |
|
public int |
741 |
|
getColumnCount() { return 3; } |
742 |
|
|
743 |
|
/** Gets the number of rows for the corresponding table model. */ |
744 |
|
@Override |
745 |
|
public int |
746 |
|
getRowCount() { return params.length; } |
747 |
|
|
748 |
|
/** |
749 |
|
* Gets the value for the cell at <code>row</code> and |
750 |
|
* <code>col</code> for the corresponding table model. |
751 |
|
*/ |
752 |
|
@Override |
753 |
|
public Object |
754 |
|
getValueAt(int row, int col) { |
755 |
|
if(col == 0) return effectInstance.getInfo().getParameter(row); |
756 |
|
if(col == 1) return effectInstance.getInfo().getParameter(row).getValue(); |
757 |
|
return ""; |
758 |
|
} |
759 |
|
|
760 |
|
/** Gets the name of the column for the corresponding table model. */ |
761 |
|
@Override |
762 |
|
public String |
763 |
|
getColumnName(int col) { |
764 |
|
if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.name"); |
765 |
|
if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.value"); |
766 |
|
return " "; |
767 |
|
} |
768 |
|
|
769 |
|
@Override |
770 |
|
public int |
771 |
|
getHorizontalAlignment(int column) { |
772 |
|
return column == 1 ? SwingConstants.RIGHT : SwingConstants.LEFT; |
773 |
|
} |
774 |
|
|
775 |
|
@Override |
776 |
|
public void |
777 |
|
effectInstanceChanged(EffectInstanceEvent e) { |
778 |
|
firePropertyChange("SamplerTreeModel.update", null, null); |
779 |
|
} |
780 |
|
|
781 |
@Override |
@Override |
782 |
public String |
public String |
783 |
toString() { return effectInstance.getDescription(); } |
toString() { return effectInstance.getInfo().getDescription(); } |
784 |
} |
} |
785 |
|
|
786 |
public static class InternalEffectsTreeNode extends AbstractTreeNode<InternalEffectTreeNode> { |
public static class InternalEffectsTreeNode extends AbstractTreeNode<InternalEffectTreeNode> { |
787 |
public |
public |
788 |
InternalEffectsTreeNode(SamplerTreeModel treeModel, TreeNode parent) { |
InternalEffectsTreeNode(SamplerTreeModel treeModel, TreeNodeBase parent) { |
789 |
super(treeModel, parent); |
super(treeModel, parent); |
790 |
} |
} |
791 |
|
|
792 |
|
/** Gets the number of columns for the corresponding table model. */ |
793 |
|
@Override |
794 |
|
public int |
795 |
|
getColumnCount() { return 5; } |
796 |
|
|
797 |
|
/** Gets the number of rows for the corresponding table model. */ |
798 |
|
@Override |
799 |
|
public int |
800 |
|
getRowCount() { return getChildCount(); } |
801 |
|
|
802 |
|
/** |
803 |
|
* Gets the value for the cell at <code>row</code> and |
804 |
|
* <code>col</code> for the corresponding table model. |
805 |
|
*/ |
806 |
|
@Override |
807 |
|
public Object |
808 |
|
getValueAt(int row, int col) { |
809 |
|
Effect e = getChildAt(row).effect; |
810 |
|
if(col == 0) return getChildAt(row); |
811 |
|
if(col == 1) return e.getSystem(); |
812 |
|
if(col == 2) return e.getModule(); |
813 |
|
if(col == 3) return e.getName(); |
814 |
|
return ""; |
815 |
|
} |
816 |
|
|
817 |
|
/** Gets the name of the column for the corresponding table model. */ |
818 |
|
@Override |
819 |
|
public String |
820 |
|
getColumnName(int col) { |
821 |
|
if(col == 0) return i18n.getLabel("SamplerTreeModel.tableColumn.effect"); |
822 |
|
if(col == 1) return i18n.getLabel("SamplerTreeModel.tableColumn.type"); |
823 |
|
if(col == 2) return i18n.getLabel("SamplerTreeModel.tableColumn.file"); |
824 |
|
if(col == 3) return i18n.getLabel("SamplerTreeModel.tableColumn.id"); |
825 |
|
return " "; |
826 |
|
} |
827 |
|
|
828 |
|
@Override |
829 |
|
public int |
830 |
|
getHorizontalAlignment(int column) { |
831 |
|
return column == 1 ? SwingConstants.CENTER : SwingConstants.LEFT; |
832 |
|
} |
833 |
|
|
834 |
@Override |
@Override |
835 |
public String |
public String |
840 |
private final Effect effect; |
private final Effect effect; |
841 |
|
|
842 |
public |
public |
843 |
InternalEffectTreeNode(TreeNode parent, Effect effect) { |
InternalEffectTreeNode(TreeNodeBase parent, Effect effect) { |
844 |
super(parent); |
super(parent); |
845 |
this.effect = effect; |
this.effect = effect; |
846 |
} |
} |