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