/[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 1496 - (show annotations) (download)
Mon Nov 19 22:22:22 2007 UTC (16 years, 5 months ago) by iliev
File size: 8989 byte(s)
* Added option for turning off the custom window decoration
  (choose Edit/Preferences, then click the `View' tab)
* Added new menu item: Help/Online Tutorial
* Fantasia: first step of implementing a theme manager
* Fantasia: fixed the view of the channel's stream/voice count statistic
* some minor GUI fixes and enhancements

1 /*
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 import org.jsampler.view.std.JSDefaultsPropsPane;
50 import org.jsampler.view.std.JSGeneralProps;
51 import org.jsampler.view.std.JSLSConsolePropsPane;
52 import org.jsampler.view.std.JSViewProps;
53
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 private final ViewPane viewPane = new ViewPane();
65 private final ConsolePane consolePane = new ConsolePane();
66 private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
67 private final JSDefaultsPropsPane defaultsPane;
68
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 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16);
79
80 JTabbedPane tp = new JTabbedPane();
81 tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
82 tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
83 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 tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
91
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 viewPane.apply();
148 consolePane.apply();
149 connectionPane.apply();
150 defaultsPane.apply();
151
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 private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane();
167
168 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 add(maxVolPane);
196
197 add(Box.createRigidArea(new Dimension(0, 6)));
198
199 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 maxVolPane.apply();
214
215 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 class ViewPane extends JPanel {
240 private final JCheckBox checkTurnOffCustomWindowDecoration =
241 new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
242
243 private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
244 private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
245
246 ViewPane() {
247 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
248
249 boolean b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
250 checkTurnOffCustomWindowDecoration.setSelected(b);
251 checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
252 add(checkTurnOffCustomWindowDecoration);
253 add(Box.createRigidArea(new Dimension(0, 6)));
254 add(midiDevsPane);
255 add(audioDevsPane);
256 }
257
258 protected void
259 apply() {
260 String s = "TurnOffCustomWindowDecoration";
261 preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
262
263 midiDevsPane.apply();
264 audioDevsPane.apply();
265 }
266 }
267
268 class ConsolePane extends JSLSConsolePropsPane {
269 protected void
270 clearConsoleHistory() {
271 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
272 mainFrame.getLSConsoleModel().clearCommandHistory();
273 }
274
275 protected void
276 apply() {
277 super.apply();
278
279 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
280
281 LSConsoleModel model = mainFrame.getLSConsoleModel();
282 model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
283
284 LSConsolePane console = mainFrame.getLSConsolePane();
285
286 int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
287 console.setTextColor(new Color(c));
288
289 c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
290 console.setBackgroundColor(new Color(c));
291
292 c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
293 console.setNotifyColor(new Color(c));
294
295 c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
296 console.setWarningColor(new Color(c));
297
298 c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
299 console.setErrorColor(new Color(c));
300 }
301 }

  ViewVC Help
Powered by ViewVC