/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/PrefsDlg.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/PrefsDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 3 months ago) by iliev
File size: 13278 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
11 *
12 * JSampler is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with JSampler; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23 package org.jsampler.view.fantasia;
24
25 import java.awt.BorderLayout;
26 import java.awt.Color;
27 import java.awt.Dialog;
28 import java.awt.Dimension;
29 import java.awt.Frame;
30
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33
34 import javax.swing.BorderFactory;
35 import javax.swing.Box;
36 import javax.swing.BoxLayout;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JPanel;
40 import javax.swing.JTabbedPane;
41
42 import net.sf.juife.EnhancedDialog;
43 import net.sf.juife.JuifeUtils;
44
45 import org.jsampler.CC;
46 import org.jsampler.LSConsoleModel;
47 import org.jsampler.Prefs;
48
49 import org.jsampler.view.std.JSAdvancedGeneralPropsDlg;
50 import org.jsampler.view.std.JSConnectionPropsPane;
51 import org.jsampler.view.std.JSDefaultsPropsPane;
52 import org.jsampler.view.std.JSGeneralProps;
53 import org.jsampler.view.std.JSLSConsolePropsPane;
54 import org.jsampler.view.std.JSViewProps;
55
56 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
57 import static org.jsampler.view.fantasia.FantasiaPrefs.*;
58
59
60 /**
61 *
62 * @author Grigor Iliev
63 */
64 public class PrefsDlg extends EnhancedDialog {
65 private final JTabbedPane tabbedPane = new JTabbedPane();
66
67 private final GeneralPane genPane = new GeneralPane(this);
68 private final ViewPane viewPane = new ViewPane();
69 private final ChannelsPropsPane channelsPane = new ChannelsPropsPane();
70 private final ConsolePane consolePane = new ConsolePane();
71 private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
72 private final JSDefaultsPropsPane defaultsPane;
73
74 private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
75 private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));
76
77
78 /** Creates a new instance of <code>PrefsDlg</code> */
79 public
80 PrefsDlg(Frame owner) {
81 super(owner, i18n.getLabel("PrefsDlg.title"), true);
82
83 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16, true);
84
85 JTabbedPane tp = tabbedPane;
86 tp.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
87
88 tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
89 tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
90 tp.addTab(i18n.getLabel("PrefsDlg.tabChannels"), channelsPane);
91 tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
92
93 JPanel p = new JPanel();
94 p.setLayout(new BorderLayout());
95 p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
96 p.add(connectionPane);
97 tp.addTab(i18n.getLabel("PrefsDlg.tabBackend"), p);
98 tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
99
100 tp.setAlignmentX(RIGHT_ALIGNMENT);
101
102 // Set preferred size for Apply & Exit buttons
103 Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose);
104 btnApply.setPreferredSize(d);
105 btnClose.setPreferredSize(d);
106
107 JPanel btnPane = new JPanel();
108 btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS));
109 btnPane.add(btnApply);
110 btnPane.add(Box.createRigidArea(new Dimension(5, 0)));
111 btnPane.add(btnClose);
112 btnPane.setAlignmentX(RIGHT_ALIGNMENT);
113
114 JPanel mainPane = new JPanel();
115 mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
116 mainPane.add(tp);
117 mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
118 mainPane.add(btnPane);
119 mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12));
120
121 getContentPane().add(mainPane);
122
123 pack();
124 setResizable(false);
125 setLocation(JuifeUtils.centerLocation(this, owner));
126
127 installListeners();
128
129 int i = preferences().getIntProperty("PrefsDlg.tabIndex");
130
131 if(i >= 0 && i < tp.getTabCount()) tp.setSelectedIndex(i);
132 }
133
134 private void
135 installListeners() {
136 btnApply.addActionListener(new ActionListener() {
137 public void
138 actionPerformed(ActionEvent e) { onApply(); }
139 });
140
141 btnClose.addActionListener(new ActionListener() {
142 public void
143 actionPerformed(ActionEvent e) { onExit(); }
144 });
145 }
146
147 protected void
148 onOk() { onApply(); }
149
150 protected void
151 onCancel() { onExit(); }
152
153 private void
154 onApply() {
155 genPane.apply();
156 viewPane.apply();
157 channelsPane.apply();
158 consolePane.apply();
159 connectionPane.apply();
160 defaultsPane.apply();
161
162 preferences().setIntProperty("PrefsDlg.tabIndex", tabbedPane.getSelectedIndex());
163
164 setVisible(false);
165 }
166
167 private void
168 onExit() { setVisible(false); }
169 }
170
171 class GeneralPane extends JPanel {
172 private final JCheckBox checkShowLSConsoleWhenRunScript =
173 new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
174
175 private final JCheckBox checkShowVolumesInDecibels =
176 new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));
177
178 private final JSGeneralProps.PolyphonyPane polyphonyPane = new JSGeneralProps.PolyphonyPane();
179
180 private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
181 new JSGeneralProps.JSamplerHomePane();
182
183 private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
184
185 private final JButton btnAdvanced = new JButton(i18n.getButtonLabel("GeneralPane.btnAdvanced"));
186
187 private final Dialog owner;
188
189 public
190 GeneralPane(Dialog owner) {
191 this.owner = owner;
192
193 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
194
195 checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
196
197 boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
198 checkShowLSConsoleWhenRunScript.setSelected(b);
199
200 add(checkShowLSConsoleWhenRunScript);
201
202 add(Box.createRigidArea(new Dimension(0, 6)));
203
204 b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
205 checkShowVolumesInDecibels.setSelected(b);
206
207 add(checkShowVolumesInDecibels);
208
209 add(Box.createRigidArea(new Dimension(0, 6)));
210
211 add(polyphonyPane);
212
213 add(Box.createRigidArea(new Dimension(0, 6)));
214
215 add(jSamplerHomePane);
216
217 add(Box.createRigidArea(new Dimension(0, 6)));
218
219 add(recentScriptsPane);
220
221 add(Box.createRigidArea(new Dimension(0, 6)));
222
223 JPanel p = new JPanel();
224 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
225
226 JPanel p2 = new JPanel();
227 p2.setLayout(new BorderLayout());
228 p.add(p2);
229 p.add(btnAdvanced);
230 p.setAlignmentX(JPanel.LEFT_ALIGNMENT);
231 add(p);
232
233 add(Box.createGlue());
234
235 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
236
237 btnAdvanced.addActionListener(new ActionListener() {
238 public void
239 actionPerformed(ActionEvent e) { showAdvancedProperties(); }
240 });
241 }
242
243 private void
244 showAdvancedProperties() {
245 new JSAdvancedGeneralPropsDlg(owner).setVisible(true);
246 }
247
248 protected void
249 apply() {
250 polyphonyPane.apply();
251
252 boolean b = checkShowLSConsoleWhenRunScript.isSelected();
253 preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
254
255 b = checkShowVolumesInDecibels.isSelected();
256 preferences().setBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL, b);
257
258 int size = recentScriptsPane.getRecentScriptsSize();
259 preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
260 ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
261
262 String s = jSamplerHomePane.getJSamplerHome();
263 if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
264 CC.changeJSamplerHome(s);
265 }
266 }
267
268 private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
269 protected void
270 clearRecentScripts() {
271 ((MainFrame)CC.getMainFrame()).clearRecentScripts();
272 }
273 }
274 }
275
276 class ViewPane extends JPanel {
277 private final JCheckBox checkTurnOffAnimationEffects =
278 new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
279
280 private final JCheckBox checkTurnOffCustomWindowDecoration =
281 new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
282
283 private final JCheckBox checkShowInstrumentsDb =
284 new JCheckBox(i18n.getLabel("ViewPane.checkShowInstrumentsDb"));
285
286 private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
287 private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
288
289 private final JSViewProps.ConfirmationMessagesPane confirmationMessagesPane =
290 new JSViewProps.ConfirmationMessagesPane();
291
292 ViewPane() {
293 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
294
295 checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);
296
297 boolean b = !preferences().getBoolProperty(ANIMATED);
298 checkTurnOffAnimationEffects.setSelected(b);
299
300 add(checkTurnOffAnimationEffects);
301
302 add(Box.createRigidArea(new Dimension(0, 6)));
303
304 b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
305 checkTurnOffCustomWindowDecoration.setSelected(b);
306 checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
307 add(checkTurnOffCustomWindowDecoration);
308 add(Box.createRigidArea(new Dimension(0, 6)));
309
310 b = preferences().getBoolProperty("rightSidePane.showInstrumentsDb");
311 checkShowInstrumentsDb.setSelected(b);
312 checkShowInstrumentsDb.setAlignmentX(JPanel.LEFT_ALIGNMENT);
313 add(checkShowInstrumentsDb);
314 add(Box.createRigidArea(new Dimension(0, 6)));
315
316 add(midiDevsPane);
317 add(audioDevsPane);
318 add(confirmationMessagesPane);
319 }
320
321 protected void
322 apply() {
323 boolean b = !checkTurnOffAnimationEffects.isSelected();
324 preferences().setBoolProperty(ANIMATED, b);
325
326 String s = "TurnOffCustomWindowDecoration";
327 preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
328
329 s = "rightSidePane.showInstrumentsDb";
330 preferences().setBoolProperty(s, checkShowInstrumentsDb.isSelected());
331
332 midiDevsPane.apply();
333 audioDevsPane.apply();
334 confirmationMessagesPane.apply();
335 }
336 }
337
338 class ChannelsPropsPane extends JPanel {
339 private final JCheckBox checkShowChannelNumbering =
340 new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowChannelNumbering"));
341
342 private final JCheckBox checkShowMidiInfo =
343 new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowMidiInfo"));
344
345 private final JCheckBox checkShowStreamVoiceCount =
346 new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowStreamVoiceCount"));
347
348 ChannelsPropsPane() {
349 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
350
351 add(createSmallViewPane());
352 JPanel p = new JPanel();
353 p.setLayout(new BorderLayout());
354 add(p);
355 }
356
357 protected void
358 apply() {
359 boolean b = checkShowChannelNumbering.isSelected();
360 preferences().setBoolProperty("channel.smallView.showChannelNumbering", b);
361
362 b = checkShowMidiInfo.isSelected();
363 preferences().setBoolProperty("channel.smallView.showMidiInfo", b);
364
365 b = checkShowStreamVoiceCount.isSelected();
366 preferences().setBoolProperty("channel.smallView.showStreamVoiceCount", b);
367 }
368
369 private JPanel
370 createSmallViewPane() {
371 JPanel p = new JPanel();
372 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
373
374 boolean b = preferences().getBoolProperty("channel.smallView.showChannelNumbering");
375 checkShowChannelNumbering.setSelected(b);
376 checkShowChannelNumbering.setAlignmentX(LEFT_ALIGNMENT);
377 p.add(checkShowChannelNumbering);
378
379 b = preferences().getBoolProperty("channel.smallView.showMidiInfo");
380 checkShowMidiInfo.setSelected(b);
381 checkShowMidiInfo.setAlignmentX(LEFT_ALIGNMENT);
382 p.add(checkShowMidiInfo);
383
384 b = preferences().getBoolProperty("channel.smallView.showStreamVoiceCount");
385 checkShowStreamVoiceCount.setSelected(b);
386 checkShowStreamVoiceCount.setAlignmentX(LEFT_ALIGNMENT);
387 p.add(checkShowStreamVoiceCount);
388
389 String s = i18n.getLabel("ChannelsPropsPane.smallView");
390 p.setBorder(BorderFactory.createTitledBorder(s));
391 p.setMaximumSize(new Dimension(Short.MAX_VALUE, p.getPreferredSize().height));
392
393 return p;
394 }
395 }
396
397 class ConsolePane extends JSLSConsolePropsPane {
398 protected void
399 clearConsoleHistory() {
400 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
401 mainFrame.getLSConsoleModel().clearCommandHistory();
402 }
403
404 protected void
405 apply() {
406 super.apply();
407
408 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
409
410 LSConsoleModel model = mainFrame.getLSConsoleModel();
411 model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
412
413 LSConsolePane console = mainFrame.getLSConsolePane();
414
415 int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
416 console.setTextColor(new Color(c));
417
418 c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
419 console.setBackgroundColor(new Color(c));
420
421 c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
422 console.setNotifyColor(new Color(c));
423
424 c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
425 console.setWarningColor(new Color(c));
426
427 c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
428 console.setErrorColor(new Color(c));
429 }
430 }

  ViewVC Help
Powered by ViewVC