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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1540 by iliev, Mon Dec 3 23:22:02 2007 UTC revision 1818 by iliev, Wed Dec 24 17:29:47 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 24  package org.jsampler.view.fantasia; Line 24  package org.jsampler.view.fantasia;
24    
25  import java.awt.BorderLayout;  import java.awt.BorderLayout;
26  import java.awt.Color;  import java.awt.Color;
27    import java.awt.Dialog;
28  import java.awt.Dimension;  import java.awt.Dimension;
29  import java.awt.Frame;  import java.awt.Frame;
30    
# Line 45  import org.jsampler.CC; Line 46  import org.jsampler.CC;
46  import org.jsampler.LSConsoleModel;  import org.jsampler.LSConsoleModel;
47  import org.jsampler.Prefs;  import org.jsampler.Prefs;
48    
49    import org.jsampler.view.std.JSAdvancedGeneralPropsDlg;
50  import org.jsampler.view.std.JSConnectionPropsPane;  import org.jsampler.view.std.JSConnectionPropsPane;
51  import org.jsampler.view.std.JSDefaultsPropsPane;  import org.jsampler.view.std.JSDefaultsPropsPane;
52  import org.jsampler.view.std.JSGeneralProps;  import org.jsampler.view.std.JSGeneralProps;
# Line 60  import static org.jsampler.view.fantasia Line 62  import static org.jsampler.view.fantasia
62   * @author Grigor Iliev   * @author Grigor Iliev
63   */   */
64  public class PrefsDlg extends EnhancedDialog {  public class PrefsDlg extends EnhancedDialog {
65          private final GeneralPane genPane = new GeneralPane();          private final JTabbedPane tabbedPane = new JTabbedPane();
66            
67            private final GeneralPane genPane = new GeneralPane(this);
68          private final ViewPane viewPane = new ViewPane();          private final ViewPane viewPane = new ViewPane();
69            private final ChannelsPropsPane channelsPane = new ChannelsPropsPane();
70          private final ConsolePane consolePane = new ConsolePane();          private final ConsolePane consolePane = new ConsolePane();
71          private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();          private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane();
72          private final JSDefaultsPropsPane defaultsPane;          private final JSDefaultsPropsPane defaultsPane;
# Line 72  public class PrefsDlg extends EnhancedDi Line 77  public class PrefsDlg extends EnhancedDi
77                    
78          /** Creates a new instance of <code>PrefsDlg</code> */          /** Creates a new instance of <code>PrefsDlg</code> */
79          public          public
80          PrefsDlg(Frame owner) {          PrefsDlg(Frame owner) {
81                  super(owner, i18n.getLabel("PrefsDlg.title"), true);                  super(owner, i18n.getLabel("PrefsDlg.title"), true);
82                                    
83                  defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16);                  defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16, true);
84                    
85                    JTabbedPane tp = tabbedPane;
86                    tp.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
87                                    
                 JTabbedPane tp = new JTabbedPane();  
88                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane);
89                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane);
90                    tp.addTab(i18n.getLabel("PrefsDlg.tabChannels"), channelsPane);
91                  tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane);
92                                    
93                  JPanel p = new JPanel();                  JPanel p = new JPanel();
94                  p.setLayout(new BorderLayout());                  p.setLayout(new BorderLayout());
95                  p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));                  p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
96                  p.add(connectionPane, BorderLayout.NORTH);                  p.add(connectionPane);
97                  tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), p);                  tp.addTab(i18n.getLabel("PrefsDlg.tabBackend"), p);
98                  tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);                  tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane);
99                                    
100                  tp.setAlignmentX(RIGHT_ALIGNMENT);                  tp.setAlignmentX(RIGHT_ALIGNMENT);
# Line 118  public class PrefsDlg extends EnhancedDi Line 126  public class PrefsDlg extends EnhancedDi
126                                    
127                  installListeners();                  installListeners();
128                                    
129                  connectionPane.setLSAddress(Prefs.getLSAddress());                  int i = preferences().getIntProperty("PrefsDlg.tabIndex");
130                  connectionPane.setLSPort(String.valueOf(Prefs.getLSPort()));                  
131                    if(i >= 0 && i < tp.getTabCount()) tp.setSelectedIndex(i);
132          }          }
133                    
134          private void          private void
# Line 145  public class PrefsDlg extends EnhancedDi Line 154  public class PrefsDlg extends EnhancedDi
154          onApply() {          onApply() {
155                  genPane.apply();                  genPane.apply();
156                  viewPane.apply();                  viewPane.apply();
157                    channelsPane.apply();
158                  consolePane.apply();                  consolePane.apply();
159                  connectionPane.apply();                  connectionPane.apply();
160                  defaultsPane.apply();                  defaultsPane.apply();
161                                    
162                    preferences().setIntProperty("PrefsDlg.tabIndex", tabbedPane.getSelectedIndex());
163                    
164                  setVisible(false);                  setVisible(false);
165          }          }
166                    
# Line 157  public class PrefsDlg extends EnhancedDi Line 169  public class PrefsDlg extends EnhancedDi
169  }  }
170    
171  class GeneralPane extends JPanel {  class GeneralPane extends JPanel {
         private final JCheckBox checkTurnOffAnimationEffects =  
                 new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));  
           
