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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (hide annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 5 months ago) by iliev
File size: 13137 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

1 iliev 787 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 2288 * Copyright (C) 2005-2011 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 1285 import java.awt.Desktop;
26 iliev 787 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 iliev 1285 import java.net.URI;
37 iliev 787 import java.net.URL;
38    
39     import javax.swing.BorderFactory;
40     import javax.swing.Box;
41     import javax.swing.BoxLayout;
42     import javax.swing.JEditorPane;
43     import javax.swing.JLabel;
44     import javax.swing.JPanel;
45     import javax.swing.JScrollPane;
46     import javax.swing.JTextField;
47    
48 iliev 2288 import net.sf.juife.swing.InformationDialog;
49     import net.sf.juife.swing.LinkButton;
50 iliev 787
51 iliev 2288 import org.jsampler.view.swing.SHF;
52 iliev 1285
53 iliev 787 import static org.jsampler.view.classic.ClassicI18n.i18n;
54    
55    
56     /**
57     *
58     * @author grish
59     */
60     public class HelpAboutDlg extends InformationDialog {
61     private JLabel lProductName =
62 iliev 2288 new JLabel("<html>\n<font size=+1>JS Classic (version 0.9cvs2)</font>");
63 iliev 787
64     private JLabel lAuthor = new JLabel(i18n.getLabel("HelpAboutDlg.lAuthor"));
65     private JTextField tfAuthor = new JTextField(i18n.getLabel("HelpAboutDlg.tfAuthor"));
66    
67     private JLabel lLicense = new JLabel(i18n.getLabel("HelpAboutDlg.lLicense"));
68     private LinkButton btnLicense = new LinkButton("GNU General Public License");
69    
70     private JLabel lLibraries = new JLabel("Using:");
71    
72     private LinkButton btnJlscp =
73     new LinkButton("jlscp - A java LinuxSampler control protocol API");
74    
75     private LinkButton btnJuife
76     = new LinkButton("juife - Java User Interface Framework Extensions");
77    
78    
79 iliev 1285 private JLabel lCopyright = new JLabel(i18n.getLabel("HelpAboutDlg.lCopyright"));
80 iliev 787
81     private JPanel mainPane = new JPanel();
82    
83     /** Creates a new instance of HelpAboutDlg */
84     public HelpAboutDlg(Frame owner) {
85 iliev 842 super(owner, i18n.getLabel("HelpAboutDlg.title"));
86 iliev 787
87     GridBagLayout gridbag = new GridBagLayout();
88     GridBagConstraints c = new GridBagConstraints();
89    
90     JPanel p = new JPanel();
91     p.setLayout(gridbag);
92    
93     c.gridx = 0;
94     c.gridy = 1;
95     c.insets = new Insets(0, 0, 0, 6);
96     c.anchor = GridBagConstraints.EAST;
97     gridbag.setConstraints(lAuthor, c);
98     p.add(lAuthor);
99    
100     c.gridx = 0;
101     c.gridy = 2;
102     gridbag.setConstraints(lLicense, c);
103     p.add(lLicense);
104    
105     c.gridx = 0;
106     c.gridy = 3;
107     c.insets = new Insets(12, 0, 0, 6);
108     c.anchor = GridBagConstraints.EAST;
109     gridbag.setConstraints(lLibraries, c);
110     p.add(lLibraries);
111    
112     tfAuthor.setEditable(false);
113     tfAuthor.setBorder(BorderFactory.createEmptyBorder());
114    
115     c.gridx = 1;
116     c.gridy = 1;
117     c.weightx = 1.0;
118     c.insets = new Insets(0, 0, 0, 0);
119     c.anchor = GridBagConstraints.WEST;
120     gridbag.setConstraints(tfAuthor, c);
121     p.add(tfAuthor);
122    
123     c.gridx = 1;
124     c.gridy = 2;
125     gridbag.setConstraints(btnLicense, c);
126     p.add(btnLicense);
127    
128     c.gridx = 1;
129     c.gridy = 3;
130     c.insets = new Insets(12, 0, 0, 0);
131     gridbag.setConstraints(btnJlscp, c);
132     p.add(btnJlscp);
133    
134     c.gridx = 1;
135     c.gridy = 4;
136     c.insets = new Insets(0, 0, 0, 0);
137     gridbag.setConstraints(btnJuife, c);
138     p.add(btnJuife);
139    
140     //
141     /*c.gridx = 0;
142     c.gridy = 1;
143     c.gridwidth = 2;
144     gridbag.setConstraints(lCopyright, c);
145     p.add(lCopyright);*/
146    
147     lProductName.setHorizontalAlignment(JLabel.CENTER);
148     c.gridx = 0;
149     c.gridy = 0;
150     c.gridwidth = 2;
151     c.insets = new Insets(0, 0, 12, 0);
152     c.anchor = GridBagConstraints.CENTER;
153     gridbag.setConstraints(lProductName, c);
154     p.add(lProductName);
155    
156     /*p = new JPanel();
157     p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
158    
159     p.add(lLicense);
160     p.add(Box.createRigidArea(new Dimension(5, 0)));
161     p.add(btnLicense);
162    
163     mainPane.add(p);*/
164    
165     mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
166     p.setAlignmentX(LEFT_ALIGNMENT);
167     mainPane.add(p);
168     mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
169    
170     /*lContactInfo.setAlignmentX(LEFT_ALIGNMENT);
171     mainPane.add(lContactInfo);
172    
173     JSeparator sep = new JSeparator();
174     sep.setAlignmentX(LEFT_ALIGNMENT);
175     mainPane.add(sep);*/
176    
177     ContactInfoPane contactInfoPane = new ContactInfoPane();
178     contactInfoPane.setAlignmentX(LEFT_ALIGNMENT);
179     mainPane.add(contactInfoPane);
180    
181     mainPane.add(Box.createRigidArea(new Dimension(0, 12)));
182    
183     lCopyright.setFont(lCopyright.getFont().deriveFont(java.awt.Font.PLAIN));
184     lCopyright.setHorizontalAlignment(JLabel.CENTER);
185     lCopyright.setAlignmentX(LEFT_ALIGNMENT);
186     mainPane.add(lCopyright);
187    
188     setMainPane(mainPane);
189    
190     pack();
191     //setResizable(false);
192    
193     btnLicense.addActionListener(new ActionListener() {
194     public void
195     actionPerformed(ActionEvent e) { showLicense(License.GPL); }
196     });
197    
198     btnJlscp.addActionListener(new ActionListener() {
199     public void
200     actionPerformed(ActionEvent e) { showJlscpInfo(); }
201     });
202    
203     btnJuife.addActionListener(new ActionListener() {
204     public void
205     actionPerformed(ActionEvent e) { showJuifeInfo(); }
206     });
207     }
208    
209     private void
210     showLicense(License license) {
211     new LicenseDlg(this, license).setVisible(true);
212     }
213    
214     private void
215     showJlscpInfo() {
216     String website = "http://sourceforge.net/projects/jlscp";
217     String ver = Package.getPackage("org.linuxsampler.lscp").getImplementationVersion();
218     new LibraryInfoDlg(this, "jlscp", ver, website, License.GPL).setVisible(true);
219     }
220    
221     private void
222     showJuifeInfo() {
223     String website = "http://sourceforge.net/projects/juife";
224     String ver = Package.getPackage("net.sf.juife").getImplementationVersion();
225     new LibraryInfoDlg(this, "juife", ver, website, License.LGPL).setVisible(true);
226     }
227    
228     class ContactInfoPane extends JPanel {
229     private JLabel lAuthorEmail =
230     new JLabel(i18n.getLabel("HelpAboutDlg.lAuthorEmail"));
231     private JLabel lLSWebsite = new JLabel(i18n.getLabel("HelpAboutDlg.lLSWebsite"));
232 iliev 1285 private LinkButton btnAuthorEmail = new LinkButton("grigor@grigoriliev.com");
233     private LinkButton btnLSWebsite = new LinkButton("www.linuxsampler.org");
234 iliev 787
235     private JLabel lLSMailingList =
236     new JLabel(i18n.getLabel("HelpAboutDlg.lLSMailingList"));
237    
238 iliev 1285 private LinkButton btnMailingList = new LinkButton (
239     "lists.sourceforge.net/lists/listinfo/linuxsampler-devel"
240 iliev 787 );
241    
242     ContactInfoPane() {
243     GridBagLayout gridbag = new GridBagLayout();
244     GridBagConstraints c = new GridBagConstraints();
245    
246     setLayout(gridbag);
247    
248     c.gridx = 0;
249     c.gridy = 0;
250     c.insets = new Insets(0, 0, 0, 6);
251     c.anchor = GridBagConstraints.EAST;
252     gridbag.setConstraints(lAuthorEmail, c);
253     add(lAuthorEmail);
254    
255     c.gridx = 0;
256     c.gridy = 1;
257     gridbag.setConstraints(lLSWebsite, c);
258     add(lLSWebsite);
259    
260     c.gridx = 0;
261     c.gridy = 2;
262     c.anchor = GridBagConstraints.EAST;
263     gridbag.setConstraints(lLSMailingList, c);
264     add(lLSMailingList);
265    
266     c.gridx = 1;
267     c.gridy = 0;
268     c.insets = new Insets(0, 0, 0, 0);
269     c.anchor = GridBagConstraints.WEST;
270     gridbag.setConstraints(btnAuthorEmail, c);
271     add(btnAuthorEmail);
272    
273     c.gridx = 1;
274     c.gridy = 1;
275 iliev 1285 gridbag.setConstraints(btnLSWebsite, c);
276     add(btnLSWebsite);
277 iliev 787
278     c.gridx = 1;
279     c.gridy = 2;
280     c.gridwidth = 2;
281     gridbag.setConstraints(btnMailingList, c);
282     add(btnMailingList);
283    
284     setBorder(BorderFactory.createTitledBorder (
285 iliev 1285 i18n.getLabel("HelpAboutDlg.contactInfoPane")
286 iliev 787 ));
287 iliev 1285
288     installListeners();
289 iliev 787 }
290 iliev 1285
291     private void
292     installListeners() {
293     btnAuthorEmail.addActionListener(new ActionListener() {
294     public void
295     actionPerformed(ActionEvent e) {
296     browse("mailto:grigor@grigoriliev.com");
297     }
298     });
299    
300     btnLSWebsite.addActionListener(new ActionListener() {
301     public void
302     actionPerformed(ActionEvent e) {
303     browse("http://www.linuxsampler.org");
304     }
305     });
306    
307     btnMailingList.addActionListener(new ActionListener() {
308     public void
309     actionPerformed(ActionEvent e) {
310     browse("http://lists.sourceforge.net/lists/listinfo/linuxsampler-devel");
311     }
312     });
313     }
314 iliev 787 }
315 iliev 1285
316     private boolean
317     checkDesktopSupported() {
318     if(Desktop.isDesktopSupported()) return true;
319    
320 iliev 2288 SHF.showErrorMessage(i18n.getError("HelpAboutDlg.DesktopApiNotSupported"), this);
321 iliev 1285
322     return false;
323     }
324    
325     private void
326     browse(String uri) {
327     if(!checkDesktopSupported()) return;
328    
329     try { Desktop.getDesktop().browse(new URI(uri)); }
330     catch(Exception x) { x.printStackTrace(); }
331     }
332    
333     private void
334     mail(String uri) {
335     if(!checkDesktopSupported()) return;
336    
337     Desktop desktop = Desktop.getDesktop();
338    
339     try { Desktop.getDesktop().mail(new URI(uri)); }
340     catch(Exception x) { x.printStackTrace(); }
341     }
342 iliev 787 }
343    
344     class WebButton extends LinkButton {
345     WebButton(String text) {
346     super(text);
347    
348     setDisabledColor(getUnvisitedColor());
349     setDisabledFontStyle(UNDERLINE);
350     setUnvisitedFontStyle(UNDERLINE);
351     setEnabled(false);
352     }
353     }
354    
355     enum License { GPL, LGPL }
356    
357     class LicenseDlg extends InformationDialog {
358     LicenseDlg(Dialog owner, License license) {
359 iliev 842 super(owner);
360 iliev 787
361     switch(license) {
362     case GPL: setTitle("GNU General Public License"); break;
363     case LGPL: setTitle("GNU Lesser General Public License"); break;
364     }
365    
366     JScrollPane sp = new JScrollPane(new LicensePane(license));
367     sp.setPreferredSize(new Dimension(800, 400));
368    
369     setMainPane(sp);
370     }
371    
372     static class LicensePane extends JEditorPane {
373     private static URL urlGPL;
374     private static URL urlLGPL;
375    
376     static {
377     String s = "licenses/gpl.html";
378     urlGPL = ClassLoader.getSystemClassLoader().getResource(s);
379     s = "licenses/lgpl.html";
380     urlLGPL = ClassLoader.getSystemClassLoader().getResource(s);
381     }
382    
383     LicensePane(License license) {
384     try {
385     switch(license) {
386     case GPL: setPage(urlGPL); break;
387     case LGPL: setPage(urlLGPL); break;
388     }
389     } catch(Exception x) {
390     x.printStackTrace();
391     }
392 iliev 842
393     setEditable(false);
394 iliev 787 }
395     }
396     }
397    
398     class LibraryInfoDlg extends InformationDialog {
399     private JLabel lAuthor = new JLabel(i18n.getLabel("LibraryInfoDlg.lAuthor"));
400     private JTextField tfAuthor = new JTextField(i18n.getLabel("LibraryInfoDlg.tfAuthor"));
401    
402     private JLabel lLicense = new JLabel(i18n.getLabel("LibraryInfoDlg.lLicense"));
403     private LinkButton btnLicense = new LinkButton(" ");
404    
405     private JLabel lWebsite = new JLabel(i18n.getLabel("LibraryInfoDlg.lWebsite"));
406     private WebButton btnWebsite = new WebButton("");
407    
408     LibraryInfoDlg (
409     Dialog owner,
410     String libName,
411     String libVersion,
412     String website,
413     final License license
414     ) {
415 iliev 842 super(owner, libName);
416 iliev 787
417     switch(license) {
418     case GPL: btnLicense.setText("GNU General Public License"); break;
419     case LGPL: btnLicense.setText("GNU Lesser General Public License"); break;
420     }
421    
422     btnWebsite.setText(website);
423    
424     setMainPane(new LibraryInfoPane(libName, libVersion, license));
425    
426     btnLicense.addActionListener(new ActionListener() {
427     public void
428     actionPerformed(ActionEvent e) { showLicense(license); }
429     });
430     }
431    
432     private void
433     showLicense(License license) {
434     new LicenseDlg(this, license).setVisible(true);
435     }
436    
437     class LibraryInfoPane extends JPanel {
438     private JLabel lProductName;
439    
440    
441     LibraryInfoPane(String libName, String libVersion, final License license) {
442     lProductName = new JLabel (
443     "<html>\n<font size=+1>" + libName +
444     " (version " + libVersion + ")</font>"
445     );
446    
447     GridBagLayout gridbag = new GridBagLayout();
448     GridBagConstraints c = new GridBagConstraints();
449    
450     setLayout(gridbag);
451    
452     c.gridx = 0;
453     c.gridy = 1;
454     c.insets = new Insets(0, 0, 0, 6);
455     c.anchor = GridBagConstraints.EAST;
456     gridbag.setConstraints(lAuthor, c);
457     add(lAuthor);
458    
459     c.gridx = 0;
460     c.gridy = 2;
461     gridbag.setConstraints(lLicense, c);
462     add(lLicense);
463    
464     c.gridx = 0;
465     c.gridy = 3;
466     c.insets = new Insets(12, 0, 0, 6);
467     gridbag.setConstraints(lWebsite, c);
468     add(lWebsite);
469    
470     tfAuthor.setEditable(false);
471     tfAuthor.setBorder(BorderFactory.createEmptyBorder());
472    
473     c.gridx = 1;
474     c.gridy = 1;
475     c.insets = new Insets(0, 0, 0, 0);
476     c.anchor = GridBagConstraints.WEST;
477     gridbag.setConstraints(tfAuthor, c);
478     add(tfAuthor);
479    
480     c.gridx = 1;
481     c.gridy = 2;
482     gridbag.setConstraints(btnLicense, c);
483     add(btnLicense);
484    
485     c.gridx = 1;
486     c.gridy = 3;
487     c.insets = new Insets(12, 0, 0, 0);
488     gridbag.setConstraints(btnWebsite, c);
489     add(btnWebsite);
490    
491     lProductName.setHorizontalAlignment(JLabel.CENTER);
492     c.gridx = 0;
493     c.gridy = 0;
494     c.gridwidth = 2;
495     c.insets = new Insets(0, 0, 12, 0);
496     c.anchor = GridBagConstraints.CENTER;
497     gridbag.setConstraints(lProductName, c);
498     add(lProductName);
499     }
500     }
501     }

  ViewVC Help
Powered by ViewVC