/[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 1732 - (hide annotations) (download)
Sat May 3 01:40:06 2008 UTC (16 years ago) by iliev
File size: 9999 byte(s)
* Fantasia: Implemented Small View for sampler channels
  (right-click on the sampler channel then choose Small View)
* Fantasia: Implemented option to choose default sampler channel view
  (choose Edit/Preferences, then click the `Defaults' tab)
* Fantasia: Added context menu to sampler channels

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 iliev 1688 PrefsDlg(Frame owner) {
76 iliev 1286 super(owner, i18n.getLabel("PrefsDlg.title"), true);
77    
78 iliev 1732 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16, true);
79 iliev 1313
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 iliev 1688 p.add(connectionPane);
89     tp.addTab(i18n.getLabel("PrefsDlg.tabBackend"), 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    
122     private void
123     installListeners() {
124     btnApply.addActionListener(new ActionListener() {
125     public void
126     actionPerformed(ActionEvent e) { onApply(); }
127     });
128    
129     btnClose.addActionListener(new ActionListener() {
130     public void
131     actionPerformed(ActionEvent e) { onExit(); }
132     });
133     }
134    
135     protected void
136     onOk() { onApply(); }
137    
138     protected void
139     onCancel() { onExit(); }
140    
141     private void
142     onApply() {
143     genPane.apply();
144 iliev 1357 viewPane.apply();
145 iliev 1286 consolePane.apply();
146     connectionPane.apply();
147 iliev 1313 defaultsPane.apply();
148 iliev 1286
149     setVisible(false);
150     }
151    
152     private void
153     onExit() { setVisible(false); }
154     }
155    
156     class GeneralPane extends JPanel {
157     private final JCheckBox checkTurnOffAnimationEffects =
158     new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
159    
160     private final JCheckBox checkShowLSConsoleWhenRunScript =
161     new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
162    
163 iliev 1540 private final JCheckBox checkShowVolumesInDecibels =
164     new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));
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 1540 b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
196     checkShowVolumesInDecibels.setSelected(b);
197    
198     add(checkShowVolumesInDecibels);
199    
200     add(Box.createRigidArea(new Dimension(0, 6)));
201    
202 iliev 1357 add(maxVolPane);
203    
204     add(Box.createRigidArea(new Dimension(0, 6)));
205    
206 iliev 1286 add(jSamplerHomePane);
207    
208     add(Box.createRigidArea(new Dimension(0, 6)));
209    
210     add(recentScriptsPane);
211     add(Box.createGlue());
212    
213     setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
214    
215    
216     }
217    
218     protected void
219     apply() {
220 iliev 1357 maxVolPane.apply();
221    
222 iliev 1286 boolean b = !checkTurnOffAnimationEffects.isSelected();
223     preferences().setBoolProperty(ANIMATED, b);
224    
225     b = checkShowLSConsoleWhenRunScript.isSelected();
226     preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
227    
228 iliev 1540 b = checkShowVolumesInDecibels.isSelected();
229     preferences().setBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL, b);
230    
231 iliev 1286 int size = recentScriptsPane.getRecentScriptsSize();
232     preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
233     ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
234    
235     String s = jSamplerHomePane.getJSamplerHome();
236     if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
237     CC.changeJSamplerHome(s);
238     }
239     }
240    
241     private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
242     protected void
243     clearRecentScripts() {
244     ((MainFrame)CC.getMainFrame()).clearRecentScripts();
245     }
246     }
247     }
248    
249 iliev 1357 class ViewPane extends JPanel {
250 iliev 1496 private final JCheckBox checkTurnOffCustomWindowDecoration =
251     new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
252    
253 iliev 1729 private final JCheckBox checkShowInstrumentsDb =
254     new JCheckBox(i18n.getLabel("ViewPane.checkShowInstrumentsDb"));
255    
256 iliev 1357 private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
257     private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
258    
259 iliev 1688 private final JSViewProps.ConfirmationMessagesPane confirmationMessagesPane =
260     new JSViewProps.ConfirmationMessagesPane();
261    
262 iliev 1357 ViewPane() {
263     setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
264 iliev 1496
265     boolean b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
266     checkTurnOffCustomWindowDecoration.setSelected(b);
267     checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
268     add(checkTurnOffCustomWindowDecoration);
269     add(Box.createRigidArea(new Dimension(0, 6)));
270 iliev 1729
271     b = preferences().getBoolProperty("rightSidePane.showInstrumentsDb");
272     checkShowInstrumentsDb.setSelected(b);
273     checkShowInstrumentsDb.setAlignmentX(JPanel.LEFT_ALIGNMENT);
274     add(checkShowInstrumentsDb);
275     add(Box.createRigidArea(new Dimension(0, 6)));
276    
277 iliev 1357 add(midiDevsPane);
278     add(audioDevsPane);
279 iliev 1688 add(confirmationMessagesPane);
280 iliev 1357 }
281    
282     protected void
283     apply() {
284 iliev 1496 String s = "TurnOffCustomWindowDecoration";
285     preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
286    
287 iliev 1729 s = "rightSidePane.showInstrumentsDb";
288     preferences().setBoolProperty(s, checkShowInstrumentsDb.isSelected());
289    
290 iliev 1357 midiDevsPane.apply();
291     audioDevsPane.apply();
292 iliev 1688 confirmationMessagesPane.apply();
293 iliev 1357 }
294     }
295    
296 iliev 1286 class ConsolePane extends JSLSConsolePropsPane {
297     protected void
298     clearConsoleHistory() {
299     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
300     mainFrame.getLSConsoleModel().clearCommandHistory();
301     }
302    
303     protected void
304     apply() {
305     super.apply();
306    
307     MainFrame mainFrame = (MainFrame)CC.getMainFrame();
308    
309     LSConsoleModel model = mainFrame.getLSConsoleModel();
310     model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
311    
312     LSConsolePane console = mainFrame.getLSConsolePane();
313    
314     int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
315     console.setTextColor(new Color(c));
316    
317     c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
318     console.setBackgroundColor(new Color(c));
319    
320     c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
321     console.setNotifyColor(new Color(c));
322    
323     c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
324     console.setWarningColor(new Color(c));
325    
326     c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
327     console.setErrorColor(new Color(c));
328     }
329     }

  ViewVC Help
Powered by ViewVC