1 |
iliev |
787 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
1285 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
787 |
* |
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.classic; |
24 |
|
|
|
25 |
iliev |
842 |
import java.awt.BorderLayout; |
26 |
|
|
import java.awt.Color; |
27 |
iliev |
787 |
import java.awt.Container; |
28 |
|
|
import java.awt.Dimension; |
29 |
|
|
import java.awt.GraphicsEnvironment; |
30 |
|
|
import java.awt.Font; |
31 |
|
|
import java.awt.Frame; |
32 |
|
|
import java.awt.GridBagConstraints; |
33 |
|
|
import java.awt.GridBagLayout; |
34 |
|
|
import java.awt.Insets; |
35 |
|
|
|
36 |
|
|
import java.awt.event.ActionEvent; |
37 |
|
|
import java.awt.event.ActionListener; |
38 |
iliev |
842 |
import java.awt.event.ItemEvent; |
39 |
|
|
import java.awt.event.ItemListener; |
40 |
iliev |
787 |
|
41 |
|
|
import java.util.Locale; |
42 |
|
|
|
43 |
|
|
import javax.swing.BorderFactory; |
44 |
|
|
import javax.swing.Box; |
45 |
|
|
import javax.swing.BoxLayout; |
46 |
iliev |
842 |
import javax.swing.DefaultButtonModel; |
47 |
iliev |
787 |
import javax.swing.JButton; |
48 |
iliev |
842 |
import javax.swing.JCheckBox; |
49 |
iliev |
787 |
import javax.swing.JComboBox; |
50 |
|
|
import javax.swing.JLabel; |
51 |
|
|
import javax.swing.JOptionPane; |
52 |
|
|
import javax.swing.JPanel; |
53 |
|
|
import javax.swing.JTabbedPane; |
54 |
|
|
import javax.swing.JTextField; |
55 |
|
|
|
56 |
|
|
import net.sf.juife.EnhancedDialog; |
57 |
|
|
import net.sf.juife.JuifeUtils; |
58 |
iliev |
842 |
import net.sf.juife.LinkButton; |
59 |
iliev |
787 |
|
60 |
iliev |
842 |
import org.jsampler.CC; |
61 |
iliev |
787 |
import org.jsampler.HF; |
62 |
|
|
import org.jsampler.JSI18n; |
63 |
|
|
import org.jsampler.JSampler; |
64 |
iliev |
911 |
import org.jsampler.LSConsoleModel; |
65 |
iliev |
787 |
import org.jsampler.Prefs; |
66 |
|
|
|
67 |
iliev |
1285 |
import org.jsampler.view.std.JSColorButton; |
68 |
|
|
import org.jsampler.view.std.JSConnectionPropsPane; |
69 |
iliev |
1313 |
import org.jsampler.view.std.JSDefaultsPropsPane; |
70 |
iliev |
1285 |
import org.jsampler.view.std.JSGeneralProps; |
71 |
|
|
import org.jsampler.view.std.JSLSConsolePropsPane; |
72 |
iliev |
842 |
|
73 |
iliev |
787 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
74 |
iliev |
1285 |
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
75 |
|
|
import static org.jsampler.view.std.StdPrefs.*; |
76 |
iliev |
787 |
|
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* |
80 |
|
|
* @author Grigor Iliev |
81 |
|
|
*/ |
82 |
|
|
public class PrefsDlg extends EnhancedDialog { |
83 |
iliev |
911 |
private final GeneralPane genPane = new GeneralPane(); |
84 |
iliev |
787 |
private final ViewPane viewPane = new ViewPane(); |
85 |
iliev |
911 |
private final ConsolePane consolePane = new ConsolePane(); |
86 |
iliev |
1285 |
private final JSConnectionPropsPane connectionPane = new JSConnectionPropsPane(); |
87 |
iliev |
1313 |
private final JSDefaultsPropsPane defaultsPane; |
88 |
iliev |
787 |
|
89 |
|
|
private final JButton btnApply = new JButton(i18n.getButtonLabel("apply")); |
90 |
|
|
private final JButton btnClose = new JButton(i18n.getButtonLabel("close")); |
91 |
|
|
|
92 |
|
|
|
93 |
|
|
public |
94 |
|
|
PrefsDlg(Frame frm) { |
95 |
|
|
super(frm, i18n.getLabel("PrefsDlg"), true); |
96 |
|
|
|
97 |
iliev |
1313 |
defaultsPane = new JSDefaultsPropsPane(this, Res.iconEdit16); |
98 |
|
|
|
99 |
iliev |
787 |
initPrefsDlg(); |
100 |
iliev |
1285 |
installListeners(); |
101 |
iliev |
787 |
|
102 |
|
|
setLocation(JuifeUtils.centerLocation(this, frm)); |
103 |
iliev |
1285 |
|
104 |
|
|
connectionPane.setLSAddress(Prefs.getLSAddress()); |
105 |
|
|
connectionPane.setLSPort(String.valueOf(Prefs.getLSPort())); |
106 |
iliev |
787 |
} |
107 |
|
|
|
108 |
|
|
private void |
109 |
|
|
initPrefsDlg() { |
110 |
|
|
JTabbedPane tp = new JTabbedPane(); |
111 |
|
|
tp.addTab(i18n.getLabel("PrefsDlg.tabGeneral"), genPane); |
112 |
|
|
tp.addTab(i18n.getLabel("PrefsDlg.tabView"), viewPane); |
113 |
iliev |
911 |
tp.addTab(i18n.getLabel("PrefsDlg.tabConsole"), consolePane); |
114 |
iliev |
1285 |
|
115 |
|
|
JPanel p = new JPanel(); |
116 |
|
|
p.setLayout(new BorderLayout()); |
117 |
|
|
p.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
118 |
|
|
p.add(connectionPane, BorderLayout.NORTH); |
119 |
|
|
tp.addTab(i18n.getLabel("PrefsDlg.tabConnection"), p); |
120 |
iliev |
1313 |
tp.addTab(i18n.getLabel("PrefsDlg.tabDefaults"), defaultsPane); |
121 |
iliev |
1285 |
|
122 |
iliev |
787 |
tp.setAlignmentX(RIGHT_ALIGNMENT); |
123 |
|
|
|
124 |
|
|
// Set preferred size for Apply & Exit buttons |
125 |
|
|
Dimension d = JuifeUtils.getUnionSize(btnApply, btnClose); |
126 |
|
|
btnApply.setPreferredSize(d); |
127 |
|
|
btnClose.setPreferredSize(d); |
128 |
|
|
|
129 |
|
|
JPanel btnPane = new JPanel(); |
130 |
|
|
btnPane.setLayout(new BoxLayout(btnPane, BoxLayout.X_AXIS)); |
131 |
|
|
btnPane.add(btnApply); |
132 |
|
|
btnPane.add(Box.createRigidArea(new Dimension(5, 0))); |
133 |
|
|
btnPane.add(btnClose); |
134 |
|
|
btnPane.setAlignmentX(RIGHT_ALIGNMENT); |
135 |
|
|
|
136 |
|
|
JPanel mainPane = new JPanel(); |
137 |
|
|
mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
138 |
|
|
mainPane.add(tp); |
139 |
|
|
mainPane.add(Box.createRigidArea(new Dimension(0, 12))); |
140 |
|
|
mainPane.add(btnPane); |
141 |
|
|
mainPane.setBorder(BorderFactory.createEmptyBorder(11, 12, 12, 12)); |
142 |
|
|
|
143 |
|
|
getContentPane().add(mainPane); |
144 |
|
|
|
145 |
|
|
pack(); |
146 |
|
|
setResizable(false); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
private void |
150 |
iliev |
1285 |
installListeners() { |
151 |
iliev |
787 |
btnApply.addActionListener(new ActionListener() { |
152 |
|
|
public void |
153 |
|
|
actionPerformed(ActionEvent e) { onApply(); } |
154 |
|
|
}); |
155 |
|
|
|
156 |
|
|
btnClose.addActionListener(new ActionListener() { |
157 |
|
|
public void |
158 |
|
|
actionPerformed(ActionEvent e) { onExit(); } |
159 |
|
|
}); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
protected void |
163 |
|
|
onOk() { onApply(); } |
164 |
|
|
|
165 |
|
|
protected void |
166 |
|
|
onCancel() { onExit(); } |
167 |
|
|
|
168 |
|
|
private void |
169 |
|
|
onApply() { |
170 |
iliev |
842 |
genPane.apply(); |
171 |
|
|
viewPane.apply(); |
172 |
iliev |
911 |
consolePane.apply(); |
173 |
iliev |
1285 |
connectionPane.apply(); |
174 |
iliev |
1313 |
defaultsPane.apply(); |
175 |
iliev |
787 |
|
176 |
|
|
setVisible(false); |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
private void |
180 |
|
|
onExit() { setVisible(false); } |
181 |
|
|
} |
182 |
|
|
|
183 |
|
|
class GeneralPane extends JPanel { |
184 |
iliev |
842 |
private final JCheckBox checkWindowSizeAndLocation = |
185 |
|
|
new JCheckBox(i18n.getLabel("GeneralPane.checkWindowSizeAndLocation")); |
186 |
|
|
|
187 |
iliev |
911 |
private final JCheckBox checkLeftPaneState = |
188 |
|
|
new JCheckBox(i18n.getLabel("GeneralPane.checkLeftPaneState")); |
189 |
|
|
|
190 |
|
|
private final JCheckBox checkShowLSConsoleWhenRunScript = |
191 |
|
|
new JCheckBox(i18n.getLabel("GeneralPane.checkShowLSConsoleWhenRunScript")); |
192 |
|
|
|
193 |
iliev |
1567 |
private final JCheckBox checkShowVolumesInDecibels = |
194 |
|
|
new JCheckBox(i18n.getLabel("GeneralPane.checkShowVolumesInDecibels")); |
195 |
|
|
|
196 |
iliev |
1357 |
private final JSGeneralProps.MaxVolumePane maxVolPane = new JSGeneralProps.MaxVolumePane(); |
197 |
|
|
|
198 |
iliev |
1285 |
private final JSGeneralProps.JSamplerHomePane jSamplerHomePane = |
199 |
|
|
new JSGeneralProps.JSamplerHomePane(); |
200 |
iliev |
1143 |
|
201 |
iliev |
1285 |
private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane(); |
202 |
iliev |
911 |
|
203 |
|
|
|
204 |
iliev |
787 |
public |
205 |
iliev |
911 |
GeneralPane() { |
206 |
iliev |
842 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
207 |
iliev |
787 |
|
208 |
iliev |
911 |
checkWindowSizeAndLocation.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
209 |
iliev |
842 |
|
210 |
iliev |
911 |
checkWindowSizeAndLocation.setSelected(ClassicPrefs.getSaveWindowProperties()); |
211 |
iliev |
842 |
checkWindowSizeAndLocation.addItemListener(new ItemListener() { |
212 |
|
|
public void |
213 |
|
|
itemStateChanged(ItemEvent e) { |
214 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
215 |
iliev |
911 |
//checkWindowSizeAndLocation.setEnabled(b); |
216 |
iliev |
842 |
} |
217 |
|
|
}); |
218 |
|
|
|
219 |
iliev |
911 |
add(checkWindowSizeAndLocation); |
220 |
iliev |
842 |
|
221 |
iliev |
911 |
checkLeftPaneState.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
222 |
|
|
checkLeftPaneState.setSelected(ClassicPrefs.getSaveLeftPaneState()); |
223 |
|
|
add(checkLeftPaneState); |
224 |
|
|
|
225 |
|
|
checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
226 |
|
|
|
227 |
iliev |
1285 |
boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT); |
228 |
iliev |
911 |
checkShowLSConsoleWhenRunScript.setSelected(b); |
229 |
|
|
|
230 |
|
|
add(checkShowLSConsoleWhenRunScript); |
231 |
|
|
|
232 |
iliev |
1567 |
b = preferences().getBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL); |
233 |
|
|
checkShowVolumesInDecibels.setSelected(b); |
234 |
|
|
|
235 |
|
|
add(checkShowVolumesInDecibels); |
236 |
|
|
|
237 |
iliev |
911 |
add(Box.createRigidArea(new Dimension(0, 6))); |
238 |
|
|
|
239 |
iliev |
1357 |
add(maxVolPane); |
240 |
|
|
|
241 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
242 |
|
|
|
243 |
iliev |
1285 |
add(jSamplerHomePane); |
244 |
iliev |
1143 |
|
245 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
246 |
|
|
|
247 |
iliev |
1285 |
add(recentScriptsPane); |
248 |
iliev |
911 |
add(Box.createGlue()); |
249 |
|
|
|
250 |
|
|
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
251 |
iliev |
787 |
} |
252 |
iliev |
842 |
|
253 |
|
|
protected void |
254 |
|
|
apply() { |
255 |
iliev |
1357 |
maxVolPane.apply(); |
256 |
|
|
|
257 |
iliev |
911 |
ClassicPrefs.setSaveWindowProperties(checkWindowSizeAndLocation.isSelected()); |
258 |
|
|
ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected()); |
259 |
|
|
|
260 |
|
|
boolean b = checkShowLSConsoleWhenRunScript.isSelected(); |
261 |
iliev |
1285 |
preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b); |
262 |
iliev |
911 |
|
263 |
iliev |
1567 |
b = checkShowVolumesInDecibels.isSelected(); |
264 |
|
|
preferences().setBoolProperty(VOL_MEASUREMENT_UNIT_DECIBEL, b); |
265 |
|
|
|
266 |
iliev |
1285 |
int size = recentScriptsPane.getRecentScriptsSize(); |
267 |
|
|
preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size); |
268 |
iliev |
911 |
((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu(); |
269 |
iliev |
1143 |
|
270 |
iliev |
1285 |
String s = jSamplerHomePane.getJSamplerHome(); |
271 |
iliev |
1143 |
if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) { |
272 |
|
|
CC.changeJSamplerHome(s); |
273 |
|
|
} |
274 |
iliev |
842 |
} |
275 |
iliev |
1285 |
|
276 |
|
|
private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane { |
277 |
|
|
protected void |
278 |
|
|
clearRecentScripts() { |
279 |
|
|
((MainFrame)CC.getMainFrame()).clearRecentScripts(); |
280 |
|
|
} |
281 |
|
|
} |
282 |
iliev |
787 |
} |
283 |
|
|
|
284 |
|
|
class ViewPane extends JPanel { |
285 |
|
|
private final JLabel lIfaceLanguage = |
286 |
|
|
new JLabel(i18n.getLabel("ViewPane.lIfaceLanguage")); |
287 |
|
|
private final JComboBox cbIfaceLanguage = new JComboBox(); |
288 |
|
|
|
289 |
|
|
private final JLabel lIfaceFont = |
290 |
|
|
new JLabel(i18n.getLabel("ViewPane.lIfaceFont")); |
291 |
|
|
private final JComboBox cbIfaceFont = new JComboBox(); |
292 |
|
|
|
293 |
iliev |
842 |
private final JCheckBox checkBorderColor = |
294 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor")); |
295 |
iliev |
1285 |
private final JSColorButton btnBorderColor = new JSColorButton(Color.WHITE); |
296 |
iliev |
842 |
|
297 |
iliev |
1143 |
private final JCheckBox checkHlChnBorderColor = |
298 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBorderColor")); |
299 |
iliev |
1285 |
private final JSColorButton btnHlChnBorderColor = new JSColorButton(Color.WHITE); |
300 |
iliev |
1143 |
|
301 |
|
|
private final JCheckBox checkSelChnBgColor = |
302 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkSelChnBgColor")); |
303 |
iliev |
1285 |
private final JSColorButton btnSelChnBgColor = new JSColorButton(Color.WHITE); |
304 |
iliev |
1143 |
|
305 |
|
|
private final JCheckBox checkHlChnBgColor = |
306 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBgColor")); |
307 |
iliev |
1285 |
private final JSColorButton btnHlChnBgColor = new JSColorButton(Color.WHITE); |
308 |
iliev |
1143 |
|
309 |
iliev |
787 |
public |
310 |
|
|
ViewPane() { initViewPane(); } |
311 |
|
|
|
312 |
|
|
private void |
313 |
|
|
initViewPane() { |
314 |
|
|
cbIfaceLanguage.setMaximumSize ( |
315 |
|
|
new Dimension(Short.MAX_VALUE, cbIfaceLanguage.getPreferredSize().height) |
316 |
|
|
); |
317 |
|
|
|
318 |
|
|
for(Locale l : JSI18n.getAvailableLocales()) { |
319 |
|
|
LocaleBox box = new LocaleBox(l); |
320 |
|
|
cbIfaceLanguage.addItem(box); |
321 |
|
|
if ( l.getLanguage().equals(Prefs.getInterfaceLanguage()) && |
322 |
|
|
l.getCountry().equals(Prefs.getInterfaceCountry()) |
323 |
|
|
) cbIfaceLanguage.setSelectedItem(box); |
324 |
|
|
} |
325 |
|
|
|
326 |
|
|
cbIfaceFont.setMaximumSize ( |
327 |
|
|
new Dimension(Short.MAX_VALUE, cbIfaceFont.getPreferredSize().height) |
328 |
|
|
); |
329 |
|
|
|
330 |
|
|
cbIfaceFont.addItem("[Default]"); |
331 |
|
|
|
332 |
|
|
String[] fontS = |
333 |
|
|
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); |
334 |
|
|
|
335 |
|
|
for(String f : fontS) cbIfaceFont.addItem(f); |
336 |
|
|
|
337 |
|
|
if(Prefs.getInterfaceFont() == null) cbIfaceFont.setSelectedItem("[Default]"); |
338 |
|
|
else cbIfaceFont.setSelectedItem(Prefs.getInterfaceFont()); |
339 |
|
|
|
340 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
341 |
|
|
|
342 |
|
|
JPanel ifacePane = new JPanel(); |
343 |
|
|
ifacePane.setLayout(new BoxLayout(ifacePane, BoxLayout.X_AXIS)); |
344 |
|
|
ifacePane.add(lIfaceLanguage); |
345 |
|
|
ifacePane.add(Box.createRigidArea(new Dimension(5, 0))); |
346 |
|
|
ifacePane.add(cbIfaceLanguage); |
347 |
|
|
|
348 |
|
|
add(ifacePane); |
349 |
|
|
|
350 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
351 |
|
|
|
352 |
|
|
JPanel fontPane = new JPanel(); |
353 |
|
|
fontPane.setLayout(new BoxLayout(fontPane, BoxLayout.X_AXIS)); |
354 |
|
|
fontPane.add(lIfaceFont); |
355 |
|
|
fontPane.add(Box.createRigidArea(new Dimension(5, 0))); |
356 |
|
|
fontPane.add(cbIfaceFont); |
357 |
|
|
|
358 |
|
|
add(fontPane); |
359 |
iliev |
842 |
add(Box.createRigidArea(new Dimension(0, 6))); |
360 |
|
|
add(createCustomColorsPane()); |
361 |
|
|
|
362 |
iliev |
787 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
363 |
|
|
} |
364 |
|
|
|
365 |
iliev |
842 |
private JPanel |
366 |
|
|
createCustomColorsPane() { |
367 |
|
|
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
368 |
|
|
btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor()); |
369 |
|
|
|
370 |
|
|
checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor()); |
371 |
|
|
|
372 |
|
|
checkBorderColor.addItemListener(new ItemListener() { |
373 |
|
|
public void |
374 |
|
|
itemStateChanged(ItemEvent e) { |
375 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
376 |
|
|
btnBorderColor.setEnabled(b); |
377 |
|
|
} |
378 |
|
|
}); |
379 |
|
|
|
380 |
iliev |
1143 |
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
381 |
|
|
btnHlChnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderHlColor()); |
382 |
iliev |
842 |
|
383 |
iliev |
1143 |
checkHlChnBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderHlColor()); |
384 |
|
|
|
385 |
|
|
checkHlChnBorderColor.addItemListener(new ItemListener() { |
386 |
|
|
public void |
387 |
|
|
itemStateChanged(ItemEvent e) { |
388 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
389 |
|
|
btnHlChnBorderColor.setEnabled(b); |
390 |
|
|
} |
391 |
|
|
}); |
392 |
|
|
|
393 |
|
|
Color color = ClassicPrefs.getSelectedChannelBgColor(); |
394 |
|
|
if(color == null) color = new Color(getBackground().getRGB()); |
395 |
|
|
btnSelChnBgColor.setColor(color); |
396 |
|
|
btnSelChnBgColor.setEnabled(ClassicPrefs.getCustomSelectedChannelBgColor()); |
397 |
|
|
|
398 |
|
|
checkSelChnBgColor.setSelected(ClassicPrefs.getCustomSelectedChannelBgColor()); |
399 |
|
|
|
400 |
|
|
checkSelChnBgColor.addItemListener(new ItemListener() { |
401 |
|
|
public void |
402 |
|
|
itemStateChanged(ItemEvent e) { |
403 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
404 |
|
|
btnSelChnBgColor.setEnabled(b); |
405 |
|
|
} |
406 |
|
|
}); |
407 |
|
|
|
408 |
|
|
color = ClassicPrefs.getHighlightedChannelBgColor(); |
409 |
|
|
if(color == null) color = new Color(getBackground().getRGB()); |
410 |
|
|
btnHlChnBgColor.setColor(color); |
411 |
|
|
btnHlChnBgColor.setEnabled(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
412 |
|
|
|
413 |
|
|
checkHlChnBgColor.setSelected(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
414 |
|
|
|
415 |
|
|
checkHlChnBgColor.addItemListener(new ItemListener() { |
416 |
|
|
public void |
417 |
|
|
itemStateChanged(ItemEvent e) { |
418 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
419 |
|
|
btnHlChnBgColor.setEnabled(b); |
420 |
|
|
} |
421 |
|
|
}); |
422 |
|
|
|
423 |
iliev |
842 |
JButton btnDefaults = new JButton("Reset to defaults"); |
424 |
|
|
btnDefaults.addActionListener(new ActionListener() { |
425 |
|
|
public void |
426 |
|
|
actionPerformed(ActionEvent e) { |
427 |
|
|
ClassicPrefs.setChannelBorderColor(null); |
428 |
|
|
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
429 |
iliev |
1143 |
|
430 |
|
|
ClassicPrefs.setChannelBorderHlColor(null); |
431 |
|
|
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
432 |
|
|
|
433 |
|
|
ClassicPrefs.setSelectedChannelBgColor(null); |
434 |
|
|
btnSelChnBgColor.setColor(ClassicPrefs.getSelectedChannelBgColor()); |
435 |
|
|
|
436 |
|
|
ClassicPrefs.setHighlightedChannelBgColor(null); |
437 |
|
|
btnHlChnBgColor.setColor(ClassicPrefs.getHighlightedChannelBgColor()); |
438 |
iliev |
842 |
} |
439 |
|
|
}); |
440 |
|
|
|
441 |
iliev |
1143 |
GridBagLayout gridbag = new GridBagLayout(); |
442 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
443 |
|
|
|
444 |
|
|
JPanel ccp = new JPanel(); |
445 |
|
|
ccp.setLayout(gridbag); |
446 |
|
|
|
447 |
|
|
c.fill = GridBagConstraints.NONE; |
448 |
|
|
|
449 |
|
|
c.gridx = 0; |
450 |
|
|
c.gridy = 0; |
451 |
|
|
c.anchor = GridBagConstraints.WEST; |
452 |
|
|
c.insets = new Insets(0, 3, 3, 3); |
453 |
|
|
gridbag.setConstraints(checkBorderColor, c); |
454 |
|
|
ccp.add(checkBorderColor); |
455 |
|
|
|
456 |
|
|
|
457 |
|
|
c.gridx = 1; |
458 |
|
|
c.gridy = 0; |
459 |
|
|
gridbag.setConstraints(btnBorderColor, c); |
460 |
|
|
ccp.add(btnBorderColor); |
461 |
|
|
|
462 |
|
|
c.gridx = 0; |
463 |
|
|
c.gridy = 1; |
464 |
|
|
gridbag.setConstraints(checkHlChnBorderColor, c); |
465 |
|
|
ccp.add(checkHlChnBorderColor); |
466 |
|
|
|
467 |
|
|
c.gridx = 1; |
468 |
|
|
c.gridy = 1; |
469 |
|
|
gridbag.setConstraints(btnHlChnBorderColor, c); |
470 |
|
|
ccp.add(btnHlChnBorderColor); |
471 |
|
|
|
472 |
|
|
c.gridx = 0; |
473 |
|
|
c.gridy = 2; |
474 |
|
|
gridbag.setConstraints(checkSelChnBgColor, c); |
475 |
|
|
ccp.add(checkSelChnBgColor); |
476 |
|
|
|
477 |
|
|
c.gridx = 1; |
478 |
|
|
c.gridy = 2; |
479 |
|
|
gridbag.setConstraints(btnSelChnBgColor, c); |
480 |
|
|
ccp.add(btnSelChnBgColor); |
481 |
|
|
|
482 |
|
|
c.gridx = 0; |
483 |
|
|
c.gridy = 3; |
484 |
|
|
gridbag.setConstraints(checkHlChnBgColor, c); |
485 |
|
|
ccp.add(checkHlChnBgColor); |
486 |
|
|
|
487 |
|
|
c.gridx = 1; |
488 |
|
|
c.gridy = 3; |
489 |
|
|
gridbag.setConstraints(btnHlChnBgColor, c); |
490 |
|
|
ccp.add(btnHlChnBgColor); |
491 |
|
|
|
492 |
|
|
JPanel p = new JPanel(); |
493 |
iliev |
842 |
p.setAlignmentX(LEFT_ALIGNMENT); |
494 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
495 |
|
|
p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6)); |
496 |
|
|
p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); |
497 |
|
|
|
498 |
|
|
p.add(Box.createGlue()); |
499 |
|
|
p.add(btnDefaults); |
500 |
|
|
p.add(Box.createGlue()); |
501 |
|
|
|
502 |
iliev |
1143 |
c.fill = GridBagConstraints.HORIZONTAL; |
503 |
|
|
c.gridx = 0; |
504 |
|
|
c.gridy = 4; |
505 |
|
|
c.gridwidth = 2; |
506 |
|
|
c.weightx = 1.0; |
507 |
|
|
c.anchor = GridBagConstraints.CENTER; |
508 |
|
|
gridbag.setConstraints(p, c); |
509 |
iliev |
842 |
ccp.add(p); |
510 |
iliev |
1143 |
|
511 |
iliev |
842 |
ccp.setBorder ( |
512 |
|
|
BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane")) |
513 |
|
|
); |
514 |
|
|
|
515 |
iliev |
911 |
ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, ccp.getPreferredSize().height)); |
516 |
iliev |
842 |
|
517 |
|
|
return ccp; |
518 |
|
|
} |
519 |
|
|
|
520 |
|
|
private String |
521 |
iliev |
787 |
getInterfaceLanguage() { |
522 |
|
|
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
523 |
|
|
if(box == null) return null; |
524 |
|
|
return box.getLocale().getLanguage(); |
525 |
|
|
} |
526 |
|
|
|
527 |
iliev |
842 |
private String |
528 |
iliev |
787 |
getInterfaceCountry() { |
529 |
|
|
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
530 |
|
|
if(box == null) return null; |
531 |
|
|
return box.getLocale().getCountry(); |
532 |
|
|
} |
533 |
|
|
|
534 |
iliev |
842 |
private String |
535 |
iliev |
787 |
getInterfaceFontName() { return cbIfaceFont.getSelectedItem().toString(); } |
536 |
|
|
|
537 |
iliev |
842 |
protected void |
538 |
|
|
apply() { |
539 |
|
|
boolean b = Prefs.setInterfaceLanguage(getInterfaceLanguage()); |
540 |
|
|
boolean b2 = Prefs.setInterfaceCountry(getInterfaceCountry()); |
541 |
|
|
if (b || b2) JOptionPane.showMessageDialog ( |
542 |
|
|
this, |
543 |
|
|
i18n.getMessage("PrefsDlg.ifaceChangeInfo", "JS Classic"), |
544 |
|
|
null, |
545 |
|
|
JOptionPane.INFORMATION_MESSAGE |
546 |
|
|
); |
547 |
|
|
|
548 |
|
|
b = false; |
549 |
|
|
String fontName = getInterfaceFontName(); |
550 |
|
|
if(fontName.equals("[Default]")) { |
551 |
|
|
b = Prefs.setInterfaceFont(null); |
552 |
|
|
} else if(Prefs.setInterfaceFont(fontName)) { |
553 |
|
|
HF.setUIDefaultFont(fontName); |
554 |
|
|
b = true; |
555 |
|
|
} |
556 |
|
|
|
557 |
|
|
if(b) JOptionPane.showMessageDialog ( |
558 |
|
|
this, |
559 |
|
|
i18n.getMessage("PrefsDlg.ifaceFontChangeInfo", "JS Classic"), |
560 |
|
|
null, |
561 |
|
|
JOptionPane.INFORMATION_MESSAGE |
562 |
|
|
); |
563 |
|
|
|
564 |
|
|
///***/// |
565 |
|
|
|
566 |
|
|
b = checkBorderColor.isSelected(); |
567 |
|
|
ClassicPrefs.setCustomChannelBorderColor(b); |
568 |
|
|
if(b) ClassicPrefs.setChannelBorderColor(btnBorderColor.getColor()); |
569 |
|
|
|
570 |
|
|
Color c; |
571 |
|
|
if(b) c = ClassicPrefs.getChannelBorderColor(); |
572 |
|
|
else c = ClassicPrefs.getDefaultChannelBorderColor(); |
573 |
|
|
Channel.setBorderColor(c); |
574 |
iliev |
1143 |
|
575 |
|
|
b = checkHlChnBorderColor.isSelected(); |
576 |
|
|
ClassicPrefs.setCustomChannelBorderHlColor(b); |
577 |
|
|
if(b) ClassicPrefs.setChannelBorderHlColor(btnHlChnBorderColor.getColor()); |
578 |
|
|
|
579 |
|
|
if(b) c = ClassicPrefs.getChannelBorderHlColor(); |
580 |
|
|
else c = ClassicPrefs.getDefaultChannelBorderHlColor(); |
581 |
|
|
Channel.setBorderHighlightedColor(c); |
582 |
|
|
|
583 |
|
|
b = checkSelChnBgColor.isSelected(); |
584 |
|
|
ClassicPrefs.setCustomSelectedChannelBgColor(b); |
585 |
|
|
if(b) ClassicPrefs.setSelectedChannelBgColor(btnSelChnBgColor.getColor()); |
586 |
|
|
|
587 |
|
|
if(b) c = ClassicPrefs.getSelectedChannelBgColor(); |
588 |
|
|
else c = new Color(getBackground().getRGB()); |
589 |
|
|
if(c == null) c = new Color(getBackground().getRGB()); |
590 |
|
|
Channel.setSelectedChannelBgColor(c); |
591 |
|
|
|
592 |
|
|
b = checkHlChnBgColor.isSelected(); |
593 |
|
|
ClassicPrefs.setCustomHighlightedChannelBgColor(b); |
594 |
|
|
if(b) ClassicPrefs.setHighlightedChannelBgColor(btnHlChnBgColor.getColor()); |
595 |
|
|
|
596 |
|
|
if(b) c = ClassicPrefs.getHighlightedChannelBgColor(); |
597 |
|
|
else c = new Color(getBackground().getRGB()); |
598 |
|
|
if(c == null) c = new Color(getBackground().getRGB()); |
599 |
|
|
Channel.setHighlightedChannelBgColor(c); |
600 |
iliev |
842 |
} |
601 |
|
|
|
602 |
iliev |
787 |
class LocaleBox { |
603 |
|
|
private Locale locale; |
604 |
|
|
|
605 |
|
|
LocaleBox(Locale locale) { this.locale = locale; } |
606 |
|
|
|
607 |
|
|
public Locale |
608 |
|
|
getLocale() { return locale; } |
609 |
|
|
|
610 |
|
|
public String |
611 |
|
|
toString() { return locale.getDisplayLanguage(JSI18n.i18n.getCurrentLocale()); } |
612 |
|
|
} |
613 |
iliev |
911 |
} |
614 |
|
|
|
615 |
iliev |
1285 |
class ConsolePane extends JSLSConsolePropsPane { |
616 |
|
|
protected void |
617 |
|
|
clearConsoleHistory() { |
618 |
|
|
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
619 |
|
|
mainFrame.getLSConsoleModel().clearCommandHistory(); |
620 |
iliev |
1143 |
} |
621 |
|
|
|
622 |
iliev |
911 |
protected void |
623 |
|
|
apply() { |
624 |
iliev |
1285 |
super.apply(); |
625 |
iliev |
1143 |
|
626 |
iliev |
911 |
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
627 |
iliev |
842 |
|
628 |
iliev |
1285 |
LSConsoleModel model = mainFrame.getLSConsoleModel(); |
629 |
|
|
model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE)); |
630 |
iliev |
842 |
|
631 |
iliev |
1285 |
int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR); |
632 |
|
|
mainFrame.setLSConsoleTextColor(new Color(c)); |
633 |
iliev |
842 |
|
634 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR); |
635 |
|
|
mainFrame.setLSConsoleBackgroundColor(new Color(c)); |
636 |
iliev |
911 |
|
637 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR); |
638 |
|
|
mainFrame.setLSConsoleNotifyColor(new Color(c)); |
639 |
iliev |
911 |
|
640 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR); |
641 |
|
|
mainFrame.setLSConsoleWarningColor(new Color(c)); |
642 |
iliev |
787 |
|
643 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR); |
644 |
|
|
mainFrame.setLSConsoleErrorColor(new Color(c)); |
645 |
iliev |
787 |
} |
646 |
|
|
} |