/[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 1357 - (hide annotations) (download)
Sat Sep 22 17:27:06 2007 UTC (16 years, 7 months ago) by iliev
File size: 8411 byte(s)
* Added options for setting the maximum master and channel volume
  (choose Edit/Preferences)
* Fantasia: Edit instrument button is now shown on the channel
  screen only when there is loaded instrument on that channel
* Fantasia: Added options for showing additional device parameters in
  audio/MIDI device panes (Edit/Preferences, then click the `View' tab)
* Fantasia: Master volume is now fully implemented

1 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4     * Copyright (C) 2005-2007 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.Dimension;
28     import java.awt.Frame;
29    
30     import java.awt.event.ActionEvent;
31     import java.awt.event.ActionListener;
32    
33     import javax.swing.BorderFactory;
34     import javax.swing.Box;
35     import javax.swing.BoxLayout;
36     import javax.swing.JButton;
37     import javax.swing.JCheckBox;
38     import javax.swing.JPanel;
39     import javax.swing.JTabbedPane;
40    
41     import net.sf.juife.EnhancedDialog;
42     import net.sf.juife.JuifeUtils;
43    
44     import org.jsampler.CC;
45     import org.jsampler.LSConsoleModel;
46     import org.jsampler.Prefs;
47    
48     import org.jsampler.view.std.JSConnectionPropsPane;
49 iliev 1313 import org.jsampler.view.std.JSDefaultsPropsPane;
50 iliev 1286 import org.jsampler.view.std.JSGeneralProps;
51     import org.jsampler.view.std.JSLSConsolePropsPane;
52 iliev 1357 import org.jsampler.view.std.JSViewProps;
53 iliev 1286
54     import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
55     import static org.jsampler.view.fantasia.FantasiaPrefs.*;
56    
57    
58     /**
59     *
60     * @author Grigor Iliev
61     */
62     public class PrefsDlg extends EnhancedDialog {
63     private final GeneralPane genPane = new GeneralPane();
64 iliev 1357 private final ViewPane viewPane = new ViewPane();
65 iliev 1286 private final ConsolePane consolePane = new ConsolePane();
66     private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
67 iliev 1313 private final JSDefaultsPropsPane defaultsPane;
68 iliev 1286
69     private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
70     private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));
71    
72    
73     /** Creates a new instance of <code>PrefsDlg</code> */
74     public
75     PrefsDlg(Frame owner) {
76     super(owner, i18n.getLabel("PrefsDlg.title"), true);
77    
78 iliev 1313 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16);
79    
80 iliev 1286 JTabbedPane tp = new JTabbedPane();
81     tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
82 iliev 1357 tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
83 iliev 1286 tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
84    
85     JPanel p = new JPanel();
86     p.setLayout(new BorderLayout());
87     p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
88     p.add(connectionPane, BorderLayout.NORTH);
89     tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), p);
90 iliev 1313 tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
91 iliev 1286
92     tp.setAlignmentX(RIGHT_ALIGNMENT);
93    
94     // Set preferred size for Apply & Exit buttons
95     Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose);
96     btnApply.setPreferredSize(d);
97     btnClose.setPreferredSize(d);
98    
99     JPanel btnPane = new JPanel();
100     btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS));
101     btnPane.add(btnApply);
102     btnPane.add(Box.createRigidArea(new Dimension(5, 0)));
103     btnPane.add(btnClose);
104     btnPane.setAlignmentX(RIGHT_ALIGNMENT);
105    
106     JPanel mainPane = new JPanel();
107     mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
108     mainPane.add(tp);
109     mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
110     mainPane.add(btnPane);
111     mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12));
112    
113     getContentPane().add(mainPane);
114    
115     pack();
116     setResizable(false);
117     setLocation(JuifeUtils.centerLocation(this, owner));
118    
119     installListeners();
120    
121     connectionPane.setLSAddress(Prefs.getLSAddress());
122     connectionPane.setLSPort(String.valueOf(Prefs.getLSPort()));
123     }
124    
125     private void
126     installListeners() {
127     btnApply.addActionListener(new ActionListener() {
128     public void
129     actionPerformed(ActionEvent e) { onApply(); }
130     });
131    
132     btnClose.addActionListener(new ActionListener() {
133     public void
134     actionPerformed(ActionEvent e) { onExit(); }
135     });
136     }
137    
138     protected void
139     onOk() { onApply(); }
140    
141     protected void
142     onCancel() { onExit(); }
143    
144     private void
145     onApply() {
146     genPane.apply();
147 iliev 1357 viewPane.apply();
148 iliev 1286 consolePane.apply();
149     connectionPane.apply();
150 iliev 1313 defaultsPane.apply();
151 iliev 1286
152     setVisible(false);
153     }
154    
155     private void
156     onExit() { setVisible(false); }
157     }
158    
159     class GeneralPane extends JPanel {
160     private final JCheckBox checkTurnOffAnimationEffects =
161     new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
162    
163     private final JCheckBox checkShowLSConsoleWhenRunScript =
164     new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
165    
166 iliev 1357 private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane();
167    
168 iliev 1286 private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
169     new JSGeneralProps.JSamplerHomePane();
170    
171     private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
172    
173     public
174     GeneralPane() {
175     setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
176    
177     checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);
178    
179     boolean b = !preferences().getBoolProperty(ANIMATED);
180     checkTurnOffAnimationEffects.setSelected(b);
181    
182     add(checkTurnOffAnimationEffects);
183    
184     add(Box.createRigidArea(new Dimension(0, 6)));
185    
186     checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
187    
188     b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
189     checkShowLSConsoleWhenRunScript.setSelected(b);
190    
191     add(checkShowLSConsoleWhenRunScript);
192    
193     add(Box.createRigidArea(new Dimension(0, 6)));
194    
195 iliev 1357 add(maxVolPane);
196    
197     add(Box.createRigidArea(new Dimension(0, 6)));
198    
199 iliev 1286 add(jSamplerHomePane);
200    
201     add(Box.createRigidArea(new Dimension(0, 6)));
202    
203     add(recentScriptsPane);
204     add(Box.createGlue());
205    
206     setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
207    
208    
209     }
210    
211     protected void
212     apply() {
213 iliev 1357 maxVolPane.apply();
214    
215 iliev 1286 boolean b = !checkTurnOffAnimationEffects.isSelected();
216     preferences().setBoolProperty(ANIMATED, b);
217    
218     b = checkShowLSConsoleWhenRunScript.isSelected();
219     preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
220    
221     int size = recentScriptsPane.getRecentScriptsSize();
222     preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
223     ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
224    
225     String s = jSamplerHomePane.getJSamplerHome();
226     if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
227     CC.changeJSamplerHome(s);
228     }
229     }
230    
231     private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
232     protected void
233     clearRecentScripts() {
234     ((MainFrame)CC.getMainFrame()).clearRecentScripts();
235     }
236     }
237     }
238    
239 iliev 1357 class ViewPane extends JPanel {
240     private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
241     private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
242    
243     ViewPane() {
244     setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
245     add(midiDevsPane);
246     add(audioDevsPane);
247     }
248    
249     protected void
250     apply() {
251     midiDevsPane.apply();
252     audioDevsPane.apply();
253     }
254     }
255    
256 iliev 1286 class ConsolePane extends JSLSConsolePropsPane {
257     protected void
258     clearConsoleHistory() {
259     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
260     mainFrame.getLSConsoleModel().clearCommandHistory();
261     }
262    
263     protected void
264     apply() {
265     super.apply();
266    
267     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
268    
269     LSConsoleModel model = mainFrame.getLSConsoleModel();
270     model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
271    
272     LSConsolePane console = mainFrame.getLSConsolePane();
273    
274     int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
275     console.setTextColor(new Color(c));
276    
277     c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
278     console.setBackgroundColor(new Color(c));
279    
280     c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
281     console.setNotifyColor(new Color(c));
282    
283     c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
284     console.setWarningColor(new Color(c));
285    
286     c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
287     console.setErrorColor(new Color(c));
288     }
289     }

  ViewVC Help
Powered by ViewVC