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