1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui;
21
22 import java.awt.Font;
23 import java.awt.GridBagLayout;
24 import java.awt.event.MouseAdapter;
25 import java.awt.event.MouseEvent;
26
27 import javax.swing.BorderFactory;
28 import javax.swing.JLabel;
29 import javax.swing.JPanel;
30 import javax.swing.JScrollPane;
31 import javax.swing.JTextArea;
32 import javax.swing.border.EmptyBorder;
33
34 import org.xnap.XNap;
35 import org.xnap.gui.component.DefaultDialog;
36 import org.xnap.gui.component.MultiLineLabel;
37 import org.xnap.gui.util.GUIHelper;
38 import org.xnap.gui.util.GridBagHelper;
39 import org.xnap.plugin.PluginInfo;
40
41 public class PluginInfoPanel extends JPanel {
42
43
44
45
46
47 private PluginInfo info;
48 private JLabel authorsLabel;
49 private MultiLineLabel descriptionLabel;
50 private JLabel licenseLabel;
51 private JLabel nameLabel;
52
53
54
55 public PluginInfoPanel()
56 {
57 setLayout(new GridBagLayout());
58
59 nameLabel = GridBagHelper.addLabel(this, "", true);
60 nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
61
62 descriptionLabel = new MultiLineLabel();
63 GridBagHelper.add(this, descriptionLabel);
64
65 GridBagHelper.addLabel(this, XNap.tr("Authors:"));
66 authorsLabel = GridBagHelper.addLabel(this, "", true);
67
68 GridBagHelper.addLabel(this, XNap.tr("License:"));
69 licenseLabel = GridBagHelper.addLabel(this, "", true);
70 licenseLabel.addMouseListener(new LicenseListener());
71 }
72
73
74
75 /***
76 * Updates the plugin info panel.
77 */
78 public void setInfo(PluginInfo info)
79 {
80 this.info = info;
81
82 nameLabel.setText(info.getName() + " " + info.getVersion());
83 descriptionLabel.setText("\n" + info.getDescription() +
84 "\n\n" + info.getLongDescription() + "\n");
85 authorsLabel.setText(info.getAuthors());
86 licenseLabel.setText
87 ("<html><a href=''>" + info.getLicense() + "</a> <br>");
88 }
89
90
91
92 private class LicenseListener extends MouseAdapter
93 {
94 public void mousePressed(MouseEvent e)
95 {
96 DefaultDialog d = new DefaultDialog(DefaultDialog.BUTTON_CLOSE);
97
98
99
100 JTextArea jtextArea = new JTextArea(30, 80);
101 jtextArea.setBorder(new EmptyBorder(5, 5, 5, 5));
102 jtextArea.setEditable (false);
103 jtextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
104 jtextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
105 GUIHelper.showFile(jtextArea, info.getLicenseFilename(),
106 XNap.tr("File {0} not found!",
107 info.getLicenseFilename()));
108
109 d.setTitle(XNap.tr("License"));
110 d.setMainComponent(new JScrollPane(jtextArea));
111 d.pack();
112 d.show(PluginInfoPanel.this);
113 }
114 }
115
116 }