1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
import java.awt.Component; |
import java.awt.Component; |
27 |
|
|
28 |
|
import java.awt.event.ActionEvent; |
29 |
|
import java.awt.event.ActionListener; |
30 |
|
|
31 |
|
import javax.swing.BoxLayout; |
32 |
import javax.swing.ListSelectionModel; |
import javax.swing.ListSelectionModel; |
33 |
|
|
34 |
import javax.swing.event.ListSelectionEvent; |
import javax.swing.event.ListSelectionEvent; |
50 |
* @author Grigor Iliev |
* @author Grigor Iliev |
51 |
*/ |
*/ |
52 |
public class ChannelsPane extends JSChannelsPane { |
public class ChannelsPane extends JSChannelsPane { |
53 |
private final ComponentList chnList = new ComponentList(); |
private final ChannelListPane chnList = new ChannelListPane(); |
54 |
private final DefaultComponentListModel listModel = new DefaultComponentListModel(); |
private final DefaultComponentListModel listModel = new DefaultComponentListModel(); |
55 |
|
|
56 |
|
private ActionListener listener; |
57 |
|
|
58 |
/** |
/** |
59 |
* Creates a new instance of <code>ChannelsPane</code> with |
* Creates a new instance of <code>ChannelsPane</code> with |
62 |
*/ |
*/ |
63 |
public |
public |
64 |
ChannelsPane(String title) { |
ChannelsPane(String title) { |
65 |
|
this(title, null); |
66 |
|
} |
67 |
|
|
68 |
|
/** |
69 |
|
* Creates a new instance of <code>ChannelsPane</code> with |
70 |
|
* the specified <code>title</code>. |
71 |
|
* @param title The title of this <code>ChannelsPane</code> |
72 |
|
* @param l A listener which is notified when a newly created |
73 |
|
* channel is fully expanded on the screen. |
74 |
|
*/ |
75 |
|
public |
76 |
|
ChannelsPane(String title, ActionListener l) { |
77 |
super(title); |
super(title); |
78 |
|
|
79 |
setLayout(new BorderLayout()); |
listener = l; |
80 |
|
|
81 |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
82 |
|
|
|
chnList.setOpaque(false); |
|
83 |
chnList.setModel(listModel); |
chnList.setModel(listModel); |
84 |
chnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
chnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
85 |
|
|
86 |
add(chnList); |
add(chnList); |
87 |
|
} |
88 |
setOpaque(true); |
|
89 |
|
class ChannelListPane extends ComponentList { |
90 |
|
public java.awt.Dimension |
91 |
|
getMaximumSize() { return getPreferredSize(); } |
92 |
} |
} |
93 |
|
|
94 |
/** |
/** |
97 |
*/ |
*/ |
98 |
public void |
public void |
99 |
addChannel(SamplerChannelModel channelModel) { |
addChannel(SamplerChannelModel channelModel) { |
100 |
Channel channel = new Channel(channelModel); |
Channel channel = new Channel(channelModel, listener); |
101 |
listModel.add(channel); |
listModel.add(channel); |
102 |
if(channel.getChannelInfo().getEngine() == null) channel.expandChannel(); |
if(channel.getChannelInfo().getEngine() == null) channel.expandChannel(false); |
103 |
chnList.setSelectedComponent(channel, true); |
chnList.setSelectedComponent(channel, true); |
|
|
|
|
MainFrame.repack(CC.getMainFrame()); |
|
104 |
} |
} |
105 |
|
|
106 |
/** |
/** |
114 |
for(JSChannel c : chns) listModel.add(c); |
for(JSChannel c : chns) listModel.add(c); |
115 |
|
|
116 |
chnList.setSelectedIndex(listModel.getSize() - 1); |
chnList.setSelectedIndex(listModel.getSize() - 1); |
|
|
|
|
MainFrame.repack(CC.getMainFrame()); |
|
117 |
} |
} |
118 |
|
|
119 |
/** |
/** |
124 |
public void |
public void |
125 |
removeChannel(JSChannel chn) { |
removeChannel(JSChannel chn) { |
126 |
listModel.remove(chn); |
listModel.remove(chn); |
|
|
|
|
MainFrame.repack(CC.getMainFrame()); |
|
127 |
} |
} |
128 |
|
|
129 |
/** |
/** |
215 |
model.remove(i); |
model.remove(i); |
216 |
} |
} |
217 |
|
|
|
|
|
|
MainFrame.repack(CC.getMainFrame()); |
|
|
|
|
218 |
return l.length; |
return l.length; |
219 |
} |
} |
220 |
|
|