/[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 1743 - (show annotations) (download)
Sat May 31 23:04:01 2008 UTC (15 years, 10 months ago) by iliev
File size: 11996 byte(s)
* Renamed the column labels in the Channel Routing dialog: The column
  representing the sampler channel's audio channels is "Audio In" and
  the column representing the audio device's channels is "Audio Out"
* Remember the last used tab in the Preferences dialog
* Fantasia: The sampler channels are now referenced by their position
  in the list, not by their ID
* Fantasia: Implemented options to show the channel number and/or the MIDI
  input port/channel on the sampler channel screen when using Small View
  (choose Edit/Preferences, then click the `Channels' tab)
* Fantasia: Migrated to substance 5

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 JTabbedPane tabbedPane = new JTabbedPane();
64
65 private final GeneralPane genPane = new GeneralPane();
66 private final ViewPane viewPane = new ViewPane();
67 private final ChannelsPropsPane channelsPane = new ChannelsPropsPane();
68 private final ConsolePane consolePane = new ConsolePane();
69 private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
70 private final JSDefaultsPropsPane defaultsPane;
71
72 private final JButton btnApply = new JButton(i18n.getButtonLabel("apply"));
73 private final JButton btnClose = new JButton(i18n.getButtonLabel("close"));
74
75
76 /** Creates a new instance of <code>PrefsDlg</code> */
77 public
78 PrefsDlg(Frame owner) {
79 super(owner, i18n.getLabel("PrefsDlg.title"), true);
80
81 defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16, true);
82
83 JTabbedPane tp = tabbedPane;
84 tp.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
85
86 tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
87 tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
88 tp.addTab(i18n.getLabel("PrefsDlg.tabChannels"), channelsPane);
89 tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
90
91 JPanel p = new JPanel();
92 p.setLayout(new BorderLayout());
93 p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
94 p.add(connectionPane);
95 tp.addTab(i18n.getLabel("PrefsDlg.tabBackend"), p);
96 tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
97
98 tp.setAlignmentX(RIGHT_ALIGNMENT);
99
100 // Set preferred size for Apply & Exit buttons
101 Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose);
102 btnApply.setPreferredSize(d);
103 btnClose.setPreferredSize(d);
104
105 JPanel btnPane = new JPanel();
106 btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS));
107 btnPane.add(btnApply);
108 btnPane.add(Box.createRigidArea(new Dimension(5, 0)));
109 btnPane.add(btnClose);
110 btnPane.setAlignmentX(RIGHT_ALIGNMENT);
111
112 JPanel mainPane = new JPanel();
113 mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
114 mainPane.add(tp);
115 mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
116 mainPane.add(btnPane);
117 mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12));
118
119 getContentPane().add(mainPane);
120
121 pack();
122 setResizable(false);
123 setLocation(JuifeUtils.centerLocation(this, owner));
124
125 installListeners();
126
127 int i = preferences().getIntProperty("PrefsDlg.tabIndex");
128
129 if(i >= 0 && i < tp.getTabCount()) tp.setSelectedIndex(i);
130 }
131
132 private void
133 installListeners() {
134 btnApply.addActionListener(new ActionListener() {
135 public void
136 actionPerformed(ActionEvent e) { onApply(); }
137 });
138
139 btnClose.addActionListener(new ActionListener() {
140 public void
141 actionPerformed(ActionEvent e) { onExit(); }
142 });
143 }
144
145 protected void
146 onOk() { onApply(); }
147
148 protected void
149 onCancel() { onExit(); }
150
151 private void
152 onApply() {
153 genPane.apply();
154 viewPane.apply();
155 channelsPane.apply();
156 consolePane.apply();
157 connectionPane.apply();
158 defaultsPane.apply();
159
160 preferences().setIntProperty("PrefsDlg.tabIndex", tabbedPane.getSelectedIndex());
161
162 setVisible(false);
163 }
164
165 private void
166 onExit() { setVisible(false); }
167 }
168
169 class GeneralPane extends JPanel {
170 private final JCheckBox checkTurnOffAnimationEffects =
171 new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
172
173 private final JCheckBox checkShowLSConsoleWhenRunScript =
174 new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
175
176 private final JCheckBox checkShowVolumesInDecibels =
177 new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));
178
179 private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane();
180
181 private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
182 new JSGeneralProps.JSamplerHomePane();
183
184 private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
185
186 public
187 GeneralPane() {
188 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
189
190 checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);
191
192 boolean b = !preferences().getBoolProperty(ANIMATED);
193 checkTurnOffAnimationEffects.setSelected(b);
194
195 add(checkTurnOffAnimationEffects);
196
197 add(Box.createRigidArea(new Dimension(0, 6)));
198
199 checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
200
201 b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
202 checkShowLSConsoleWhenRunScript.setSelected(b);
203
204 add(checkShowLSConsoleWhenRunScript);
205
206 add(Box.createRigidArea(new Dimension(0, 6)));
207
208 b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL);
209 checkShowVolumesInDecibels.setSelected(b);
210
211 add(checkShowVolumesInDecibels);
212
213 add(Box.createRigidArea(new Dimension(0, 6)));
214
215 add(maxVolPane);
216
217 add(Box.createRigidArea(new Dimension(0, 6)));
218
219 add(jSamplerHomePane);
220
221 add(Box.createRigidArea(new Dimension(0, 6)));
222
223 add(recentScriptsPane);
224 add(Box.createGlue());
225
226 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
227
228
229 }
230
231 protected void
232 apply() {
233 maxVolPane.apply();
234
235 boolean b = !checkTurnOffAnimationEffects.isSelected();
236 preferences().setBoolProperty(ANIMATED, b);
237
238 b = checkShowLSConsoleWhenRunScript.isSelected();
239 preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
240
241 b = checkShowVolumesInDecibels.isSelected();
242 preferences().setBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL, b);
243
244 int size = recentScriptsPane.getRecentScriptsSize();
245 preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size);
246 ((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu();
247
248 String s = jSamplerHomePane.getJSamplerHome();
249 if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) {
250 CC.changeJSamplerHome(s);
251 }
252 }
253
254 private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane {
255 protected void
256 clearRecentScripts() {
257 ((MainFrame)CC.getMainFrame()).clearRecentScripts();
258 }
259 }
260 }
261
262 class ViewPane extends JPanel {
263 private final JCheckBox checkTurnOffCustomWindowDecoration =
264 new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
265
266 private final JCheckBox checkShowInstrumentsDb =
267 new JCheckBox(i18n.getLabel("ViewPane.checkShowInstrumentsDb"));
268
269 private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
270 private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
271
272 private final JSViewProps.ConfirmationMessagesPane confirmationMessagesPane =
273 new JSViewProps.ConfirmationMessagesPane();
274
275 ViewPane() {
276 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
277
278 boolean b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
279 checkTurnOffCustomWindowDecoration.setSelected(b);
280 checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
281 add(checkTurnOffCustomWindowDecoration);
282 add(Box.createRigidArea(new Dimension(0, 6)));
283
284 b = preferences().getBoolProperty("rightSidePane.showInstrumentsDb");
285 checkShowInstrumentsDb.setSelected(b);
286 checkShowInstrumentsDb.setAlignmentX(JPanel.LEFT_ALIGNMENT);
287 add(checkShowInstrumentsDb);
288 add(Box.createRigidArea(new Dimension(0, 6)));
289
290 add(midiDevsPane);
291 add(audioDevsPane);
292 add(confirmationMessagesPane);
293 }
294
295 protected void
296 apply() {
297 String s = "TurnOffCustomWindowDecoration";
298 preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
299
300 s = "rightSidePane.showInstrumentsDb";
301 preferences().setBoolProperty(s, checkShowInstrumentsDb.isSelected());
302
303 midiDevsPane.apply();
304 audioDevsPane.apply();
305 confirmationMessagesPane.apply();
306 }
307 }
308
309 class ChannelsPropsPane extends JPanel {
310 private final JCheckBox checkShowChannelNumbering =
311 new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowChannelNumbering"));
312
313 private final JCheckBox checkShowMidiInfo =
314 new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowMidiInfo"));
315
316 ChannelsPropsPane() {
317 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
318
319 add(createSmallViewPane());
320 JPanel p = new JPanel();
321 p.setLayout(new BorderLayout());
322 add(p);
323 }
324
325 protected void
326 apply() {
327 boolean b = checkShowChannelNumbering.isSelected();
328 preferences().setBoolProperty("channel.smallView.showChannelNumbering", b);
329
330 b = checkShowMidiInfo.isSelected();
331 preferences().setBoolProperty("channel.smallView.showMidiInfo", b);
332 }
333
334 private JPanel
335 createSmallViewPane() {
336 JPanel p = new JPanel();
337 p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
338
339 boolean b = preferences().getBoolProperty("channel.smallView.showChannelNumbering");
340 checkShowChannelNumbering.setSelected(b);
341 checkShowChannelNumbering.setAlignmentX(LEFT_ALIGNMENT);
342 p.add(checkShowChannelNumbering);
343
344 b = preferences().getBoolProperty("channel.smallView.showMidiInfo");
345 checkShowMidiInfo.setSelected(b);
346 checkShowMidiInfo.setAlignmentX(LEFT_ALIGNMENT);
347 p.add(checkShowMidiInfo);
348
349 String s = i18n.getLabel("ChannelsPropsPane.smallView");
350 p.setBorder(BorderFactory.createTitledBorder(s));
351 p.setMaximumSize(new Dimension(Short.MAX_VALUE, p.getPreferredSize().height));
352
353 return p;
354 }
355 }
356
357 class ConsolePane extends JSLSConsolePropsPane {
358 protected void
359 clearConsoleHistory() {
360 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
361 mainFrame.getLSConsoleModel().clearCommandHistory();
362 }
363
364 protected void
365 apply() {
366 super.apply();
367
368 MainFrame mainFrame = (MainFrame)CC.getMainFrame();
369
370 LSConsoleModel model = mainFrame.getLSConsoleModel();
371 model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE));
372
373 LSConsolePane console = mainFrame.getLSConsolePane();
374
375 int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
376 console.setTextColor(new Color(c));
377
378 c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
379 console.setBackgroundColor(new Color(c));
380
381 c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
382 console.setNotifyColor(new Color(c));
383
384 c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
385 console.setWarningColor(new Color(c));
386
387 c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
388 console.setErrorColor(new Color(c));
389 }
390 }

  ViewVC Help
Powered by ViewVC