36 |
import javax.swing.Icon; |
import javax.swing.Icon; |
37 |
import javax.swing.JButton; |
import javax.swing.JButton; |
38 |
import javax.swing.JCheckBox; |
import javax.swing.JCheckBox; |
39 |
|
import javax.swing.JComboBox; |
40 |
import javax.swing.JDialog; |
import javax.swing.JDialog; |
41 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
42 |
|
|
43 |
import org.jsampler.CC; |
import org.jsampler.CC; |
44 |
import org.jsampler.JSPrefs; |
import org.jsampler.JSPrefs; |
45 |
|
|
46 |
|
import org.linuxsampler.lscp.AudioOutputDriver; |
47 |
|
import org.linuxsampler.lscp.MidiInputDriver; |
48 |
|
|
49 |
import static org.jsampler.view.std.StdI18n.i18n; |
import static org.jsampler.view.std.StdI18n.i18n; |
50 |
import static org.jsampler.view.std.StdPrefs.*; |
import static org.jsampler.view.std.StdPrefs.*; |
51 |
|
|
55 |
*/ |
*/ |
56 |
public class JSDefaultsPropsPane extends JPanel { |
public class JSDefaultsPropsPane extends JPanel { |
57 |
private final ChannelDefaultsPane channelDefaultsPane; |
private final ChannelDefaultsPane channelDefaultsPane; |
58 |
|
private final DefaultMidiDriverPane defaultMidiDriverPane = new DefaultMidiDriverPane(); |
59 |
|
private final DefaultAudioDriverPane defaultAudioDriverPane = new DefaultAudioDriverPane(); |
60 |
|
|
61 |
|
|
62 |
/** Creates a new instance of <code>JSDefaultsPropsPane</code> */ |
/** Creates a new instance of <code>JSDefaultsPropsPane</code> */ |
66 |
|
|
67 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
68 |
add(channelDefaultsPane); |
add(channelDefaultsPane); |
69 |
|
add(Box.createRigidArea(new Dimension(0, 6))); |
70 |
|
add(defaultMidiDriverPane); |
71 |
|
add(Box.createRigidArea(new Dimension(0, 6))); |
72 |
|
add(defaultAudioDriverPane); |
73 |
} |
} |
74 |
|
|
75 |
private static JSPrefs |
private static JSPrefs |
78 |
public void |
public void |
79 |
apply() { |
apply() { |
80 |
channelDefaultsPane.apply(); |
channelDefaultsPane.apply(); |
81 |
|
defaultMidiDriverPane.apply(); |
82 |
|
defaultAudioDriverPane.apply(); |
83 |
} |
} |
84 |
|
|
85 |
public static class ChannelDefaultsPane extends JPanel { |
public static class ChannelDefaultsPane extends JPanel { |
146 |
dlg.setVisible(true); |
dlg.setVisible(true); |
147 |
} |
} |
148 |
} |
} |
149 |
|
|
150 |
|
public static class DefaultMidiDriverPane extends JPanel { |
151 |
|
private final JComboBox cbDriver = new JComboBox(); |
152 |
|
|
153 |
|
public |
154 |
|
DefaultMidiDriverPane() { |
155 |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
156 |
|
|
157 |
|
JPanel p = new JPanel(); |
158 |
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
159 |
|
|
160 |
|
cbDriver.setAlignmentX(LEFT_ALIGNMENT); |
161 |
|
int h = cbDriver.getPreferredSize().height; |
162 |
|
cbDriver.setMaximumSize(new Dimension(Short.MAX_VALUE, h)); |
163 |
|
|
164 |
|
p.add(cbDriver); |
165 |
|
p.setAlignmentX(LEFT_ALIGNMENT); |
166 |
|
p.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); |
167 |
|
|
168 |
|
add(p); |
169 |
|
|
170 |
|
String s = i18n.getLabel("JSDefaultsPropsPane.titleMidiDriver"); |
171 |
|
setBorder(BorderFactory.createTitledBorder(s)); |
172 |
|
setAlignmentX(LEFT_ALIGNMENT); |
173 |
|
|
174 |
|
for(Object o : CC.getSamplerModel().getMidiInputDrivers()) { |
175 |
|
cbDriver.addItem(o); |
176 |
|
} |
177 |
|
|
178 |
|
String drv = preferences().getStringProperty(DEFAULT_MIDI_DRIVER); |
179 |
|
for(MidiInputDriver d : CC.getSamplerModel().getMidiInputDrivers()) { |
180 |
|
if(d.getName().equals(drv)){ |
181 |
|
cbDriver.setSelectedItem(d); |
182 |
|
break; |
183 |
|
} |
184 |
|
} |
185 |
|
} |
186 |
|
|
187 |
|
public void |
188 |
|
apply() { |
189 |
|
Object o = cbDriver.getSelectedItem(); |
190 |
|
if(o == null) { |
191 |
|
preferences().setStringProperty(DEFAULT_MIDI_DRIVER, null); |
192 |
|
return; |
193 |
|
} |
194 |
|
|
195 |
|
String drv = ((MidiInputDriver) o).getName(); |
196 |
|
preferences().setStringProperty(DEFAULT_MIDI_DRIVER, drv); |
197 |
|
} |
198 |
|
} |
199 |
|
|
200 |
|
public static class DefaultAudioDriverPane extends JPanel { |
201 |
|
private final JComboBox cbDriver = new JComboBox(); |
202 |
|
|
203 |
|
public |
204 |
|
DefaultAudioDriverPane() { |
205 |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
206 |
|
|
207 |
|
JPanel p = new JPanel(); |
208 |
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
209 |
|
|
210 |
|
cbDriver.setAlignmentX(LEFT_ALIGNMENT); |
211 |
|
int h = cbDriver.getPreferredSize().height; |
212 |
|
cbDriver.setMaximumSize(new Dimension(Short.MAX_VALUE, h)); |
213 |
|
|
214 |
|
p.add(cbDriver); |
215 |
|
p.setAlignmentX(LEFT_ALIGNMENT); |
216 |
|
p.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); |
217 |
|
|
218 |
|
add(p); |
219 |
|
|
220 |
|
String s = i18n.getLabel("JSDefaultsPropsPane.titleAudioDriver"); |
221 |
|
setBorder(BorderFactory.createTitledBorder(s)); |
222 |
|
setAlignmentX(LEFT_ALIGNMENT); |
223 |
|
|
224 |
|
for(Object o : CC.getSamplerModel().getAudioOutputDrivers()) { |
225 |
|
cbDriver.addItem(o); |
226 |
|
} |
227 |
|
|
228 |
|
String drv = preferences().getStringProperty(DEFAULT_AUDIO_DRIVER); |
229 |
|
for(AudioOutputDriver d : CC.getSamplerModel().getAudioOutputDrivers()) { |
230 |
|
if(d.getName().equals(drv)){ |
231 |
|
cbDriver.setSelectedItem(d); |
232 |
|
break; |
233 |
|
} |
234 |
|
} |
235 |
|
} |
236 |
|
|
237 |
|
public void |
238 |
|
apply() { |
239 |
|
Object o = cbDriver.getSelectedItem(); |
240 |
|
if(o == null) { |
241 |
|
preferences().setStringProperty(DEFAULT_AUDIO_DRIVER, null); |
242 |
|
return; |
243 |
|
} |
244 |
|
|
245 |
|
String drv = ((AudioOutputDriver) o).getName(); |
246 |
|
preferences().setStringProperty(DEFAULT_AUDIO_DRIVER, drv); |
247 |
|
} |
248 |
|
} |
249 |
} |
} |