1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2008 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.fantasia; |
24 |
|
25 |
import java.awt.Color; |
26 |
import java.awt.Dialog; |
27 |
import java.awt.Dimension; |
28 |
import java.awt.Frame; |
29 |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
31 |
import java.awt.Insets; |
32 |
|
33 |
import java.awt.event.ActionEvent; |
34 |
import java.awt.event.ActionListener; |
35 |
|
36 |
import java.net.URL; |
37 |
|
38 |
import javax.swing.BorderFactory; |
39 |
import javax.swing.Box; |
40 |
import javax.swing.BoxLayout; |
41 |
import javax.swing.JButton; |
42 |
import javax.swing.JEditorPane; |
43 |
import javax.swing.JLabel; |
44 |
import javax.swing.JPanel; |
45 |
import javax.swing.JScrollPane; |
46 |
import javax.swing.JTabbedPane; |
47 |
|
48 |
import net.sf.juife.InformationDialog; |
49 |
import net.sf.juife.LinkButton; |
50 |
|
51 |
import org.jsampler.view.std.StdUtils; |
52 |
|
53 |
import org.jvnet.substance.SubstanceLookAndFeel; |
54 |
|
55 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
56 |
|
57 |
/** |
58 |
* |
59 |
* @author Grigor Iliev |
60 |
*/ |
61 |
public class HelpAboutDlg extends InformationDialog { |
62 |
private JLabel lProductName = |
63 |
new JLabel("<html>\n<font size=+1>JSampler Fantasia (version 0.8a cvs_6)</font>"); |
64 |
|
65 |
private JLabel lAuthor = new JLabel(i18n.getLabel("HelpAboutDlg.lAuthor")); |
66 |
private LinkButton btnAuthor = new Lnkbutton(i18n.getLabel("HelpAboutDlg.btnAuthor")); |
67 |
|
68 |
private JLabel lLicense = new JLabel(i18n.getLabel("HelpAboutDlg.lLicense")); |
69 |
private LinkButton btnLicense = new Lnkbutton("GNU General Public License v.2"); |
70 |
|
71 |
private JLabel lDesign = new JLabel(i18n.getLabel("HelpAboutDlg.lDesign")); |
72 |
|
73 |
private JLabel lCopyright = new JLabel(i18n.getLabel("HelpAboutDlg.lCopyright")); |
74 |
|
75 |
private JPanel mainPane = new JPanel(); |
76 |
|
77 |
/** Creates a new instance of <code>HelpAboutDlg</code> */ |
78 |
public |
79 |
HelpAboutDlg(Frame owner) { |
80 |
super(owner, i18n.getLabel("HelpAboutDlg.title")); |
81 |
|
82 |
mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); |
83 |
|
84 |
lProductName.setHorizontalAlignment(JLabel.CENTER); |
85 |
lProductName.setAlignmentX(LEFT_ALIGNMENT); |
86 |
mainPane.add(lProductName); |
87 |
mainPane.add(Box.createRigidArea(new Dimension(0, 12))); |
88 |
|
89 |
JTabbedPane tp = new JTabbedPane(); |
90 |
tp.addTab(i18n.getLabel("HelpAboutDlg.about"), createAboutPane()); |
91 |
tp.addTab(i18n.getLabel("HelpAboutDlg.details"), createDetailsPane()); |
92 |
|
93 |
tp.setAlignmentX(LEFT_ALIGNMENT); |
94 |
|
95 |
mainPane.add(tp); |
96 |
|
97 |
mainPane.add(Box.createRigidArea(new Dimension(0, 12))); |
98 |
|
99 |
lCopyright.setFont(lCopyright.getFont().deriveFont(java.awt.Font.PLAIN)); |
100 |
lCopyright.setFont(lCopyright.getFont().deriveFont(10.0f)); |
101 |
lCopyright.setHorizontalAlignment(JLabel.CENTER); |
102 |
lCopyright.setAlignmentX(LEFT_ALIGNMENT); |
103 |
mainPane.add(lCopyright); |
104 |
|
105 |
setMainPane(mainPane); |
106 |
|
107 |
pack(); |
108 |
|
109 |
installListeners(); |
110 |
} |
111 |
|
112 |
private void |
113 |
installListeners() { |
114 |
btnAuthor.addActionListener(new ActionListener() { |
115 |
public void |
116 |
actionPerformed(ActionEvent e) { |
117 |
StdUtils.browse("http://www.grigoriliev.com"); |
118 |
} |
119 |
}); |
120 |
|
121 |
btnLicense.addActionListener(new ActionListener() { |
122 |
public void |
123 |
actionPerformed(ActionEvent e) { showLicense(License.GPL); } |
124 |
}); |
125 |
} |
126 |
|
127 |
private JPanel |
128 |
createAboutPane() { |
129 |
GridBagLayout gridbag = new GridBagLayout(); |
130 |
GridBagConstraints c = new GridBagConstraints(); |
131 |
|
132 |
JPanel p = new JPanel(); |
133 |
p.setLayout(gridbag); |
134 |
|
135 |
c.gridx = 0; |
136 |
c.gridy = 0; |
137 |
c.insets = new Insets(0, 0, 0, 6); |
138 |
c.anchor = GridBagConstraints.EAST; |
139 |
gridbag.setConstraints(lAuthor, c); |
140 |
p.add(lAuthor); |
141 |
|
142 |
c.gridx = 0; |
143 |
c.gridy = 1; |
144 |
gridbag.setConstraints(lLicense, c); |
145 |
p.add(lLicense); |
146 |
|
147 |
c.gridx = 0; |
148 |
c.gridy = 2; |
149 |
gridbag.setConstraints(lDesign, c); |
150 |
p.add(lDesign); |
151 |
|
152 |
btnAuthor.setUnvisitedColor(new Color(0xFFA300)); |
153 |
c.gridx = 1; |
154 |
c.gridy = 0; |
155 |
c.weightx = 1.0; |
156 |
c.insets = new Insets(0, 0, 0, 0); |
157 |
c.anchor = GridBagConstraints.WEST; |
158 |
gridbag.setConstraints(btnAuthor, c); |
159 |
p.add(btnAuthor); |
160 |
|
161 |
c.gridx = 1; |
162 |
c.gridy = 1; |
163 |
gridbag.setConstraints(btnLicense, c); |
164 |
p.add(btnLicense); |
165 |
|
166 |
JLabel l = new JLabel("Olivier Boyer, Grigor Iliev"); |
167 |
l.setFont(l.getFont().deriveFont(java.awt.Font.BOLD)); |
168 |
c.gridx = 1; |
169 |
c.gridy = 2; |
170 |
gridbag.setConstraints(l, c); |
171 |
p.add(l); |
172 |
|
173 |
p.setAlignmentX(LEFT_ALIGNMENT); |
174 |
|
175 |
JPanel aboutPane = new JPanel(); |
176 |
aboutPane.setLayout(new BoxLayout(aboutPane, BoxLayout.Y_AXIS)); |
177 |
|
178 |
aboutPane.add(p); |
179 |
|
180 |
aboutPane.add(Box.createRigidArea(new Dimension(0, 12))); |
181 |
|
182 |
aboutPane.add(createLibrariesPane()); |
183 |
|
184 |
aboutPane.add(Box.createRigidArea(new Dimension(0, 12))); |
185 |
|
186 |
return aboutPane; |
187 |
} |
188 |
|
189 |
private JPanel |
190 |
createDetailsPane() { |
191 |
JPanel detailsPane = new JPanel(); |
192 |
detailsPane.setLayout(new BoxLayout(detailsPane, BoxLayout.Y_AXIS)); |
193 |
|
194 |
detailsPane.add(new ContactInfoPane()); |
195 |
JPanel p = new JPanel(); |
196 |
p.setLayout(new java.awt.BorderLayout()); |
197 |
p.setOpaque(false); |
198 |
detailsPane.add(p); |
199 |
return detailsPane; |
200 |
} |
201 |
|
202 |
private JPanel |
203 |
createLibrariesPane() { |
204 |
JPanel p = new JPanel(); |
205 |
GridBagLayout gridbag = new GridBagLayout(); |
206 |
GridBagConstraints c = new GridBagConstraints(); |
207 |
p.setLayout(gridbag); |
208 |
|
209 |
Button btn = new Button("swingx"); |
210 |
btn.addActionListener(new ActionListener() { |
211 |
public void |
212 |
actionPerformed(ActionEvent e) { |
213 |
StdUtils.browse("http://swingx.dev.java.net/"); |
214 |
} |
215 |
}); |
216 |
|
217 |
c.gridx = 1; |
218 |
c.gridy = 0; |
219 |
c.insets = new Insets(3, 3, 3, 3); |
220 |
gridbag.setConstraints(btn, c); |
221 |
p.add(btn); |
222 |
|
223 |
btn = new Button("substance"); |
224 |
btn.addActionListener(new ActionListener() { |
225 |
public void |
226 |
actionPerformed(ActionEvent e) { |
227 |
StdUtils.browse("http://substance.dev.java.net/"); |
228 |
} |
229 |
}); |
230 |
|
231 |
c.gridx = 1; |
232 |
c.gridy = 1; |
233 |
gridbag.setConstraints(btn, c); |
234 |
p.add(btn); |
235 |
|
236 |
btn = new Button("jlscp"); |
237 |
btn.addActionListener(new ActionListener() { |
238 |
public void |
239 |
actionPerformed(ActionEvent e) { |
240 |
StdUtils.browse("http://sourceforge.net/projects/jlscp/"); |
241 |
} |
242 |
}); |
243 |
|
244 |
c.gridx = 0; |
245 |
c.gridy = 2; |
246 |
gridbag.setConstraints(btn, c); |
247 |
p.add(btn); |
248 |
|
249 |
btn = new Button("substance-swingx"); |
250 |
btn.addActionListener(new ActionListener() { |
251 |
public void |
252 |
actionPerformed(ActionEvent e) { |
253 |
StdUtils.browse("http://substance-swingx.dev.java.net/"); |
254 |
} |
255 |
}); |
256 |
|
257 |
c.gridx = 1; |
258 |
c.gridy = 2; |
259 |
gridbag.setConstraints(btn, c); |
260 |
p.add(btn); |
261 |
|
262 |
btn = new Button("juife"); |
263 |
btn.addActionListener(new ActionListener() { |
264 |
public void |
265 |
actionPerformed(ActionEvent e) { |
266 |
StdUtils.browse("http://sourceforge.net/projects/juife/"); |
267 |
} |
268 |
}); |
269 |
|
270 |
c.gridx = 2; |
271 |
c.gridy = 2; |
272 |
gridbag.setConstraints(btn, c); |
273 |
p.add(btn); |
274 |
|
275 |
p.setBorder(BorderFactory.createTitledBorder ( |
276 |
i18n.getLabel("HelpAboutDlg.using") |
277 |
)); |
278 |
|
279 |
p.setAlignmentX(LEFT_ALIGNMENT); |
280 |
|
281 |
return p; |
282 |
} |
283 |
|
284 |
private void |
285 |
showLicense(License license) { |
286 |
new LicenseDlg(this, license).setVisible(true); |
287 |
} |
288 |
|
289 |
class ContactInfoPane extends JPanel { |
290 |
private JLabel lAuthorEmail = |
291 |
new JLabel(i18n.getLabel("HelpAboutDlg.lAuthorEmail")); |
292 |
private JLabel lLSWebsite = new JLabel(i18n.getLabel("HelpAboutDlg.lLSWebsite")); |
293 |
private JLabel lJSWebsite = new JLabel(i18n.getLabel("HelpAboutDlg.lJSWebsite")); |
294 |
|
295 |
private Lnkbutton btnAuthorEmail = new Lnkbutton("grigor@grigoriliev.com"); |
296 |
private Lnkbutton btnLSWebsite = new Lnkbutton("www.linuxsampler.org"); |
297 |
private Lnkbutton btnJSWebsite = new Lnkbutton("sf.net/projects/jsampler"); |
298 |
|
299 |
private Button btnDocumentation = |
300 |
new Button(i18n.getButtonLabel("HelpAboutDlg.btnDocumentation")); |
301 |
|
302 |
private Button btnLSDevelopers = |
303 |
new Button(i18n.getButtonLabel("HelpAboutDlg.btnLSDevelopers")); |
304 |
|
305 |
private Button btnLSMailingList = |
306 |
new Button(i18n.getButtonLabel("HelpAboutDlg.btnLSMailingList")); |
307 |
|
308 |
ContactInfoPane() { |
309 |
GridBagLayout gridbag = new GridBagLayout(); |
310 |
GridBagConstraints c = new GridBagConstraints(); |
311 |
|
312 |
setLayout(gridbag); |
313 |
|
314 |
c.gridx = 0; |
315 |
c.gridy = 0; |
316 |
c.insets = new Insets(0, 0, 0, 6); |
317 |
c.anchor = GridBagConstraints.EAST; |
318 |
gridbag.setConstraints(lAuthorEmail, c); |
319 |
add(lAuthorEmail); |
320 |
|
321 |
c.gridx = 0; |
322 |
c.gridy = 1; |
323 |
gridbag.setConstraints(lLSWebsite, c); |
324 |
add(lLSWebsite); |
325 |
|
326 |
c.gridx = 0; |
327 |
c.gridy = 2; |
328 |
c.anchor = GridBagConstraints.EAST; |
329 |
gridbag.setConstraints(lJSWebsite, c); |
330 |
add(lJSWebsite); |
331 |
|
332 |
c.gridx = 1; |
333 |
c.gridy = 0; |
334 |
c.insets = new Insets(0, 0, 0, 0); |
335 |
c.anchor = GridBagConstraints.WEST; |
336 |
gridbag.setConstraints(btnAuthorEmail, c); |
337 |
add(btnAuthorEmail); |
338 |
|
339 |
c.gridx = 1; |
340 |
c.gridy = 1; |
341 |
gridbag.setConstraints(btnLSWebsite, c); |
342 |
add(btnLSWebsite); |
343 |
|
344 |
c.gridx = 1; |
345 |
c.gridy = 2; |
346 |
gridbag.setConstraints(btnJSWebsite, c); |
347 |
add(btnJSWebsite); |
348 |
|
349 |
c.gridx = 0; |
350 |
c.gridy = 3; |
351 |
c.gridwidth = 2; |
352 |
c.insets = new Insets(12, 0, 0, 0); |
353 |
c.anchor = GridBagConstraints.CENTER; |
354 |
gridbag.setConstraints(btnDocumentation, c); |
355 |
add(btnDocumentation); |
356 |
|
357 |
c.gridx = 0; |
358 |
c.gridy = 4; |
359 |
c.insets = new Insets(6, 0, 0, 0); |
360 |
gridbag.setConstraints(btnLSDevelopers, c); |
361 |
add(btnLSDevelopers); |
362 |
|
363 |
c.gridx = 0; |
364 |
c.gridy = 5; |
365 |
gridbag.setConstraints(btnLSMailingList, c); |
366 |
add(btnLSMailingList); |
367 |
|
368 |
setBorder(BorderFactory.createTitledBorder ( |
369 |
i18n.getLabel("HelpAboutDlg.contactInfoPane") |
370 |
)); |
371 |
|
372 |
btnAuthorEmail.addActionListener(new ActionListener() { |
373 |
public void |
374 |
actionPerformed(ActionEvent e) { |
375 |
StdUtils.browse("mailto:grigor@grigoriliev.com"); |
376 |
} |
377 |
}); |
378 |
|
379 |
btnLSWebsite.addActionListener(new ActionListener() { |
380 |
public void |
381 |
actionPerformed(ActionEvent e) { |
382 |
StdUtils.browse("http://www.linuxsampler.org"); |
383 |
} |
384 |
}); |
385 |
|
386 |
btnJSWebsite.addActionListener(new ActionListener() { |
387 |
public void |
388 |
actionPerformed(ActionEvent e) { |
389 |
StdUtils.browse("http://sf.net/projects/jsampler/"); |
390 |
} |
391 |
}); |
392 |
|
393 |
btnDocumentation.addActionListener(new ActionListener() { |
394 |
public void |
395 |
actionPerformed(ActionEvent e) { |
396 |
StdUtils.browse("http://www.linuxsampler.org/documentation.html"); |
397 |
} |
398 |
}); |
399 |
|
400 |
btnLSDevelopers.addActionListener(new ActionListener() { |
401 |
public void |
402 |
actionPerformed(ActionEvent e) { |
403 |
StdUtils.browse("http://www.linuxsampler.org/developers.html"); |
404 |
} |
405 |
}); |
406 |
|
407 |
btnLSMailingList.addActionListener(new ActionListener() { |
408 |
public void |
409 |
actionPerformed(ActionEvent e) { |
410 |
StdUtils.browse("http://lists.sourceforge.net/lists/listinfo/linuxsampler-devel"); |
411 |
} |
412 |
}); |
413 |
} |
414 |
} |
415 |
|
416 |
private class Lnkbutton extends LinkButton { |
417 |
Lnkbutton(String s) { |
418 |
super(s); |
419 |
Color c = new Color(0xFFA300); |
420 |
setUnvisitedColor(c); |
421 |
setUnvisitedFontStyle(BOLD); |
422 |
setVisitedColor(c); |
423 |
setVisitedFontStyle(BOLD); |
424 |
setHoverColor(c); |
425 |
setHoverFontStyle(BOLD | UNDERLINE); |
426 |
} |
427 |
} |
428 |
|
429 |
private class Button extends JButton { |
430 |
Button(String s) { |
431 |
super(s); |
432 |
putClientProperty ( |
433 |
SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, |
434 |
"org.jvnet.substance.button.StandardButtonShaper" |
435 |
); |
436 |
|
437 |
setForeground(new Color(0xFFA300)); |
438 |
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
439 |
} |
440 |
} |
441 |
} |
442 |
|
443 |
|
444 |
|
445 |
enum License { GPL, LGPL } |
446 |
|
447 |
class LicenseDlg extends InformationDialog { |
448 |
LicenseDlg(Dialog owner, License license) { |
449 |
super(owner); |
450 |
|
451 |
switch(license) { |
452 |
case GPL: setTitle("GNU General Public License"); break; |
453 |
case LGPL: setTitle("GNU Lesser General Public License"); break; |
454 |
} |
455 |
|
456 |
JScrollPane sp = new JScrollPane(new LicensePane(license)); |
457 |
sp.setPreferredSize(new Dimension(800, 400)); |
458 |
|
459 |
setMainPane(sp); |
460 |
} |
461 |
|
462 |
static class LicensePane extends JEditorPane { |
463 |
private static URL urlGPL; |
464 |
private static URL urlLGPL; |
465 |
|
466 |
static { |
467 |
String s = "licenses/gpl.html"; |
468 |
urlGPL = ClassLoader.getSystemClassLoader().getResource(s); |
469 |
s = "licenses/lgpl.html"; |
470 |
urlLGPL = ClassLoader.getSystemClassLoader().getResource(s); |
471 |
} |
472 |
|
473 |
LicensePane(License license) { |
474 |
try { |
475 |
switch(license) { |
476 |
case GPL: setPage(urlGPL); break; |
477 |
case LGPL: setPage(urlLGPL); break; |
478 |
} |
479 |
} catch(Exception x) { |
480 |
x.printStackTrace(); |
481 |
} |
482 |
|
483 |
setEditable(false); |
484 |
} |
485 |
} |
486 |
} |