39 |
import javax.swing.AbstractAction; |
import javax.swing.AbstractAction; |
40 |
import javax.swing.Action; |
import javax.swing.Action; |
41 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
|
import javax.swing.ButtonGroup; |
|
42 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
43 |
import javax.swing.JButton; |
import javax.swing.JButton; |
44 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
46 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
47 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
48 |
import javax.swing.JPopupMenu; |
import javax.swing.JPopupMenu; |
|
import javax.swing.JRadioButtonMenuItem; |
|
49 |
import javax.swing.JScrollPane; |
import javax.swing.JScrollPane; |
50 |
import javax.swing.JToolBar; |
import javax.swing.JToolBar; |
51 |
|
|
73 |
|
|
74 |
import org.linuxsampler.lscp.SamplerChannel; |
import org.linuxsampler.lscp.SamplerChannel; |
75 |
|
|
76 |
|
import static org.jsampler.view.fantasia.A4n.a4n; |
77 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
78 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
79 |
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
171 |
*/ |
*/ |
172 |
public |
public |
173 |
Channel(SamplerChannelModel model, final ActionListener listener) { |
Channel(SamplerChannelModel model, final ActionListener listener) { |
174 |
|
this ( |
175 |
|
model, listener, |
176 |
|
preferences().getIntProperty(DEFAULT_CHANNEL_VIEW) == 0 ? |
177 |
|
ChannelView.Type.SMALL : ChannelView.Type.NORMAL |
178 |
|
); |
179 |
|
} |
180 |
|
|
181 |
|
/** |
182 |
|
* Creates a new instance of <code>Channel</code> using the specified |
183 |
|
* non-<code>null</code> channel model. |
184 |
|
* @param model The model to be used by this channel. |
185 |
|
* @param listener A listener which is notified when the newly created |
186 |
|
* channel is fully expanded on the screen. |
187 |
|
* @param type Specifies the view type to be used. |
188 |
|
* @throws IllegalArgumentException If the model is <code>null</code>. |
189 |
|
*/ |
190 |
|
public |
191 |
|
Channel(SamplerChannelModel model, final ActionListener listener, ChannelView.Type type) { |
192 |
super(model); |
super(model); |
193 |
|
|
194 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
202 |
new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS) |
new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS) |
203 |
); |
); |
204 |
|
|
205 |
int viewIdx = preferences().getIntProperty(DEFAULT_CHANNEL_VIEW); |
switch(type) { |
206 |
if(viewIdx == 0) { |
case SMALL: viewTracker.setView(new SmallChannelView(Channel.this)); break; |
207 |
viewTracker.setView(new SmallChannelView(Channel.this)); |
case NORMAL: viewTracker.setView(new NormalChannelView(Channel.this)); break; |
208 |
} else if(viewIdx == 1) { |
default: viewTracker.setView(new NormalChannelView(Channel.this)); |
|
viewTracker.setView(new NormalChannelView(Channel.this)); |
|
|
} else { |
|
|
viewTracker.setView(new NormalChannelView(Channel.this)); |
|
209 |
} |
} |
210 |
|
|
211 |
setOpaque(false); |
setOpaque(false); |
310 |
@Override |
@Override |
311 |
public void |
public void |
312 |
setSelected(boolean select) { |
setSelected(boolean select) { |
313 |
|
if(selected == select) return; |
314 |
selected = select; |
selected = select; |
315 |
|
repaint(); |
316 |
} |
} |
317 |
|
|
318 |
/** Shows the channel properties. */ |
/** Shows the channel properties. */ |
806 |
voiceCountChanged(SamplerChannelEvent e) { } |
voiceCountChanged(SamplerChannelEvent e) { } |
807 |
} |
} |
808 |
|
|
|
class SetSmallViewAction extends AbstractAction { |
|
|
SetSmallViewAction() { |
|
|
super(i18n.getMenuLabel("channels.smallView")); |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
viewTracker.setView(new SmallChannelView(Channel.this)); |
|
|
} |
|
|
} |
|
|
|
|
|
class SetNormalViewAction extends AbstractAction { |
|
|
SetNormalViewAction() { |
|
|
super(i18n.getMenuLabel("channels.normalView")); |
|
|
} |
|
|
|
|
|
@Override |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
viewTracker.setView(new NormalChannelView(Channel.this)); |
|
|
} |
|
|
} |
|
|
|
|
809 |
public ContextMenu |
public ContextMenu |
810 |
getContextMenu() { return contextMenu; } |
getContextMenu() { return contextMenu; } |
811 |
|
|
812 |
class ContextMenu extends MouseAdapter { |
class ContextMenu extends MouseAdapter { |
813 |
private JPopupMenu menu = null; |
private JPopupMenu menu = null; |
814 |
|
|
|
protected JRadioButtonMenuItem rbmiSmallView; |
|
|
protected JRadioButtonMenuItem rbmiNormalView; |
|
|
|
|
815 |
ContextMenu() { |
ContextMenu() { |
816 |
|
|
817 |
} |
} |
822 |
menu.add(new JMenuItem(new EditInstrumentAction())); |
menu.add(new JMenuItem(new EditInstrumentAction())); |
823 |
menu.addSeparator(); |
menu.addSeparator(); |
824 |
|
|
825 |
rbmiSmallView = new JRadioButtonMenuItem(new SetSmallViewAction()); |
MenuManager.ChannelViewGroup group; |
826 |
rbmiNormalView = new JRadioButtonMenuItem(new SetNormalViewAction()); |
group = new MenuManager.ChannelViewGroup(true, true); |
827 |
if(viewTracker.getOriginalView() instanceof SmallChannelView) { |
MenuManager.getMenuManager().registerChannelViewGroup(group); |
|
rbmiSmallView.setSelected(true); |
|
|
} else if(viewTracker.getOriginalView() instanceof NormalChannelView) { |
|
|
rbmiNormalView.setSelected(true); |
|
|
} |
|
828 |
|
|
829 |
ButtonGroup group = new ButtonGroup(); |
for(JMenuItem mi : group.getMenuItems()) menu.add(mi); |
|
group.add(rbmiSmallView); |
|
|
group.add(rbmiNormalView); |
|
830 |
|
|
831 |
menu.add(rbmiSmallView); |
menu.addSeparator(); |
832 |
menu.add(rbmiNormalView); |
|
833 |
|
menu.add(new JMenuItem(a4n.moveChannelsOnTop)); |
834 |
|
menu.add(new JMenuItem(a4n.moveChannelsUp)); |
835 |
|
menu.add(new JMenuItem(a4n.moveChannelsDown)); |
836 |
|
menu.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
837 |
|
|
838 |
|
menu.add(new MainFrame.ToPanelMenu()); |
839 |
|
|
840 |
menu.addSeparator(); |
menu.addSeparator(); |
841 |
|
|
842 |
menu.add(new JMenuItem(new FxSendsAction())); |
menu.add(new JMenuItem(new FxSendsAction())); |
843 |
menu.add(new JMenuItem(new ChannelRoutingAction())); |
menu.add(new JMenuItem(new ChannelRoutingAction())); |
844 |
} |
} |