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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1286 - (show annotations) (download)
Fri Aug 10 20:24:23 2007 UTC (16 years, 10 months ago) by iliev
File size: 9932 byte(s)
- Updated to version 0.6a. The Fantasia distribution is now
  capable of controlling all features available in LinuxSampler

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.Color;
26 import java.awt.Dimension;
27 import java.awt.GridBagConstraints;
28 import java.awt.GridBagLayout;
29 import java.awt.Insets;
30
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33
34 import javax.swing.BorderFactory;
35 import javax.swing.Box;
36 import javax.swing.BoxLayout;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JLabel;
40 import javax.swing.JPanel;
41 import javax.swing.JSpinner;
42 import javax.swing.SpinnerNumberModel;
43
44 import org.jsampler.CC;
45 import org.jsampler.JSPrefs;
46
47 import static org.jsampler.view.std.StdI18n.i18n;
48 import static org.jsampler.view.std.StdPrefs.*;
49
50
51 /**
52 *
53 * @author Grigor Iliev
54 */
55 public class JSLSConsolePropsPane extends JPanel {
56 private final JCheckBox checkSaveCmdHist =
57 new JCheckBox(i18n.getLabel("JSLSConsolePropsPane.checkSaveCmdHist"));
58
59 private final JLabel lCmdHistorySize =
60 new JLabel(i18n.getLabel("JSLSConsolePropsPane.lCmdHistorySize"));
61 private JSpinner spCmdHistorySize;
62 private final JLabel lLines = new JLabel(i18n.getLabel("JSLSConsolePropsPane.lLines"));
63 private final JButton btnClearCmdHistory =
64 new JButton(i18n.getButtonLabel("JSLSConsolePropsPane.btnClearCmdHistory"));
65
66 private final JLabel lTextColor =
67 new JLabel(i18n.getLabel("JSLSConsolePropsPane.lTextColor"));
68
69 private final JSColorButton btnTextColor = new JSColorButton();
70
71 private final JLabel lBGColor = new JLabel(i18n.getLabel("JSLSConsolePropsPane.lBGColor"));
72 private final JSColorButton btnBGColor = new JSColorButton();
73
74 private final JLabel lNotifyColor =
75 new JLabel(i18n.getLabel("JSLSConsolePropsPane.lNotifyColor"));
76
77 private final JSColorButton btnNotifyColor = new JSColorButton();
78
79 private final JLabel lWarningColor
80 = new JLabel(i18n.getLabel("JSLSConsolePropsPane.lWarningColor"));
81
82 private final JSColorButton btnWarningColor = new JSColorButton();
83
84 private final JLabel lErrorColor =
85 new JLabel(i18n.getLabel("JSLSConsolePropsPane.lErrorColor"));
86
87 private final JSColorButton btnErrorColor = new JSColorButton();
88
89
90 /** Creates a new instance of <code>JSLSConsolePropsPane</code> */
91 public
92 JSLSConsolePropsPane() {
93 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
94
95 add(checkSaveCmdHist);
96
97 add(createCommandHistoryPane());
98 add(Box.createRigidArea(new Dimension(0, 6)));
99 add(createConsoleColorsPane());
100
101 setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
102 }
103
104 private JPanel
105 createCommandHistoryPane() {
106 JPanel chp = new JPanel();
107 chp.setAlignmentX(CENTER_ALIGNMENT);
108
109 GridBagLayout gridbag = new GridBagLayout();
110 GridBagConstraints c = new GridBagConstraints();
111
112 chp.setLayout(gridbag);
113
114 int i = preferences().getIntProperty(LS_CONSOLE_HISTSIZE, 1000);
115 spCmdHistorySize = new JSpinner(new SpinnerNumberModel(i, 0, 20000, 1));
116 spCmdHistorySize.setMaximumSize(spCmdHistorySize.getPreferredSize());
117
118 btnClearCmdHistory.addActionListener(new ActionListener() {
119 public void
120 actionPerformed(ActionEvent e) {
121 JSLSConsolePane.clearConsoleHistory();
122 clearConsoleHistory();
123 }
124 });
125
126 btnClearCmdHistory.setAlignmentX(JPanel.CENTER_ALIGNMENT);
127 add(btnClearCmdHistory);
128
129 c.fill = GridBagConstraints.NONE;
130
131 c.gridx = 0;
132 c.gridy = 0;
133 c.anchor = GridBagConstraints.EAST;
134 c.insets = new Insets(0, 6, 3, 0);
135 gridbag.setConstraints(lCmdHistorySize, c);
136 chp.add(lCmdHistorySize);
137
138 c.gridx = 1;
139 c.gridy = 0;
140 gridbag.setConstraints(spCmdHistorySize, c);
141 chp.add(spCmdHistorySize);
142
143 c.gridx = 2;
144 c.gridy = 0;
145 gridbag.setConstraints(lLines, c);
146 chp.add(lLines);
147
148 c.gridx = 3;
149 c.gridy = 0;
150 c.insets = new Insets(0, 12, 3, 6);
151 gridbag.setConstraints(btnClearCmdHistory, c);
152 chp.add(btnClearCmdHistory);
153
154 checkSaveCmdHist.setSelected(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY));
155 checkSaveCmdHist.setAlignmentX(JPanel.CENTER_ALIGNMENT);
156
157 c.gridx = 0;
158 c.gridy = 1;
159 c.gridwidth = 4;
160 c.insets = new Insets(3, 6, 3, 6);
161 c.anchor = GridBagConstraints.CENTER;
162 gridbag.setConstraints(checkSaveCmdHist, c);
163 chp.add(checkSaveCmdHist);
164
165 String s = i18n.getLabel("JSLSConsolePropsPane.commandHistory");
166 chp.setBorder(BorderFactory.createTitledBorder(s));
167
168 chp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
169
170 return chp;
171 }
172
173 private JPanel
174 createConsoleColorsPane() {
175 JPanel ccp = new JPanel();
176 ccp.setAlignmentX(CENTER_ALIGNMENT);
177
178 GridBagLayout gridbag = new GridBagLayout();
179 GridBagConstraints c = new GridBagConstraints();
180
181 ccp.setLayout(gridbag);
182
183 c.fill = GridBagConstraints.NONE;
184
185 c.gridx = 0;
186 c.gridy = 0;
187 c.anchor = GridBagConstraints.EAST;
188 c.insets = new Insets(3, 3, 3, 3);
189 gridbag.setConstraints(lTextColor, c);
190 ccp.add(lTextColor);
191
192 c.gridx = 0;
193 c.gridy = 1;
194 gridbag.setConstraints(lBGColor, c);
195 ccp.add(lBGColor);
196
197 c.gridx = 0;
198 c.gridy = 2;
199 gridbag.setConstraints(lNotifyColor, c);
200 ccp.add(lNotifyColor);
201
202 c.gridx = 0;
203 c.gridy = 3;
204 gridbag.setConstraints(lWarningColor, c);
205 ccp.add(lWarningColor);
206
207 c.gridx = 0;
208 c.gridy = 4;
209 gridbag.setConstraints(lErrorColor, c);
210 ccp.add(lErrorColor);
211
212 c.fill = GridBagConstraints.HORIZONTAL;
213 c.gridx = 1;
214 c.gridy = 0;
215 //c.weightx = 1.0;
216 c.anchor = GridBagConstraints.WEST;
217 gridbag.setConstraints(btnTextColor, c);
218 ccp.add(btnTextColor);
219
220 c.gridx = 1;
221 c.gridy = 1;
222 gridbag.setConstraints(btnBGColor, c);
223 ccp.add(btnBGColor);
224
225 c.gridx = 1;
226 c.gridy = 2;
227 gridbag.setConstraints(btnNotifyColor, c);
228 ccp.add(btnNotifyColor);
229
230 c.gridx = 1;
231 c.gridy = 3;
232 gridbag.setConstraints(btnWarningColor, c);
233 ccp.add(btnWarningColor);
234
235 c.gridx = 1;
236 c.gridy = 4;
237 gridbag.setConstraints(btnErrorColor, c);
238 ccp.add(btnErrorColor);
239
240 int i = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR);
241 btnTextColor.setColor(new Color(i));
242
243 i = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR);
244 btnBGColor.setColor(new Color(i));
245
246 i = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR);
247 btnNotifyColor.setColor(new Color(i));
248
249 i = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR);
250 btnWarningColor.setColor(new Color(i));
251
252 i = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR);
253 btnErrorColor.setColor(new Color(i));
254
255 String s = i18n.getButtonLabel("JSLSConsolePropsPane.btnDefaults");
256 JButton btnDefaults = new JButton(s);
257
258 btnDefaults.addActionListener(new ActionListener() {
259 public void
260 actionPerformed(ActionEvent e) {
261 int i = preferences().getDefaultIntValue(LS_CONSOLE_TEXT_COLOR);
262 preferences().setIntProperty(LS_CONSOLE_TEXT_COLOR, i);
263 btnTextColor.setColor(new Color(i));
264
265 i = preferences().getDefaultIntValue(LS_CONSOLE_BACKGROUND_COLOR);
266 preferences().setIntProperty(LS_CONSOLE_BACKGROUND_COLOR, i);
267 btnBGColor.setColor(new Color(i));
268
269 i = preferences().getDefaultIntValue(LS_CONSOLE_NOTIFY_COLOR);
270 preferences().setIntProperty(LS_CONSOLE_NOTIFY_COLOR, i);
271 btnNotifyColor.setColor(new Color(i));
272
273 i = preferences().getDefaultIntValue(LS_CONSOLE_WARNING_COLOR);
274 preferences().setIntProperty(LS_CONSOLE_WARNING_COLOR, i);
275 btnWarningColor.setColor(new Color(i));
276
277 i = preferences().getDefaultIntValue(LS_CONSOLE_ERROR_COLOR);
278 preferences().setIntProperty(LS_CONSOLE_ERROR_COLOR, i);
279 btnErrorColor.setColor(new Color(i));
280 }
281 });
282
283 JPanel p = new JPanel();
284 p.setAlignmentX(LEFT_ALIGNMENT);
285 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
286 p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6));
287 p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
288
289 p.add(Box.createGlue());
290 p.add(btnDefaults);
291 p.add(Box.createGlue());
292
293 c.gridx = 0;
294 c.gridy = 5;
295 c.gridwidth = 2;
296 gridbag.setConstraints(p, c);
297 ccp.add(p);
298
299 s = i18n.getLabel("JSLSConsolePropsPane.consoleColors");
300 ccp.setBorder(BorderFactory.createTitledBorder(s));
301
302 ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
303
304 return ccp;
305 }
306
307 private JSPrefs
308 preferences() { return CC.getViewConfig().preferences(); }
309
310 /**
311 * Override this method to clear the command history of the LS Console's model.
312 */
313 protected void
314 clearConsoleHistory() { }
315
316 protected void
317 apply() {
318 boolean b = checkSaveCmdHist.isSelected();
319 preferences().setBoolProperty(SAVE_LS_CONSOLE_HISTORY, b);
320
321 int size = Integer.parseInt(spCmdHistorySize.getValue().toString());
322 preferences().setIntProperty(LS_CONSOLE_HISTSIZE, size);
323
324 ///***///
325
326 int c = btnTextColor.getColor().getRGB();
327 preferences().setIntProperty(LS_CONSOLE_TEXT_COLOR, c);
328
329 c = btnBGColor.getColor().getRGB();
330 preferences().setIntProperty(LS_CONSOLE_BACKGROUND_COLOR, c);
331
332 c = btnNotifyColor.getColor().getRGB();
333 preferences().setIntProperty(LS_CONSOLE_NOTIFY_COLOR, c);
334
335 c = btnWarningColor.getColor().getRGB();
336 preferences().setIntProperty(LS_CONSOLE_WARNING_COLOR, c);
337
338 c = btnErrorColor.getColor().getRGB();
339 preferences().setIntProperty(LS_CONSOLE_ERROR_COLOR, c);
340 }
341 }

  ViewVC Help
Powered by ViewVC