1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ens.transcriptome.doelan.gui;
23
24 import java.awt.Font;
25 import java.awt.event.MouseEvent;
26 import java.awt.event.MouseListener;
27 import java.io.IOException;
28 import java.net.URL;
29
30 import javax.swing.ImageIcon;
31 import javax.swing.JLabel;
32 import javax.swing.JOptionPane;
33 import javax.swing.JPanel;
34 import javax.swing.JTextPane;
35
36 import fr.ens.transcriptome.doelan.DoelanRegistery;
37 import fr.ens.transcriptome.nividic.util.WebBrowser;
38
39 /***
40 * About widget
41 * @author Laurent Jourdren
42 */
43 public class AboutWidget extends JPanel {
44
45 private class WebSiteMouseListener implements MouseListener {
46
47 private String browserPath = DoelanRegistery.getBrowserPath();
48 private String url;
49
50 private void setURL(final String url) {
51 this.url = url;
52 }
53
54 public void mouseClicked(final MouseEvent e) {
55
56 try {
57
58 WebBrowser.launch(browserPath, this.url);
59 } catch (IOException exception) {
60 showMessage("Error while launching navigator : "
61 + exception.getMessage(), true);
62 }
63
64 }
65
66 public void mouseEntered(final MouseEvent e) {
67 }
68
69 public void mouseExited(final MouseEvent e) {
70 }
71
72 public void mousePressed(final MouseEvent e) {
73 }
74
75 public void mouseReleased(final MouseEvent e) {
76 }
77
78 public WebSiteMouseListener(final String url) {
79 setURL(url);
80 }
81
82 }
83
84 /***
85 * Show a message to the user.
86 * @param message Message to show
87 * @param error true if message is an error
88 */
89 private void showMessage(final String message, final boolean error) {
90
91 JOptionPane.showMessageDialog(this, message, error ? "Error" : "Message",
92 error ? JOptionPane.ERROR_MESSAGE : JOptionPane.WARNING_MESSAGE);
93 }
94
95 private void init() {
96
97 setLayout(new java.awt.GridLayout(1, 2));
98
99 URL url = CommonWindow.class.getResource("/files/doelan-300.png");
100 ImageIcon ii = new ImageIcon(url);
101
102 JLabel logoLabel = new JLabel(ii);
103 logoLabel.setToolTipText("Click to view " + DoelanRegistery.getAppName()
104 + " website");
105
106 add(logoLabel);
107
108
109 JTextPane copyrightLabel = new javax.swing.JTextPane();
110
111
112 copyrightLabel.setEditable(false);
113
114 copyrightLabel.setBackground(logoLabel.getBackground());
115
116
117 copyrightLabel.setFont(new Font("SansSerif", Font.PLAIN, 11));
118
119 copyrightLabel.setText(DoelanRegistery.about());
120
121
122 copyrightLabel.setToolTipText("Click to view "
123 + DoelanRegistery.getOrganizationName() + " website");
124
125 add(copyrightLabel);
126
127
128 if (!DoelanRegistery.isAppletMode()) {
129
130 WebSiteMouseListener goProjectWebsiteListener = new WebSiteMouseListener(
131 DoelanRegistery.getAppURL());
132 WebSiteMouseListener goOrganizationWebsiteListener = new WebSiteMouseListener(
133 DoelanRegistery.getOrganizationURL());
134
135 logoLabel.addMouseListener(goProjectWebsiteListener);
136 copyrightLabel.addMouseListener(goOrganizationWebsiteListener);
137 }
138
139 }
140
141
142
143
144
145 /***
146 * Public constructor.
147 */
148 public AboutWidget() {
149 init();
150 }
151
152 }