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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1872 - (hide annotations) (download)
Mon Mar 23 15:34:50 2009 UTC (15 years, 1 month ago) by iliev
File size: 15042 byte(s)
* Variable number of channel lanes
  (choose Edit/Preferences, then click the `Channels' tab)

1 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 1871 * Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5 iliev 1286 *
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 iliev 1767 import java.awt.Dialog;
28 iliev 1286 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 iliev 1872 import javax.swing.JLabel;
40 iliev 1286 import javax.swing.JPanel;
41 iliev 1872 import javax.swing.JSpinner;
42 iliev 1286 import javax.swing.JTabbedPane;
43 iliev 1872 import javax.swing.SpinnerNumberModel;
44 iliev 1286
45     import net.sf.juife.EnhancedDialog;
46     import net.sf.juife.JuifeUtils;
47    
48     import org.jsampler.CC;
49     import org.jsampler.LSConsoleModel;
50    
51 iliev 1767 import org.jsampler.view.std.JSAdvancedGeneralPropsDlg;
52 iliev 1286 import org.jsampler.view.std.JSConnectionPropsPane;
53 iliev 1313 import org.jsampler.view.std.JSDefaultsPropsPane;
54 iliev 1286 import org.jsampler.view.std.JSGeneralProps;
55     import org.jsampler.view.std.JSLSConsolePropsPane;
56 iliev 1357 import org.jsampler.view.std.JSViewProps;
57 iliev 1286
58     import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
59     import static org.jsampler.view.fantasia.FantasiaPrefs.*;
60    
61    
62     /**
63     *
64     * @author Grigor Iliev
65     */
66     public class PrefsDlg extends EnhancedDialog {
67 iliev 1743 private final JTabbedPane tabbedPane = new JTabbedPane();
68    
69 iliev 1767 private final GeneralPane genPane = new GeneralPane(this);
70 iliev 1357 private final ViewPane viewPane = new ViewPane();
71 iliev 1743 private final ChannelsPropsPane channelsPane = new ChannelsPropsPane();
72 iliev 1286 private final ConsolePane consolePane = new ConsolePane();
73     private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
74 iliev 1313 private final JSDefaultsPropsPane defaultsPane;
75 iliev 1286
76     private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
77     private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));
78    
79    
80     /** Creates a new instance of <code>PrefsDlg</code> */
81     public
82 iliev 1688 PrefsDlg(Frame owner) {
83 iliev 1286 super(owner, i18n.getLabel("PrefsDlg.title"), true);
84    
85 iliev 1732 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16, true);
86 iliev 1313
87 iliev 1743 JTabbedPane tp = tabbedPane;
88     tp.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
89    
90 iliev 1286 tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
91 iliev 1357 tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
92 iliev 1743 tp.addTab(i18n.getLabel("PrefsDlg.tabChannels"), channelsPane);
93 iliev 1286 tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
94    
95     JPanel p = new JPanel();
96     p.setLayout(new BorderLayout());
97     p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
98 iliev 1688 p.add(connectionPane);
99     tp.addTab(i18n.getLabel("PrefsDlg.tabBackend"), p);
100 iliev 1313 tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
101 iliev 1286
102     tp.setAlignmentX(RIGHT_ALIGNMENT);
103    
104     // Set preferred size for Apply & Exit buttons
105     Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose);
106     btnApply.setPreferredSize(d);
107     btnClose.setPreferredSize(d);
108    
109     JPanel btnPane = new JPanel();
110     btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS));
111     btnPane.add(btnApply);
112     btnPane.add(Box.createRigidArea(new Dimension(5, 0)));
113     btnPane.add(btnClose);
114     btnPane.setAlignmentX(RIGHT_ALIGNMENT);
115    
116     JPanel mainPane = new JPanel();
117     mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
118     mainPane.add(tp);
119     mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
120     mainPane.add(btnPane);
121     mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12));
122    
123     getContentPane().add(mainPane);
124    
125     pack();
126     setResizable(false);
127     setLocation(JuifeUtils.centerLocation(this, owner));
128    
129     installListeners();
130 iliev 1743
131     int i = preferences().getIntProperty("PrefsDlg.tabIndex");
132    
133     if(i >= 0 && i < tp.getTabCount()) tp.setSelectedIndex(i);
134 iliev 1286 }
135    
136     private void
137     installListeners() {
138     btnApply.addActionListener(new ActionListener() {
139     public void
140     actionPerformed(ActionEvent e) { onApply(); }
141     });
142    
143     btnClose.addActionListener(new ActionListener() {
144     public void
145     actionPerformed(ActionEvent e) { onExit(); }
146     });
147     }
148    
149     protected void
150     onOk() { onApply(); }
151    
152     protected void
153     onCancel() { onExit(); }
154    
155     private void
156     onApply() {
157     genPane.apply();
158 iliev 1357 viewPane.apply();
159 iliev 1743 channelsPane.apply();
160 iliev 1286 consolePane.apply();
161     connectionPane.apply();
162 iliev 1313 defaultsPane.apply();
163 iliev 1286
164 iliev 1743 preferences().setIntProperty("PrefsDlg.tabIndex", tabbedPane.getSelectedIndex());
165    
166 iliev 1286 setVisible(false);
167     }
168    
169     private void
170     onExit() { setVisible(false); }
171     }
172    
173     class GeneralPane extends JPanel {
174     private final JCheckBox checkShowLSConsoleWhenRunScript =
175     new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
176    
177 iliev 1540 private final JCheckBox checkShowVolumesInDecibels =
178     new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));
179    
180 iliev 1818 private final JSGeneralProps.PolyphonyPane polyphonyPane = new JSGeneralProps.PolyphonyPane();
181 iliev 1357
182 iliev 1286 private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
183     new JSGeneralProps.JSamplerHomePane();
184    
185     private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
186    
187 iliev 1767 private final JButton btnAdvanced = new JButton(i18n.getButtonLabel("GeneralPane.btnAdvanced"));
188    
189     private final Dialog owner;
190    
191 iliev 1286 public
192 iliev 1767 GeneralPane(Dialog owner) {
193     this.owner = owner;
194    
195 iliev 1286 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
196    
197     checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
198    
199 iliev 1767 boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
200 iliev 1286 checkShowLSConsoleWhenRunScript.setSelected(b);
201    
202     add(checkShowLSConsoleWhenRunScript);
203    
204     add(Box.createRigidArea(new Dimension(0, 6)));
205    
206 iliev 1540 b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
207     checkShowVolumesInDecibels.setSelected(b);
208    
209     add(checkShowVolumesInDecibels);
210    
211     add(Box.createRigidArea(new Dimension(0, 6)));
212    
213 iliev 1818 add(polyphonyPane);
214 iliev 1357
215     add(Box.createRigidArea(new Dimension(0, 6)));
216    
217 iliev 1286 add(jSamplerHomePane);
218    
219     add(Box.createRigidArea(new Dimension(0, 6)));
220    
221     add(recentScriptsPane);
222 iliev 1767
223     add(Box.createRigidArea(new Dimension(0, 6)));
224    
225     JPanel p = new JPanel();
226     p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
227    
228     JPanel p2 = new JPanel();
229     p2.setLayout(new BorderLayout());
230     p.add(p2);
231     p.add(btnAdvanced);
232     p.setAlignmentX(JPanel.LEFT_ALIGNMENT);
233     add(p);
234    
235 iliev 1286 add(Box.createGlue());
236    
237     setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
238    
239 iliev 1767 btnAdvanced.addActionListener(new ActionListener() {
240     public void
241     actionPerformed(ActionEvent e) { showAdvancedProperties(); }
242     });
243 iliev 1286 }
244    
245 iliev 1767 private void
246     showAdvancedProperties() {
247     new JSAdvancedGeneralPropsDlg(owner).setVisible(true);
248     }
249    
250 iliev 1286 protected void
251     apply() {
252 iliev 1818 polyphonyPane.apply();
253 iliev 1357
254 iliev 1767 boolean b = checkShowLSConsoleWhenRunScript.isSelected();
255 iliev 1286 preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
256    
257 iliev 1540 b = checkShowVolumesInDecibels.isSelected();
258     preferences().setBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL, b);
259    
260 iliev 1286 int size = recentScriptsPane.getRecentScriptsSize();
261     preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
262     ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
263    
264     String s = jSamplerHomePane.getJSamplerHome();
265     if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
266     CC.changeJSamplerHome(s);
267     }
268     }
269    
270     private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
271     protected void
272     clearRecentScripts() {
273     ((MainFrame)CC.getMainFrame()).clearRecentScripts();
274     }
275     }
276     }
277    
278 iliev 1357 class ViewPane extends JPanel {
279 iliev 1767 private final JCheckBox checkTurnOffAnimationEffects =
280     new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
281    
282 iliev 1496 private final JCheckBox checkTurnOffCustomWindowDecoration =
283     new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
284    
285 iliev 1729 private final JCheckBox checkShowInstrumentsDb =
286     new JCheckBox(i18n.getLabel("ViewPane.checkShowInstrumentsDb"));
287    
288 iliev 1871 private final JCheckBox checkUseNativeFileChoosers =
289     new JCheckBox(i18n.getLabel("ViewPane.checkUseNativeFileChoosers"));
290    
291 iliev 1357 private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
292     private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
293    
294 iliev 1688 private final JSViewProps.ConfirmationMessagesPane confirmationMessagesPane =
295     new JSViewProps.ConfirmationMessagesPane();
296    
297 iliev 1357 ViewPane() {
298     setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
299 iliev 1496
300 iliev 1767 checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);
301    
302     boolean b = !preferences().getBoolProperty(ANIMATED);
303     checkTurnOffAnimationEffects.setSelected(b);
304    
305     add(checkTurnOffAnimationEffects);
306    
307     add(Box.createRigidArea(new Dimension(0, 6)));
308    
309     b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
310 iliev 1496 checkTurnOffCustomWindowDecoration.setSelected(b);
311     checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
312     add(checkTurnOffCustomWindowDecoration);
313     add(Box.createRigidArea(new Dimension(0, 6)));
314 iliev 1729
315     b = preferences().getBoolProperty("rightSidePane.showInstrumentsDb");
316     checkShowInstrumentsDb.setSelected(b);
317     checkShowInstrumentsDb.setAlignmentX(JPanel.LEFT_ALIGNMENT);
318     add(checkShowInstrumentsDb);
319     add(Box.createRigidArea(new Dimension(0, 6)));
320 iliev 1871
321     b = preferences().getBoolProperty("nativeFileChoosers");
322     checkUseNativeFileChoosers.setSelected(b);
323     checkUseNativeFileChoosers.setAlignmentX(JPanel.LEFT_ALIGNMENT);
324     add(checkUseNativeFileChoosers);
325     add(Box.createRigidArea(new Dimension(0, 6)));
326 iliev 1729
327 iliev 1357 add(midiDevsPane);
328     add(audioDevsPane);
329 iliev 1688 add(confirmationMessagesPane);
330 iliev 1357 }
331    
332     protected void
333     apply() {
334 iliev 1767 boolean b = !checkTurnOffAnimationEffects.isSelected();
335     preferences().setBoolProperty(ANIMATED, b);
336    
337 iliev 1496 String s = "TurnOffCustomWindowDecoration";
338     preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
339    
340 iliev 1729 s = "rightSidePane.showInstrumentsDb";
341     preferences().setBoolProperty(s, checkShowInstrumentsDb.isSelected());
342    
343 iliev 1871 s = "nativeFileChoosers";
344     preferences().setBoolProperty(s, checkUseNativeFileChoosers.isSelected());
345    
346 iliev 1357 midiDevsPane.apply();
347     audioDevsPane.apply();
348 iliev 1688 confirmationMessagesPane.apply();
349 iliev 1357 }
350     }
351    
352 iliev 1743 class ChannelsPropsPane extends JPanel {
353     private final JCheckBox checkShowChannelNumbering =
354     new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowChannelNumbering"));
355    
356     private final JCheckBox checkShowMidiInfo =
357     new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowMidiInfo"));
358    
359 iliev 1767 private final JCheckBox checkShowStreamVoiceCount =
360     new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowStreamVoiceCount"));
361 iliev 1872
362     private final JLabel lChannelLaneNumber =
363     new JLabel(i18n.getLabel("ChannelsPropsPane.lChannelLaneNumber"));
364    
365     private JSpinner spChannelLaneNumber;
366 iliev 1767
367 iliev 1743 ChannelsPropsPane() {
368     setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
369    
370 iliev 1872 add(createChannelLanesPane());
371 iliev 1743 add(createSmallViewPane());
372 iliev 1872
373 iliev 1743 JPanel p = new JPanel();
374     p.setLayout(new BorderLayout());
375     add(p);
376     }
377    
378     protected void
379     apply() {
380     boolean b = checkShowChannelNumbering.isSelected();
381     preferences().setBoolProperty("channel.smallView.showChannelNumbering", b);
382    
383     b = checkShowMidiInfo.isSelected();
384     preferences().setBoolProperty("channel.smallView.showMidiInfo", b);
385 iliev 1767
386     b = checkShowStreamVoiceCount.isSelected();
387     preferences().setBoolProperty("channel.smallView.showStreamVoiceCount", b);
388 iliev 1872
389     int i = Integer.parseInt(spChannelLaneNumber.getValue().toString());
390     preferences().setIntProperty("channelLanes.count", i);
391 iliev 1743 }
392    
393     private JPanel
394     createSmallViewPane() {
395     JPanel p = new JPanel();
396     p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
397    
398     boolean b = preferences().getBoolProperty("channel.smallView.showChannelNumbering");
399     checkShowChannelNumbering.setSelected(b);
400     checkShowChannelNumbering.setAlignmentX(LEFT_ALIGNMENT);
401     p.add(checkShowChannelNumbering);
402    
403     b = preferences().getBoolProperty("channel.smallView.showMidiInfo");
404     checkShowMidiInfo.setSelected(b);
405     checkShowMidiInfo.setAlignmentX(LEFT_ALIGNMENT);
406     p.add(checkShowMidiInfo);
407    
408 iliev 1767 b = preferences().getBoolProperty("channel.smallView.showStreamVoiceCount");
409     checkShowStreamVoiceCount.setSelected(b);
410     checkShowStreamVoiceCount.setAlignmentX(LEFT_ALIGNMENT);
411     p.add(checkShowStreamVoiceCount);
412    
413 iliev 1743 String s = i18n.getLabel("ChannelsPropsPane.smallView");
414     p.setBorder(BorderFactory.createTitledBorder(s));
415     p.setMaximumSize(new Dimension(Short.MAX_VALUE, p.getPreferredSize().height));
416    
417     return p;
418     }
419 iliev 1872
420     private JPanel
421     createChannelLanesPane() {
422     int max = MainFrame.MAX_CHANNEL_LANE_NUMBER;
423    
424     int i = preferences().getIntProperty("channelLanes.count");
425     if(i < 1 || i > max) i = max;
426     spChannelLaneNumber = new JSpinner(new SpinnerNumberModel(i, 1, max, 1));
427    
428     JPanel p = new JPanel();
429     p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
430     p.add(lChannelLaneNumber);
431     p.add(Box.createRigidArea(new Dimension(5, 0)));
432     p.add(spChannelLaneNumber);
433     p.setAlignmentX(LEFT_ALIGNMENT);
434     p.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
435    
436     JPanel p2 = new JPanel();
437     p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
438     String s = i18n.getLabel("ChannelsPropsPane.channelLanes");
439     p2.setBorder(BorderFactory.createTitledBorder(s));
440     p2.setMaximumSize(new Dimension(Short.MAX_VALUE, p.getPreferredSize().height));
441     p2.add(p);
442     p2.setAlignmentX(LEFT_ALIGNMENT);
443    
444     return p2;
445     }
446 iliev 1743 }
447    
448 iliev 1286 class ConsolePane extends JSLSConsolePropsPane {
449     protected void
450     clearConsoleHistory() {
451     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
452     mainFrame.getLSConsoleModel().clearCommandHistory();
453     }
454    
455     protected void
456     apply() {
457     super.apply();
458    
459     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
460    
461     LSConsoleModel model = mainFrame.getLSConsoleModel();
462     model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
463    
464     LSConsolePane console = mainFrame.getLSConsolePane();
465    
466     int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
467     console.setTextColor(new Color(c));
468    
469     c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
470     console.setBackgroundColor(new Color(c));
471    
472     c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
473     console.setNotifyColor(new Color(c));
474    
475     c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
476     console.setWarningColor(new Color(c));
477    
478     c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
479     console.setErrorColor(new Color(c));
480     }
481     }

  ViewVC Help
Powered by ViewVC