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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1567 - (hide annotations) (download)
Thu Dec 6 19:37:41 2007 UTC (16 years, 4 months ago) by iliev
File size: 12699 byte(s)
* added confirmation dialog on exit
* some minor gui enhancements
* preparations for release 0.8a

1 iliev 1286 /*
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 iliev 1496 import org.jsampler.view.std.StdUtils;
56 iliev 1286
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 iliev 1567 new JLabel("<html>\n<font size=+1>JSampler Fantasia (version 0.8a)</font>");
68 iliev 1286
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 iliev 1496 StdUtils.browse("http://www.grigoriliev.com");
122 iliev 1286 }
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 iliev 1496 StdUtils.browse("http://swingx.dev.java.net/");
218 iliev 1286 }
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 iliev 1496 StdUtils.browse("http://substance.dev.java.net/");
232 iliev 1286 }
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 iliev 1496 StdUtils.browse("http://sourceforge.net/projects/jlscp/");
245 iliev 1286 }
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 iliev 1496 StdUtils.browse("http://substance-swingx.dev.java.net/");
258 iliev 1286 }
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 iliev 1496 StdUtils.browse("http://sourceforge.net/projects/juife/");
271 iliev 1286 }
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 iliev 1567 private Button btnDocumentation =
304     new Button(i18n.getButtonLabel("HelpAboutDlg.btnDocumentation"));
305    
306     private Button btnLSDevelopers =
307     new Button(i18n.getButtonLabel("HelpAboutDlg.btnLSDevelopers"));
308    
309 iliev 1286 private Button btnLSMailingList =
310     new Button(i18n.getButtonLabel("HelpAboutDlg.btnLSMailingList"));
311    
312     ContactInfoPane() {
313     GridBagLayout gridbag = new GridBagLayout();
314     GridBagConstraints c = new GridBagConstraints();
315    
316     setLayout(gridbag);
317    
318     c.gridx = 0;
319     c.gridy = 0;
320     c.insets = new Insets(0, 0, 0, 6);
321     c.anchor = GridBagConstraints.EAST;
322     gridbag.setConstraints(lAuthorEmail, c);
323     add(lAuthorEmail);
324    
325     c.gridx = 0;
326     c.gridy = 1;
327     gridbag.setConstraints(lLSWebsite, c);
328     add(lLSWebsite);
329    
330     c.gridx = 0;
331     c.gridy = 2;
332     c.anchor = GridBagConstraints.EAST;
333     gridbag.setConstraints(lJSWebsite, c);
334     add(lJSWebsite);
335    
336     c.gridx = 1;
337     c.gridy = 0;
338     c.insets = new Insets(0, 0, 0, 0);
339     c.anchor = GridBagConstraints.WEST;
340     gridbag.setConstraints(btnAuthorEmail, c);
341     add(btnAuthorEmail);
342    
343     c.gridx = 1;
344     c.gridy = 1;
345     gridbag.setConstraints(btnLSWebsite, c);
346     add(btnLSWebsite);
347    
348     c.gridx = 1;
349     c.gridy = 2;
350     gridbag.setConstraints(btnJSWebsite, c);
351     add(btnJSWebsite);
352    
353     c.gridx = 0;
354     c.gridy = 3;
355     c.gridwidth = 2;
356     c.insets = new Insets(12, 0, 0, 0);
357     c.anchor = GridBagConstraints.CENTER;
358 iliev 1567 gridbag.setConstraints(btnDocumentation, c);
359     add(btnDocumentation);
360    
361     c.gridx = 0;
362     c.gridy = 4;
363     c.insets = new Insets(6, 0, 0, 0);
364     gridbag.setConstraints(btnLSDevelopers, c);
365     add(btnLSDevelopers);
366    
367     c.gridx = 0;
368     c.gridy = 5;
369 iliev 1286 gridbag.setConstraints(btnLSMailingList, c);
370     add(btnLSMailingList);
371    
372     setBorder(BorderFactory.createTitledBorder (
373     i18n.getLabel("HelpAboutDlg.contactInfoPane")
374     ));
375    
376     btnAuthorEmail.addActionListener(new ActionListener() {
377     public void
378     actionPerformed(ActionEvent e) {
379 iliev 1496 StdUtils.browse("mailto:grigor@grigoriliev.com");
380 iliev 1286 }
381     });
382    
383     btnLSWebsite.addActionListener(new ActionListener() {
384     public void
385     actionPerformed(ActionEvent e) {
386 iliev 1496 StdUtils.browse("http://www.linuxsampler.org");
387 iliev 1286 }
388     });
389    
390     btnJSWebsite.addActionListener(new ActionListener() {
391     public void
392     actionPerformed(ActionEvent e) {
393 iliev 1496 StdUtils.browse("http://sf.net/projects/jsampler/");
394 iliev 1286 }
395     });
396    
397 iliev 1567 btnDocumentation.addActionListener(new ActionListener() {
398     public void
399     actionPerformed(ActionEvent e) {
400     StdUtils.browse("http://www.linuxsampler.org/documentation.html");
401     }
402     });
403    
404     btnLSDevelopers.addActionListener(new ActionListener() {
405     public void
406     actionPerformed(ActionEvent e) {
407     StdUtils.browse("http://www.linuxsampler.org/developers.html");
408     }
409     });
410    
411 iliev 1286 btnLSMailingList.addActionListener(new ActionListener() {
412     public void
413     actionPerformed(ActionEvent e) {
414 iliev 1496 StdUtils.browse("http://lists.sourceforge.net/lists/listinfo/linuxsampler-devel");
415 iliev 1286 }
416     });
417     }
418     }
419    
420     private class Lnkbutton extends LinkButton {
421     Lnkbutton(String s) {
422     super(s);
423     Color c = new Color(0xFFA300);
424     setUnvisitedColor(c);
425     setUnvisitedFontStyle(BOLD);
426     setVisitedColor(c);
427     setVisitedFontStyle(BOLD);
428     setHoverColor(c);
429     setHoverFontStyle(BOLD | UNDERLINE);
430     }
431     }
432    
433     private class Button extends JButton {
434     Button(String s) {
435     super(s);
436     putClientProperty (
437     SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
438     "org.jvnet.substance.button.StandardButtonShaper"
439     );
440    
441     setForeground(new Color(0xFFA300));
442     setFont(getFont().deriveFont(java.awt.Font.BOLD));
443     }
444     }
445     }
446    
447    
448    
449     enum License { GPL, LGPL }
450    
451     class LicenseDlg extends InformationDialog {
452     LicenseDlg(Dialog owner, License license) {
453     super(owner);
454    
455     switch(license) {
456     case GPL: setTitle("GNU General Public License"); break;
457     case LGPL: setTitle("GNU Lesser General Public License"); break;
458     }
459    
460     JScrollPane sp = new JScrollPane(new LicensePane(license));
461     sp.setPreferredSize(new Dimension(800, 400));
462    
463     setMainPane(sp);
464     }
465    
466     static class LicensePane extends JEditorPane {
467     private static URL urlGPL;
468     private static URL urlLGPL;
469    
470     static {
471     String s = "licenses/gpl.html";
472     urlGPL = ClassLoader.getSystemClassLoader().getResource(s);
473     s = "licenses/lgpl.html";
474     urlLGPL = ClassLoader.getSystemClassLoader().getResource(s);
475     }
476    
477     LicensePane(License license) {
478     try {
479     switch(license) {
480     case GPL: setPage(urlGPL); break;
481     case LGPL: setPage(urlLGPL); break;
482     }
483     } catch(Exception x) {
484     x.printStackTrace();
485     }
486    
487     setEditable(false);
488     }
489     }
490     }

  ViewVC Help
Powered by ViewVC