/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSDefaultsPropsPane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/std/JSDefaultsPropsPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1313 - (show annotations) (download)
Thu Aug 30 22:44:29 2007 UTC (16 years, 8 months ago) by iliev
File size: 3980 byte(s)
* Added option for default actions when channel is created
  (choose Edit/Preferences, then click the `Defaults' tab)

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.std;
24
25 import java.awt.Dialog;
26 import java.awt.Dimension;
27
28 import java.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30 import java.awt.event.ItemEvent;
31 import java.awt.event.ItemListener;
32
33 import javax.swing.BorderFactory;
34 import javax.swing.Box;
35 import javax.swing.BoxLayout;
36 import javax.swing.Icon;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JDialog;
40 import javax.swing.JPanel;
41
42 import org.jsampler.CC;
43 import org.jsampler.JSPrefs;
44
45 import static org.jsampler.view.std.StdI18n.i18n;
46 import static org.jsampler.view.std.StdPrefs.*;
47
48 /**
49 *
50 * @author Grigor Iliev
51 */
52 public class JSDefaultsPropsPane extends JPanel {
53 private final ChannelDefaultsPane channelDefaultsPane;
54
55
56 /** Creates a new instance of <code>JSDefaultsPropsPane</code> */
57 public
58 JSDefaultsPropsPane(Dialog owner, Icon iconChangeDefaults) {
59 channelDefaultsPane = new ChannelDefaultsPane(owner, iconChangeDefaults);
60
61 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
62 add(channelDefaultsPane);
63 }
64
65 private static JSPrefs
66 preferences() { return CC.getViewConfig().preferences(); }
67
68 public void
69 apply() {
70 channelDefaultsPane.apply();
71 }
72
73 public static class ChannelDefaultsPane extends JPanel {
74 private final Dialog owner;
75 private final JCheckBox checkChannelDefaults =
76 new JCheckBox(i18n.getLabel("JSDefaultsPropsPane.checkChannelDefaults"));
77
78 private final JButton btnChannelDefaults;
79
80
81 public
82 ChannelDefaultsPane(Dialog owner, Icon iconChangeDefaults) {
83 this.owner = owner;
84 btnChannelDefaults = new JButton(iconChangeDefaults);
85 btnChannelDefaults.setEnabled(false);
86 btnChannelDefaults.setMargin(new java.awt.Insets(0, 0, 0, 0));
87
88 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
89
90 JPanel p = new JPanel();
91 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
92
93 p.add(checkChannelDefaults);
94 p.add(Box.createRigidArea(new Dimension(5, 0)));
95 p.add(btnChannelDefaults);
96 p.setAlignmentX(LEFT_ALIGNMENT);
97 p.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
98 add(p);
99
100 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
101
102 String s = i18n.getLabel("JSDefaultsPropsPane.titleChannels");
103 setBorder(BorderFactory.createTitledBorder(s));
104 setAlignmentX(LEFT_ALIGNMENT);
105
106 checkChannelDefaults.addItemListener(new ItemListener() {
107 public void
108 itemStateChanged(ItemEvent e) {
109 btnChannelDefaults.setEnabled(checkChannelDefaults.isSelected());
110 }
111 });
112
113 setMaximumSize(new Dimension(Short.MAX_VALUE, getMaximumSize().height));
114
115 if(preferences().getBoolProperty(USE_CHANNEL_DEFAULTS)) {
116 checkChannelDefaults.doClick(0);
117 }
118
119 btnChannelDefaults.addActionListener(new ActionListener() {
120 public void
121 actionPerformed(ActionEvent e) { editChannelDefaults(); }
122 });
123 }
124
125 public void
126 apply() {
127 boolean b = checkChannelDefaults.isSelected();
128 preferences().setBoolProperty(USE_CHANNEL_DEFAULTS, b);
129 }
130
131 protected void
132 editChannelDefaults() {
133 JDialog dlg = new JSChannelsDefaultSettingsPane().createDialog(owner);
134 dlg.setVisible(true);
135 }
136 }
137 }

  ViewVC Help
Powered by ViewVC