/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/HelpAboutDlg.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/HelpAboutDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1496 - (show annotations) (download)
Mon Nov 19 22:22:22 2007 UTC (16 years, 5 months ago) by iliev
File size: 11822 byte(s)
* Added option for turning off the custom window decoration
  (choose Edit/Preferences, then click the `View' tab)
* Added new menu item: Help/Online Tutorial
* Fantasia: first step of implementing a theme manager
* Fantasia: fixed the view of the channel's stream/voice count statistic
* some minor GUI fixes and enhancements

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

  ViewVC Help
Powered by ViewVC