1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
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.classic; |
24 |
|
25 |
import java.awt.Dialog; |
26 |
import java.awt.Dimension; |
27 |
import java.awt.Frame; |
28 |
import java.awt.GridBagConstraints; |
29 |
import java.awt.GridBagLayout; |
30 |
import java.awt.Insets; |
31 |
|
32 |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
34 |
|
35 |
import java.net.URL; |
36 |
|
37 |
import javax.swing.BorderFactory; |
38 |
import javax.swing.Box; |
39 |
import javax.swing.BoxLayout; |
40 |
import javax.swing.ImageIcon; |
41 |
import javax.swing.JEditorPane; |
42 |
import javax.swing.JLabel; |
43 |
import javax.swing.JPanel; |
44 |
import javax.swing.JScrollPane; |
45 |
import javax.swing.JSeparator; |
46 |
import javax.swing.JTextField; |
47 |
|
48 |
import net.sf.juife.InformationDialog; |
49 |
import net.sf.juife.JuifeUtils; |
50 |
import net.sf.juife.LinkButton; |
51 |
|
52 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
53 |
|
54 |
|
55 |
/** |
56 |
* |
57 |
* @author grish |
58 |
*/ |
59 |
public class HelpAboutDlg extends InformationDialog { |
60 |
private JLabel lProductName = |
61 |
new JLabel("<html>\n<font size=+1>JS Classic (version 0.3a)</font>"); |
62 |
|
63 |
private JLabel lAuthor = new JLabel(i18n.getLabel("HelpAboutDlg.lAuthor")); |
64 |
private JTextField tfAuthor = new JTextField(i18n.getLabel("HelpAboutDlg.tfAuthor")); |
65 |
|
66 |
private JLabel lLicense = new JLabel(i18n.getLabel("HelpAboutDlg.lLicense")); |
67 |
private LinkButton btnLicense = new LinkButton("GNU General Public License"); |
68 |
|
69 |
private JLabel lLibraries = new JLabel("Using:"); |
70 |
|
71 |
private LinkButton btnJlscp = |
72 |
new LinkButton("jlscp - A java LinuxSampler control protocol API"); |
73 |
|
74 |
private LinkButton btnJuife |
75 |
= new LinkButton("juife - Java User Interface Framework Extensions"); |
76 |
|
77 |
|
78 |
private JLabel lCopyright = |
79 |
new JLabel(i18n.getLabel("HelpAboutDlg.lCopyright")); |
80 |
|
81 |
private JPanel mainPane = new JPanel(); |
82 |
|
83 |
/** Creates a new instance of HelpAboutDlg */ |
84 |
public HelpAboutDlg(Frame owner) { |
85 |
super(owner, i18n.getLabel("HelpAboutDlg.title")); |
86 |
|
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 |
private WebButton btnAuthorEmail = new WebButton("gr.iliev@gmail.com"); |
233 |
private WebButton btnWebsite = new WebButton("http://www.linuxsampler.org"); |
234 |
|
235 |
private JLabel lLSMailingList = |
236 |
new JLabel(i18n.getLabel("HelpAboutDlg.lLSMailingList")); |
237 |
|
238 |
private WebButton btnMailingList = new WebButton ( |
239 |
"http://lists.sourceforge.net/lists/listinfo/linuxsampler-devel" |
240 |
); |
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 |
gridbag.setConstraints(btnWebsite, c); |
276 |
add(btnWebsite); |
277 |
|
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 |
i18n.getLabel("HelpAboutDlg.ContactInfoPane") |
286 |
)); |
287 |
} |
288 |
} |
289 |
} |
290 |
|
291 |
class WebButton extends LinkButton { |
292 |
WebButton(String text) { |
293 |
super(text); |
294 |
|
295 |
setDisabledColor(getUnvisitedColor()); |
296 |
setDisabledFontStyle(UNDERLINE); |
297 |
setUnvisitedFontStyle(UNDERLINE); |
298 |
setEnabled(false); |
299 |
} |
300 |
} |
301 |
|
302 |
enum License { GPL, LGPL } |
303 |
|
304 |
class LicenseDlg extends InformationDialog { |
305 |
LicenseDlg(Dialog owner, License license) { |
306 |
super(owner); |
307 |
|
308 |
switch(license) { |
309 |
case GPL: setTitle("GNU General Public License"); break; |
310 |
case LGPL: setTitle("GNU Lesser General Public License"); break; |
311 |
} |
312 |
|
313 |
JScrollPane sp = new JScrollPane(new LicensePane(license)); |
314 |
sp.setPreferredSize(new Dimension(800, 400)); |
315 |
|
316 |
setMainPane(sp); |
317 |
} |
318 |
|
319 |
static class LicensePane extends JEditorPane { |
320 |
private static URL urlGPL; |
321 |
private static URL urlLGPL; |
322 |
|
323 |
static { |
324 |
String s = "licenses/gpl.html"; |
325 |
urlGPL = ClassLoader.getSystemClassLoader().getResource(s); |
326 |
s = "licenses/lgpl.html"; |
327 |
urlLGPL = ClassLoader.getSystemClassLoader().getResource(s); |
328 |
} |
329 |
|
330 |
LicensePane(License license) { |
331 |
try { |
332 |
switch(license) { |
333 |
case GPL: setPage(urlGPL); break; |
334 |
case LGPL: setPage(urlLGPL); break; |
335 |
} |
336 |
} catch(Exception x) { |
337 |
x.printStackTrace(); |
338 |
} |
339 |
|
340 |
setEditable(false); |
341 |
} |
342 |
} |
343 |
} |
344 |
|
345 |
class LibraryInfoDlg extends InformationDialog { |
346 |
private JLabel lAuthor = new JLabel(i18n.getLabel("LibraryInfoDlg.lAuthor")); |
347 |
private JTextField tfAuthor = new JTextField(i18n.getLabel("LibraryInfoDlg.tfAuthor")); |
348 |
|
349 |
private JLabel lLicense = new JLabel(i18n.getLabel("LibraryInfoDlg.lLicense")); |
350 |
private LinkButton btnLicense = new LinkButton(" "); |
351 |
|
352 |
private JLabel lWebsite = new JLabel(i18n.getLabel("LibraryInfoDlg.lWebsite")); |
353 |
private WebButton btnWebsite = new WebButton(""); |
354 |
|
355 |
LibraryInfoDlg ( |
356 |
Dialog owner, |
357 |
String libName, |
358 |
String libVersion, |
359 |
String website, |
360 |
final License license |
361 |
) { |
362 |
super(owner, libName); |
363 |
|
364 |
switch(license) { |
365 |
case GPL: btnLicense.setText("GNU General Public License"); break; |
366 |
case LGPL: btnLicense.setText("GNU Lesser General Public License"); break; |
367 |
} |
368 |
|
369 |
btnWebsite.setText(website); |
370 |
|
371 |
setMainPane(new LibraryInfoPane(libName, libVersion, license)); |
372 |
|
373 |
btnLicense.addActionListener(new ActionListener() { |
374 |
public void |
375 |
actionPerformed(ActionEvent e) { showLicense(license); } |
376 |
}); |
377 |
} |
378 |
|
379 |
private void |
380 |
showLicense(License license) { |
381 |
new LicenseDlg(this, license).setVisible(true); |
382 |
} |
383 |
|
384 |
class LibraryInfoPane extends JPanel { |
385 |
private JLabel lProductName; |
386 |
|
387 |
|
388 |
LibraryInfoPane(String libName, String libVersion, final License license) { |
389 |
lProductName = new JLabel ( |
390 |
"<html>\n<font size=+1>" + libName + |
391 |
" (version " + libVersion + ")</font>" |
392 |
); |
393 |
|
394 |
GridBagLayout gridbag = new GridBagLayout(); |
395 |
GridBagConstraints c = new GridBagConstraints(); |
396 |
|
397 |
setLayout(gridbag); |
398 |
|
399 |
c.gridx = 0; |
400 |
c.gridy = 1; |
401 |
c.insets = new Insets(0, 0, 0, 6); |
402 |
c.anchor = GridBagConstraints.EAST; |
403 |
gridbag.setConstraints(lAuthor, c); |
404 |
add(lAuthor); |
405 |
|
406 |
c.gridx = 0; |
407 |
c.gridy = 2; |
408 |
gridbag.setConstraints(lLicense, c); |
409 |
add(lLicense); |
410 |
|
411 |
c.gridx = 0; |
412 |
c.gridy = 3; |
413 |
c.insets = new Insets(12, 0, 0, 6); |
414 |
gridbag.setConstraints(lWebsite, c); |
415 |
add(lWebsite); |
416 |
|
417 |
tfAuthor.setEditable(false); |
418 |
tfAuthor.setBorder(BorderFactory.createEmptyBorder()); |
419 |
|
420 |
c.gridx = 1; |
421 |
c.gridy = 1; |
422 |
c.insets = new Insets(0, 0, 0, 0); |
423 |
c.anchor = GridBagConstraints.WEST; |
424 |
gridbag.setConstraints(tfAuthor, c); |
425 |
add(tfAuthor); |
426 |
|
427 |
c.gridx = 1; |
428 |
c.gridy = 2; |
429 |
gridbag.setConstraints(btnLicense, c); |
430 |
add(btnLicense); |
431 |
|
432 |
c.gridx = 1; |
433 |
c.gridy = 3; |
434 |
c.insets = new Insets(12, 0, 0, 0); |
435 |
gridbag.setConstraints(btnWebsite, c); |
436 |
add(btnWebsite); |
437 |
|
438 |
lProductName.setHorizontalAlignment(JLabel.CENTER); |
439 |
c.gridx = 0; |
440 |
c.gridy = 0; |
441 |
c.gridwidth = 2; |
442 |
c.insets = new Insets(0, 0, 12, 0); |
443 |
c.anchor = GridBagConstraints.CENTER; |
444 |
gridbag.setConstraints(lProductName, c); |
445 |
add(lProductName); |
446 |
} |
447 |
} |
448 |
} |