172          private final JCheckBox checkShowLSConsoleWhenRunScript =          private final JCheckBox checkShowLSConsoleWhenRunScript =
173                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript"));
174                    
175          private final JCheckBox checkShowVolumesInDecibels =          private final JCheckBox checkShowVolumesInDecibels =
176                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));                  new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels"));
177                    
178          private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane();          private final JSGeneralProps.PolyphonyPane polyphonyPane = new JSGeneralProps.PolyphonyPane();
179                    
180          private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =          private final JSGeneralProps.JSamplerHomePane jSamplerHomePane =
181                  new JSGeneralProps.JSamplerHomePane();                  new JSGeneralProps.JSamplerHomePane();
182                    
183          private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();          private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane();
184                    
185            private final JButton btnAdvanced = new JButton(i18n.getButtonLabel("GeneralPane.btnAdvanced"));
186            
187            private final Dialog owner;
188            
189          public          public
190          GeneralPane() {          GeneralPane(Dialog owner) {
191                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));                  this.owner = owner;
192                                    
193                  checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
                   
                 boolean b = !preferences().getBoolProperty(ANIMATED);  
                 checkTurnOffAnimationEffects.setSelected(b);  
                   
                 add(checkTurnOffAnimationEffects);  
                   
                 add(Box.createRigidArea(new Dimension(0, 6)));  
