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 |
1285 |
private final JSGeneralProps.JSamplerHomePane jSamplerHomePane = |
194 |
|
|
new JSGeneralProps.JSamplerHomePane(); |
195 |
iliev |
1143 |
|
196 |
iliev |
1285 |
private final RecentScriptsPane recentScriptsPane = new RecentScriptsPane(); |
197 |
iliev |
911 |
|
198 |
|
|
|
199 |
iliev |
787 |
public |
200 |
iliev |
911 |
GeneralPane() { |
201 |
iliev |
842 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
202 |
iliev |
787 |
|
203 |
iliev |
911 |
checkWindowSizeAndLocation.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
204 |
iliev |
842 |
|
205 |
iliev |
911 |
checkWindowSizeAndLocation.setSelected(ClassicPrefs.getSaveWindowProperties()); |
206 |
iliev |
842 |
checkWindowSizeAndLocation.addItemListener(new ItemListener() { |
207 |
|
|
public void |
208 |
|
|
itemStateChanged(ItemEvent e) { |
209 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
210 |
iliev |
911 |
//checkWindowSizeAndLocation.setEnabled(b); |
211 |
iliev |
842 |
} |
212 |
|
|
}); |
213 |
|
|
|
214 |
iliev |
911 |
add(checkWindowSizeAndLocation); |
215 |
iliev |
842 |
|
216 |
iliev |
911 |
checkLeftPaneState.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
217 |
|
|
checkLeftPaneState.setSelected(ClassicPrefs.getSaveLeftPaneState()); |
218 |
|
|
add(checkLeftPaneState); |
219 |
|
|
|
220 |
|
|
checkShowLSConsoleWhenRunScript.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
221 |
|
|
|
222 |
iliev |
1285 |
boolean b = preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT); |
223 |
iliev |
911 |
checkShowLSConsoleWhenRunScript.setSelected(b); |
224 |
|
|
|
225 |
|
|
add(checkShowLSConsoleWhenRunScript); |
226 |
|
|
|
227 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
228 |
|
|
|
229 |
iliev |
1285 |
add(jSamplerHomePane); |
230 |
iliev |
1143 |
|
231 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
232 |
|
|
|
233 |
iliev |
1285 |
add(recentScriptsPane); |
234 |
iliev |
911 |
add(Box.createGlue()); |
235 |
|
|
|
236 |
|
|
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
237 |
iliev |
787 |
} |
238 |
iliev |
842 |
|
239 |
|
|
protected void |
240 |
|
|
apply() { |
241 |
iliev |
911 |
ClassicPrefs.setSaveWindowProperties(checkWindowSizeAndLocation.isSelected()); |
242 |
|
|
ClassicPrefs.setSaveLeftPaneState(checkLeftPaneState.isSelected()); |
243 |
|
|
|
244 |
|
|
boolean b = checkShowLSConsoleWhenRunScript.isSelected(); |
245 |
iliev |
1285 |
preferences().setBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT, b); |
246 |
iliev |
911 |
|
247 |
iliev |
1285 |
int size = recentScriptsPane.getRecentScriptsSize(); |
248 |
|
|
preferences().setIntProperty(RECENT_LSCP_SCRIPTS_SIZE, size); |
249 |
iliev |
911 |
((MainFrame)CC.getMainFrame()).updateRecentScriptsMenu(); |
250 |
iliev |
1143 |
|
251 |
iliev |
1285 |
String s = jSamplerHomePane.getJSamplerHome(); |
252 |
iliev |
1143 |
if(s.length() > 0 && !s.equals(CC.getJSamplerHome())) { |
253 |
|
|
CC.changeJSamplerHome(s); |
254 |
|
|
} |
255 |
iliev |
842 |
} |
256 |
iliev |
1285 |
|
257 |
|
|
private class RecentScriptsPane extends JSGeneralProps.RecentScriptsPane { |
258 |
|
|
protected void |
259 |
|
|
clearRecentScripts() { |
260 |
|
|
((MainFrame)CC.getMainFrame()).clearRecentScripts(); |
261 |
|
|
} |
262 |
|
|
} |
263 |
iliev |
787 |
} |
264 |
|
|
|
265 |
|
|
class ViewPane extends JPanel { |
266 |
|
|
private final JLabel lIfaceLanguage = |
267 |
|
|
new JLabel(i18n.getLabel("ViewPane.lIfaceLanguage")); |
268 |
|
|
private final JComboBox cbIfaceLanguage = new JComboBox(); |
269 |
|
|
|
270 |
|
|
private final JLabel lIfaceFont = |
271 |
|
|
new JLabel(i18n.getLabel("ViewPane.lIfaceFont")); |
272 |
|
|
private final JComboBox cbIfaceFont = new JComboBox(); |
273 |
|
|
|
274 |
iliev |
842 |
private final JCheckBox checkBorderColor = |
275 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.channelBorderColor")); |
276 |
iliev |
1285 |
private final JSColorButton btnBorderColor = new JSColorButton(Color.WHITE); |
277 |
iliev |
842 |
|
278 |
iliev |
1143 |
private final JCheckBox checkHlChnBorderColor = |
279 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBorderColor")); |
280 |
iliev |
1285 |
private final JSColorButton btnHlChnBorderColor = new JSColorButton(Color.WHITE); |
281 |
iliev |
1143 |
|
282 |
|
|
private final JCheckBox checkSelChnBgColor = |
283 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkSelChnBgColor")); |
284 |
iliev |
1285 |
private final JSColorButton btnSelChnBgColor = new JSColorButton(Color.WHITE); |
285 |
iliev |
1143 |
|
286 |
|
|
private final JCheckBox checkHlChnBgColor = |
287 |
|
|
new JCheckBox(i18n.getLabel("ViewPane.checkHlChnBgColor")); |
288 |
iliev |
1285 |
private final JSColorButton btnHlChnBgColor = new JSColorButton(Color.WHITE); |
289 |
iliev |
1143 |
|
290 |
iliev |
787 |
public |
291 |
|
|
ViewPane() { initViewPane(); } |
292 |
|
|
|
293 |
|
|
private void |
294 |
|
|
initViewPane() { |
295 |
|
|
cbIfaceLanguage.setMaximumSize ( |
296 |
|
|
new Dimension(Short.MAX_VALUE, cbIfaceLanguage.getPreferredSize().height) |
297 |
|
|
); |
298 |
|
|
|
299 |
|
|
for(Locale l : JSI18n.getAvailableLocales()) { |
300 |
|
|
LocaleBox box = new LocaleBox(l); |
301 |
|
|
cbIfaceLanguage.addItem(box); |
302 |
|
|
if ( l.getLanguage().equals(Prefs.getInterfaceLanguage()) && |
303 |
|
|
l.getCountry().equals(Prefs.getInterfaceCountry()) |
304 |
|
|
) cbIfaceLanguage.setSelectedItem(box); |
305 |
|
|
} |
306 |
|
|
|
307 |
|
|
cbIfaceFont.setMaximumSize ( |
308 |
|
|
new Dimension(Short.MAX_VALUE, cbIfaceFont.getPreferredSize().height) |
309 |
|
|
); |
310 |
|
|
|
311 |
|
|
cbIfaceFont.addItem("[Default]"); |
312 |
|
|
|
313 |
|
|
String[] fontS = |
314 |
|
|
GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); |
315 |
|
|
|
316 |
|
|
for(String f : fontS) cbIfaceFont.addItem(f); |
317 |
|
|
|
318 |
|
|
if(Prefs.getInterfaceFont() == null) cbIfaceFont.setSelectedItem("[Default]"); |
319 |
|
|
else cbIfaceFont.setSelectedItem(Prefs.getInterfaceFont()); |
320 |
|
|
|
321 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
322 |
|
|
|
323 |
|
|
JPanel ifacePane = new JPanel(); |
324 |
|
|
ifacePane.setLayout(new BoxLayout(ifacePane, BoxLayout.X_AXIS)); |
325 |
|
|
ifacePane.add(lIfaceLanguage); |
326 |
|
|
ifacePane.add(Box.createRigidArea(new Dimension(5, 0))); |
327 |
|
|
ifacePane.add(cbIfaceLanguage); |
328 |
|
|
|
329 |
|
|
add(ifacePane); |
330 |
|
|
|
331 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
332 |
|
|
|
333 |
|
|
JPanel fontPane = new JPanel(); |
334 |
|
|
fontPane.setLayout(new BoxLayout(fontPane, BoxLayout.X_AXIS)); |
335 |
|
|
fontPane.add(lIfaceFont); |
336 |
|
|
fontPane.add(Box.createRigidArea(new Dimension(5, 0))); |
337 |
|
|
fontPane.add(cbIfaceFont); |
338 |
|
|
|
339 |
|
|
add(fontPane); |
340 |
iliev |
842 |
add(Box.createRigidArea(new Dimension(0, 6))); |
341 |
|
|
add(createCustomColorsPane()); |
342 |
|
|
|
343 |
iliev |
787 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
344 |
|
|
} |
345 |
|
|
|
346 |
iliev |
842 |
private JPanel |
347 |
|
|
createCustomColorsPane() { |
348 |
|
|
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
349 |
|
|
btnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderColor()); |
350 |
|
|
|
351 |
|
|
checkBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderColor()); |
352 |
|
|
|
353 |
|
|
checkBorderColor.addItemListener(new ItemListener() { |
354 |
|
|
public void |
355 |
|
|
itemStateChanged(ItemEvent e) { |
356 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
357 |
|
|
btnBorderColor.setEnabled(b); |
358 |
|
|
} |
359 |
|
|
}); |
360 |
|
|
|
361 |
iliev |
1143 |
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
362 |
|
|
btnHlChnBorderColor.setEnabled(ClassicPrefs.getCustomChannelBorderHlColor()); |
363 |
iliev |
842 |
|
364 |
iliev |
1143 |
checkHlChnBorderColor.setSelected(ClassicPrefs.getCustomChannelBorderHlColor()); |
365 |
|
|
|
366 |
|
|
checkHlChnBorderColor.addItemListener(new ItemListener() { |
367 |
|
|
public void |
368 |
|
|
itemStateChanged(ItemEvent e) { |
369 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
370 |
|
|
btnHlChnBorderColor.setEnabled(b); |
371 |
|
|
} |
372 |
|
|
}); |
373 |
|
|
|
374 |
|
|
Color color = ClassicPrefs.getSelectedChannelBgColor(); |
375 |
|
|
if(color == null) color = new Color(getBackground().getRGB()); |
376 |
|
|
btnSelChnBgColor.setColor(color); |
377 |
|
|
btnSelChnBgColor.setEnabled(ClassicPrefs.getCustomSelectedChannelBgColor()); |
378 |
|
|
|
379 |
|
|
checkSelChnBgColor.setSelected(ClassicPrefs.getCustomSelectedChannelBgColor()); |
380 |
|
|
|
381 |
|
|
checkSelChnBgColor.addItemListener(new ItemListener() { |
382 |
|
|
public void |
383 |
|
|
itemStateChanged(ItemEvent e) { |
384 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
385 |
|
|
btnSelChnBgColor.setEnabled(b); |
386 |
|
|
} |
387 |
|
|
}); |
388 |
|
|
|
389 |
|
|
color = ClassicPrefs.getHighlightedChannelBgColor(); |
390 |
|
|
if(color == null) color = new Color(getBackground().getRGB()); |
391 |
|
|
btnHlChnBgColor.setColor(color); |
392 |
|
|
btnHlChnBgColor.setEnabled(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
393 |
|
|
|
394 |
|
|
checkHlChnBgColor.setSelected(ClassicPrefs.getCustomHighlightedChannelBgColor()); |
395 |
|
|
|
396 |
|
|
checkHlChnBgColor.addItemListener(new ItemListener() { |
397 |
|
|
public void |
398 |
|
|
itemStateChanged(ItemEvent e) { |
399 |
|
|
boolean b = e.getStateChange() == e.SELECTED; |
400 |
|
|
btnHlChnBgColor.setEnabled(b); |
401 |
|
|
} |
402 |
|
|
}); |
403 |
|
|
|
404 |
iliev |
842 |
JButton btnDefaults = new JButton("Reset to defaults"); |
405 |
|
|
btnDefaults.addActionListener(new ActionListener() { |
406 |
|
|
public void |
407 |
|
|
actionPerformed(ActionEvent e) { |
408 |
|
|
ClassicPrefs.setChannelBorderColor(null); |
409 |
|
|
btnBorderColor.setColor(ClassicPrefs.getChannelBorderColor()); |
410 |
iliev |
1143 |
|
411 |
|
|
ClassicPrefs.setChannelBorderHlColor(null); |
412 |
|
|
btnHlChnBorderColor.setColor(ClassicPrefs.getChannelBorderHlColor()); |
413 |
|
|
|
414 |
|
|
ClassicPrefs.setSelectedChannelBgColor(null); |
415 |
|
|
btnSelChnBgColor.setColor(ClassicPrefs.getSelectedChannelBgColor()); |
416 |
|
|
|
417 |
|
|
ClassicPrefs.setHighlightedChannelBgColor(null); |
418 |
|
|
btnHlChnBgColor.setColor(ClassicPrefs.getHighlightedChannelBgColor()); |
419 |
iliev |
842 |
} |
420 |
|
|
}); |
421 |
|
|
|
422 |
iliev |
1143 |
GridBagLayout gridbag = new GridBagLayout(); |
423 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
424 |
|
|
|
425 |
|
|
JPanel ccp = new JPanel(); |
426 |
|
|
ccp.setLayout(gridbag); |
427 |
|
|
|
428 |
|
|
c.fill = GridBagConstraints.NONE; |
429 |
|
|
|
430 |
|
|
c.gridx = 0; |
431 |
|
|
c.gridy = 0; |
432 |
|
|
c.anchor = GridBagConstraints.WEST; |
433 |
|
|
c.insets = new Insets(0, 3, 3, 3); |
434 |
|
|
gridbag.setConstraints(checkBorderColor, c); |
435 |
|
|
ccp.add(checkBorderColor); |
436 |
|
|
|
437 |
|
|
|
438 |
|
|
c.gridx = 1; |
439 |
|
|
c.gridy = 0; |
440 |
|
|
gridbag.setConstraints(btnBorderColor, c); |
441 |
|
|
ccp.add(btnBorderColor); |
442 |
|
|
|
443 |
|
|
c.gridx = 0; |
444 |
|
|
c.gridy = 1; |
445 |
|
|
gridbag.setConstraints(checkHlChnBorderColor, c); |
446 |
|
|
ccp.add(checkHlChnBorderColor); |
447 |
|
|
|
448 |
|
|
c.gridx = 1; |
449 |
|
|
c.gridy = 1; |
450 |
|
|
gridbag.setConstraints(btnHlChnBorderColor, c); |
451 |
|
|
ccp.add(btnHlChnBorderColor); |
452 |
|
|
|
453 |
|
|
c.gridx = 0; |
454 |
|
|
c.gridy = 2; |
455 |
|
|
gridbag.setConstraints(checkSelChnBgColor, c); |
456 |
|
|
ccp.add(checkSelChnBgColor); |
457 |
|
|
|
458 |
|
|
c.gridx = 1; |
459 |
|
|
c.gridy = 2; |
460 |
|
|
gridbag.setConstraints(btnSelChnBgColor, c); |
461 |
|
|
ccp.add(btnSelChnBgColor); |
462 |
|
|
|
463 |
|
|
c.gridx = 0; |
464 |
|
|
c.gridy = 3; |
465 |
|
|
gridbag.setConstraints(checkHlChnBgColor, c); |
466 |
|
|
ccp.add(checkHlChnBgColor); |
467 |
|
|
|
468 |
|
|
c.gridx = 1; |
469 |
|
|
c.gridy = 3; |
470 |
|
|
gridbag.setConstraints(btnHlChnBgColor, c); |
471 |
|
|
ccp.add(btnHlChnBgColor); |
472 |
|
|
|
473 |
|
|
JPanel p = new JPanel(); |
474 |
iliev |
842 |
p.setAlignmentX(LEFT_ALIGNMENT); |
475 |
|
|
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
476 |
|
|
p.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 6)); |
477 |
|
|
p.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)); |
478 |
|
|
|
479 |
|
|
p.add(Box.createGlue()); |
480 |
|
|
p.add(btnDefaults); |
481 |
|
|
p.add(Box.createGlue()); |
482 |
|
|
|
483 |
iliev |
1143 |
c.fill = GridBagConstraints.HORIZONTAL; |
484 |
|
|
c.gridx = 0; |
485 |
|
|
c.gridy = 4; |
486 |
|
|
c.gridwidth = 2; |
487 |
|
|
c.weightx = 1.0; |
488 |
|
|
c.anchor = GridBagConstraints.CENTER; |
489 |
|
|
gridbag.setConstraints(p, c); |
490 |
iliev |
842 |
ccp.add(p); |
491 |
iliev |
1143 |
|
492 |
iliev |
842 |
ccp.setBorder ( |
493 |
|
|
BorderFactory.createTitledBorder(i18n.getLabel("ViewPane.CustomColorsPane")) |
494 |
|
|
); |
495 |
|
|
|
496 |
iliev |
911 |
ccp.setMaximumSize(new Dimension(Short.MAX_VALUE, ccp.getPreferredSize().height)); |
497 |
iliev |
842 |
|
498 |
|
|
return ccp; |
499 |
|
|
} |
500 |
|
|
|
501 |
|
|
private String |
502 |
iliev |
787 |
getInterfaceLanguage() { |
503 |
|
|
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
504 |
|
|
if(box == null) return null; |
505 |
|
|
return box.getLocale().getLanguage(); |
506 |
|
|
} |
507 |
|
|
|
508 |
iliev |
842 |
private String |
509 |
iliev |
787 |
getInterfaceCountry() { |
510 |
|
|
LocaleBox box = (LocaleBox)cbIfaceLanguage.getSelectedItem(); |
511 |
|
|
if(box == null) return null; |
512 |
|
|
return box.getLocale().getCountry(); |
513 |
|
|
} |
514 |
|
|
|
515 |
iliev |
842 |
private String |
516 |
iliev |
787 |
getInterfaceFontName() { return cbIfaceFont.getSelectedItem().toString(); } |
517 |
|
|
|
518 |
iliev |
842 |
protected void |
519 |
|
|
apply() { |
520 |
|
|
boolean b = Prefs.setInterfaceLanguage(getInterfaceLanguage()); |
521 |
|
|
boolean b2 = Prefs.setInterfaceCountry(getInterfaceCountry()); |
522 |
|
|
if (b || b2) JOptionPane.showMessageDialog ( |
523 |
|
|
this, |
524 |
|
|
i18n.getMessage("PrefsDlg.ifaceChangeInfo", "JS Classic"), |
525 |
|
|
null, |
526 |
|
|
JOptionPane.INFORMATION_MESSAGE |
527 |
|
|
); |
528 |
|
|
|
529 |
|
|
b = false; |
530 |
|
|
String fontName = getInterfaceFontName(); |
531 |
|
|
if(fontName.equals("[Default]")) { |
532 |
|
|
b = Prefs.setInterfaceFont(null); |
533 |
|
|
} else if(Prefs.setInterfaceFont(fontName)) { |
534 |
|
|
HF.setUIDefaultFont(fontName); |
535 |
|
|
b = true; |
536 |
|
|
} |
537 |
|
|
|
538 |
|
|
if(b) JOptionPane.showMessageDialog ( |
539 |
|
|
this, |
540 |
|
|
i18n.getMessage("PrefsDlg.ifaceFontChangeInfo", "JS Classic"), |
541 |
|
|
null, |
542 |
|
|
JOptionPane.INFORMATION_MESSAGE |
543 |
|
|
); |
544 |
|
|
|
545 |
|
|
///***/// |
546 |
|
|
|
547 |
|
|
b = checkBorderColor.isSelected(); |
548 |
|
|
ClassicPrefs.setCustomChannelBorderColor(b); |
549 |
|
|
if(b) ClassicPrefs.setChannelBorderColor(btnBorderColor.getColor()); |
550 |
|
|
|
551 |
|
|
Color c; |
552 |
|
|
if(b) c = ClassicPrefs.getChannelBorderColor(); |
553 |
|
|
else c = ClassicPrefs.getDefaultChannelBorderColor(); |
554 |
|
|
Channel.setBorderColor(c); |
555 |
iliev |
1143 |
|
556 |
|
|
b = checkHlChnBorderColor.isSelected(); |
557 |
|
|
ClassicPrefs.setCustomChannelBorderHlColor(b); |
558 |
|
|
if(b) ClassicPrefs.setChannelBorderHlColor(btnHlChnBorderColor.getColor()); |
559 |
|
|
|
560 |
|
|
if(b) c = ClassicPrefs.getChannelBorderHlColor(); |
561 |
|
|
else c = ClassicPrefs.getDefaultChannelBorderHlColor(); |
562 |
|
|
Channel.setBorderHighlightedColor(c); |
563 |
|
|
|
564 |
|
|
b = checkSelChnBgColor.isSelected(); |
565 |
|
|
ClassicPrefs.setCustomSelectedChannelBgColor(b); |
566 |
|
|
if(b) ClassicPrefs.setSelectedChannelBgColor(btnSelChnBgColor.getColor()); |
567 |
|
|
|
568 |
|
|
if(b) c = ClassicPrefs.getSelectedChannelBgColor(); |
569 |
|
|
else c = new Color(getBackground().getRGB()); |
570 |
|
|
if(c == null) c = new Color(getBackground().getRGB()); |
571 |
|
|
Channel.setSelectedChannelBgColor(c); |
572 |
|
|
|
573 |
|
|
b = checkHlChnBgColor.isSelected(); |
574 |
|
|
ClassicPrefs.setCustomHighlightedChannelBgColor(b); |
575 |
|
|
if(b) ClassicPrefs.setHighlightedChannelBgColor(btnHlChnBgColor.getColor()); |
576 |
|
|
|
577 |
|
|
if(b) c = ClassicPrefs.getHighlightedChannelBgColor(); |
578 |
|
|
else c = new Color(getBackground().getRGB()); |
579 |
|
|
if(c == null) c = new Color(getBackground().getRGB()); |
580 |
|
|
Channel.setHighlightedChannelBgColor(c); |
581 |
iliev |
842 |
} |
582 |
|
|
|
583 |
iliev |
787 |
class LocaleBox { |
584 |
|
|
private Locale locale; |
585 |
|
|
|
586 |
|
|
LocaleBox(Locale locale) { this.locale = locale; } |
587 |
|
|
|
588 |
|
|
public Locale |
589 |
|
|
getLocale() { return locale; } |
590 |
|
|
|
591 |
|
|
public String |
592 |
|
|
toString() { return locale.getDisplayLanguage(JSI18n.i18n.getCurrentLocale()); } |
593 |
|
|
} |
594 |
iliev |
911 |
} |
595 |
|
|
|
596 |
iliev |
1285 |
class ConsolePane extends JSLSConsolePropsPane { |
597 |
|
|
protected void |
598 |
|
|
clearConsoleHistory() { |
599 |
|
|
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
600 |
|
|
mainFrame.getLSConsoleModel().clearCommandHistory(); |
601 |
iliev |
1143 |
} |
602 |
|
|
|
603 |
iliev |
911 |
protected void |
604 |
|
|
apply() { |
605 |
iliev |
1285 |
super.apply(); |
606 |
iliev |
1143 |
|
607 |
iliev |
911 |
MainFrame mainFrame = (MainFrame)CC.getMainFrame(); |
608 |
iliev |
842 |
|
609 |
iliev |
1285 |
LSConsoleModel model = mainFrame.getLSConsoleModel(); |
610 |
|
|
model.setCommandHistorySize(preferences().getIntProperty(LS_CONSOLE_HISTSIZE)); |
611 |
iliev |
842 |
|
612 |
iliev |
1285 |
int c = preferences().getIntProperty(LS_CONSOLE_TEXT_COLOR); |
613 |
|
|
mainFrame.setLSConsoleTextColor(new Color(c)); |
614 |
iliev |
842 |
|
615 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_BACKGROUND_COLOR); |
616 |
|
|
mainFrame.setLSConsoleBackgroundColor(new Color(c)); |
617 |
iliev |
911 |
|
618 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_NOTIFY_COLOR); |
619 |
|
|
mainFrame.setLSConsoleNotifyColor(new Color(c)); |
620 |
iliev |
911 |
|
621 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_WARNING_COLOR); |
622 |
|
|
mainFrame.setLSConsoleWarningColor(new Color(c)); |
623 |
iliev |
787 |
|
624 |
iliev |
1285 |
c = preferences().getIntProperty(LS_CONSOLE_ERROR_COLOR); |
625 |
|
|
mainFrame.setLSConsoleErrorColor(new Color(c)); |
626 |
iliev |
787 |
} |
627 |
|
|
} |