194                                    
195                  checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);                  checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT);
196                                    
197                  b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);                  boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT);
198                  checkShowLSConsoleWhenRunScript.setSelected(b);                  checkShowLSConsoleWhenRunScript.setSelected(b);
199                                    
200                  add(checkShowLSConsoleWhenRunScript);                  add(checkShowLSConsoleWhenRunScript);
# Line 202  class GeneralPane extends JPanel { Line 208  class GeneralPane extends JPanel {
208                                    
209                  add(Box.createRigidArea(new Dimension(0, 6)));                  add(Box.createRigidArea(new Dimension(0, 6)));
210                                    
211                  add(maxVolPane);                  add(polyphonyPane);
212                                    
213                  add(Box.createRigidArea(new Dimension(0, 6)));                  add(Box.createRigidArea(new Dimension(0, 6)));
214                                    
# Line 211  class GeneralPane extends JPanel { Line 217  class GeneralPane extends JPanel {
217                  add(Box.createRigidArea(new Dimension(0, 6)));                  add(Box.createRigidArea(new Dimension(0, 6)));
218                                    
219                  add(recentScriptsPane);                  add(recentScriptsPane);
220                    
221                    add(Box.createRigidArea(new Dimension(0, 6)));
222                    
223                    JPanel p = new JPanel();
224                    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
225                    
226                    JPanel p2 = new JPanel();
227                    p2.setLayout(new BorderLayout());
228                    p.add(p2);
229                    p.add(btnAdvanced);
230                    p.setAlignmentX(JPanel.LEFT_ALIGNMENT);
231                    add(p);
232                    
233                  add(Box.createGlue());                  add(Box.createGlue());
234                                    
235                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));                  setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
236                                    
237                                    btnAdvanced.addActionListener(new ActionListener() {
238                            public void
239                            actionPerformed(ActionEvent e) { showAdvancedProperties(); }
240                    });
241            }
242            
243            private void
244            showAdvancedProperties() {
245                    new JSAdvancedGeneralPropsDlg(owner).setVisible(true);
246          }          }
247                    
248          protected void          protected void
249          apply() {          apply() {
250                  maxVolPane.apply();                  polyphonyPane.apply();
                   
                 boolean b = !checkTurnOffAnimationEffects.isSelected();  
                 preferences().setBoolProperty(ANIMATED, b);  
251                                    
252                  b = checkShowLSConsoleWhenRunScript.isSelected();                  boolean b = checkShowLSConsoleWhenRunScript.isSelected();
253                  preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);                  preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b);
254                                    
255                  b = checkShowVolumesInDecibels.isSelected();                  b = checkShowVolumesInDecibels.isSelected();
# Line 250  class GeneralPane extends JPanel { Line 274  class GeneralPane extends JPanel {
274  }  }
275    
276  class ViewPane extends JPanel {  class ViewPane extends JPanel {
277            private final JCheckBox checkTurnOffAnimationEffects =
278                    new JCheckBox(i18n.getLabel("GeneralPane.checkTurnOffAnimationEffects"));
279            
280          private final JCheckBox checkTurnOffCustomWindowDecoration =          private final JCheckBox checkTurnOffCustomWindowDecoration =
281                  new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));                  new JCheckBox(i18n.getLabel("ViewPane.checkTurnOffCustomWindowDecoration"));
282                    
283            private final JCheckBox checkShowInstrumentsDb =
284                    new JCheckBox(i18n.getLabel("ViewPane.checkShowInstrumentsDb"));
285            
286          private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();          private final JSViewProps.MidiDevicesPane midiDevsPane = new JSViewProps.MidiDevicesPane();
287          private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();          private final JSViewProps.AudioDevicesPane audioDevsPane = new JSViewProps.AudioDevicesPane();
288                    
289            private final JSViewProps.ConfirmationMessagesPane confirmationMessagesPane =
290                    new JSViewProps.ConfirmationMessagesPane();
291            
292          ViewPane() {          ViewPane() {
293                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));                  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
294                                    
295                  boolean b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");                  checkTurnOffAnimationEffects.setAlignmentX(JPanel.LEFT_ALIGNMENT);
296                    
297                    boolean b = !preferences().getBoolProperty(ANIMATED);
298                    checkTurnOffAnimationEffects.setSelected(b);
299                    
300                    add(checkTurnOffAnimationEffects);
301                    
302                    add(Box.createRigidArea(new Dimension(0, 6)));
303                    
304                    b = preferences().getBoolProperty("TurnOffCustomWindowDecoration");
305                  checkTurnOffCustomWindowDecoration.setSelected(b);                  checkTurnOffCustomWindowDecoration.setSelected(b);
306                  checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);                  checkTurnOffCustomWindowDecoration.setAlignmentX(JPanel.LEFT_ALIGNMENT);
307                  add(checkTurnOffCustomWindowDecoration);                  add(checkTurnOffCustomWindowDecoration);
308                  add(Box.createRigidArea(new Dimension(0, 6)));                  add(Box.createRigidArea(new Dimension(0, 6)));
309                    
310                    b = preferences().getBoolProperty("rightSidePane.showInstrumentsDb");
311                    checkShowInstrumentsDb.setSelected(b);
312                    checkShowInstrumentsDb.setAlignmentX(JPanel.LEFT_ALIGNMENT);
313                    add(checkShowInstrumentsDb);
314                    add(Box.createRigidArea(new Dimension(0, 6)));
315                    
316                  add(midiDevsPane);                  add(midiDevsPane);
317                  add(audioDevsPane);                  add(audioDevsPane);
318                    add(confirmationMessagesPane);
319          }          }
320                    
321          protected void          protected void
322          apply() {          apply() {
323                    boolean b = !checkTurnOffAnimationEffects.isSelected();
324                    preferences().setBoolProperty(ANIMATED, b);
325                    
326                  String s = "TurnOffCustomWindowDecoration";                  String s = "TurnOffCustomWindowDecoration";
327                  preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());                  preferences().setBoolProperty(s, checkTurnOffCustomWindowDecoration.isSelected());
328                                    
329                    s = "rightSidePane.showInstrumentsDb";
330                    preferences().setBoolProperty(s, checkShowInstrumentsDb.isSelected());
331                    
332                  midiDevsPane.apply();                  midiDevsPane.apply();
333                  audioDevsPane.apply();                  audioDevsPane.apply();
334                    confirmationMessagesPane.apply();
335            }
336    }
337    
338    class ChannelsPropsPane extends JPanel {
339            private final JCheckBox checkShowChannelNumbering =
340                    new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowChannelNumbering"));
341            
342            private final JCheckBox checkShowMidiInfo =
343                    new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowMidiInfo"));
344            
345            private final JCheckBox checkShowStreamVoiceCount =
346                    new JCheckBox(i18n.getLabel("ChannelsPropsPane.checkShowStreamVoiceCount"));
347            
348            ChannelsPropsPane() {
349                    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
350                    
351                    add(createSmallViewPane());
352                    JPanel p = new JPanel();
353                    p.setLayout(new BorderLayout());
354                    add(p);
355            }
356            
357            protected void
358            apply() {
359                    boolean b = checkShowChannelNumbering.isSelected();
360                    preferences().setBoolProperty("channel.smallView.showChannelNumbering", b);
361                    
362                    b = checkShowMidiInfo.isSelected();
363                    preferences().setBoolProperty("channel.smallView.showMidiInfo", b);
364                    
365                    b = checkShowStreamVoiceCount.isSelected();
366                    preferences().setBoolProperty("channel.smallView.showStreamVoiceCount", b);
367            }
368            
369            private JPanel
370            createSmallViewPane() {
371                    JPanel p = new JPanel();
372                    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
373                    
374                    boolean b = preferences().getBoolProperty("channel.smallView.showChannelNumbering");
375                    checkShowChannelNumbering.setSelected(b);
376                    checkShowChannelNumbering.setAlignmentX(LEFT_ALIGNMENT);
377                    p.add(checkShowChannelNumbering);
378                    
379                    b = preferences().getBoolProperty("channel.smallView.showMidiInfo");
380                    checkShowMidiInfo.setSelected(b);
381                    checkShowMidiInfo.setAlignmentX(LEFT_ALIGNMENT);
382                    p.add(checkShowMidiInfo);
383                    
384                    b = preferences().getBoolProperty("channel.smallView.showStreamVoiceCount");
385                    checkShowStreamVoiceCount.setSelected(b);
386                    checkShowStreamVoiceCount.setAlignmentX(LEFT_ALIGNMENT);
387                    p.add(checkShowStreamVoiceCount);
388                    
389                    String s = i18n.getLabel("ChannelsPropsPane.smallView");
390                    p.setBorder(BorderFactory.createTitledBorder(s));
391                    p.setMaximumSize(new Dimension(Short.MAX_VALUE, p.getPreferredSize().height));
392                    
393                    return p;
394          }          }
395  }  }
396    

Legend:
Removed from v.1540  
changed lines
  Added in v.1818

  ViewVC Help
Powered by ViewVC