2008-11-03 05:56:57 -05:00
|
|
|
|
package davmail.ui;
|
2008-10-19 17:00:22 -04:00
|
|
|
|
|
2008-11-03 11:07:13 -05:00
|
|
|
|
import davmail.DavGateway;
|
2009-04-03 03:38:31 -04:00
|
|
|
|
import davmail.ui.tray.DavGatewayTray;
|
2008-10-19 17:00:22 -04:00
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import javax.swing.event.HyperlinkEvent;
|
|
|
|
|
import javax.swing.event.HyperlinkListener;
|
|
|
|
|
import javax.swing.text.html.HTMLEditorKit;
|
|
|
|
|
import javax.swing.text.html.StyleSheet;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.io.IOException;
|
2008-11-07 13:28:16 -05:00
|
|
|
|
import java.net.URISyntaxException;
|
2009-02-11 08:25:16 -05:00
|
|
|
|
import java.net.URL;
|
2008-10-19 17:00:22 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* About frame
|
|
|
|
|
*/
|
|
|
|
|
public class AboutFrame extends JFrame {
|
2008-12-17 10:31:08 -05:00
|
|
|
|
private final JEditorPane jEditorPane;
|
2008-11-04 05:38:31 -05:00
|
|
|
|
|
2008-10-19 17:00:22 -04:00
|
|
|
|
public AboutFrame() {
|
|
|
|
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
2008-11-03 05:56:57 -05:00
|
|
|
|
setTitle("About DavMail Gateway");
|
|
|
|
|
setIconImage(DavGatewayTray.getFrameIcon());
|
2008-10-19 17:00:22 -04:00
|
|
|
|
try {
|
|
|
|
|
JLabel imageLabel = new JLabel();
|
|
|
|
|
ClassLoader classloader = this.getClass().getClassLoader();
|
|
|
|
|
URL imageUrl = classloader.getResource("tray32.png");
|
|
|
|
|
Image iconImage = ImageIO.read(imageUrl);
|
|
|
|
|
ImageIcon icon = new ImageIcon(iconImage);
|
|
|
|
|
imageLabel.setIcon(icon);
|
|
|
|
|
JPanel imagePanel = new JPanel();
|
|
|
|
|
imagePanel.add(imageLabel);
|
|
|
|
|
add("West", imagePanel);
|
|
|
|
|
} catch (IOException e) {
|
2008-10-20 07:05:35 -04:00
|
|
|
|
DavGatewayTray.error("Unable to create icon", e);
|
2008-10-19 17:00:22 -04:00
|
|
|
|
}
|
2008-11-04 05:38:31 -05:00
|
|
|
|
|
2009-02-11 08:25:16 -05:00
|
|
|
|
jEditorPane = new JEditorPane();
|
|
|
|
|
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
|
|
|
|
|
StyleSheet stylesheet = htmlEditorKit.getStyleSheet();
|
2008-10-19 17:00:22 -04:00
|
|
|
|
stylesheet.addRule("body { font-size:small;font-family: " + jEditorPane.getFont().getFamily() + "}");
|
2009-02-11 08:25:16 -05:00
|
|
|
|
jEditorPane.setEditorKit(htmlEditorKit);
|
|
|
|
|
jEditorPane.setContentType("text/html");
|
|
|
|
|
jEditorPane.setText(getContent());
|
2008-10-19 17:00:22 -04:00
|
|
|
|
|
|
|
|
|
jEditorPane.setEditable(false);
|
|
|
|
|
jEditorPane.setOpaque(false);
|
|
|
|
|
jEditorPane.addHyperlinkListener(new HyperlinkListener() {
|
|
|
|
|
public void hyperlinkUpdate(HyperlinkEvent hle) {
|
|
|
|
|
if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
|
|
|
|
|
try {
|
2008-11-07 13:28:16 -05:00
|
|
|
|
DesktopBrowser.browse(hle.getURL().toURI());
|
|
|
|
|
} catch (URISyntaxException e) {
|
2008-10-20 07:05:35 -04:00
|
|
|
|
DavGatewayTray.error("Unable to open link", e);
|
2008-10-19 17:00:22 -04:00
|
|
|
|
}
|
2008-11-07 13:28:16 -05:00
|
|
|
|
dispose();
|
2008-10-19 17:00:22 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel mainPanel = new JPanel();
|
|
|
|
|
mainPanel.add(jEditorPane);
|
|
|
|
|
add("Center", mainPanel);
|
|
|
|
|
|
|
|
|
|
JPanel buttonPanel = new JPanel();
|
|
|
|
|
JButton ok = new JButton("OK");
|
|
|
|
|
ActionListener close = new ActionListener() {
|
|
|
|
|
public void actionPerformed(ActionEvent evt) {
|
|
|
|
|
dispose();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
ok.addActionListener(close);
|
|
|
|
|
|
|
|
|
|
buttonPanel.add(ok);
|
|
|
|
|
|
|
|
|
|
add("South", buttonPanel);
|
|
|
|
|
|
|
|
|
|
pack();
|
|
|
|
|
setResizable(false);
|
|
|
|
|
// center frame
|
|
|
|
|
setLocation(getToolkit().getScreenSize().width / 2 -
|
|
|
|
|
getSize().width / 2,
|
|
|
|
|
getToolkit().getScreenSize().height / 2 -
|
|
|
|
|
getSize().height / 2);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-17 10:31:08 -05:00
|
|
|
|
String getContent() {
|
2008-11-04 05:38:31 -05:00
|
|
|
|
Package davmailPackage = DavGateway.class.getPackage();
|
|
|
|
|
StringBuilder buffer = new StringBuilder();
|
|
|
|
|
buffer.append("<html><b>DavMail Gateway</b><br>");
|
|
|
|
|
buffer.append("By Micka<6B>l Guessant<br><br>");
|
|
|
|
|
String currentVersion = davmailPackage.getImplementationVersion();
|
|
|
|
|
if (currentVersion != null) {
|
|
|
|
|
buffer.append("Current version: ").append(currentVersion).append("<br>");
|
|
|
|
|
}
|
|
|
|
|
String releasedVersion = DavGateway.getReleasedVersion();
|
|
|
|
|
if (currentVersion != null && releasedVersion != null && currentVersion.compareTo(releasedVersion) < 0) {
|
|
|
|
|
buffer.append("Latest version available: ").append(releasedVersion).append("<br>" +
|
|
|
|
|
"A new version of DavMail Gateway is available.<br>" +
|
|
|
|
|
"<a href=\"http://sourceforge.net/project/platformdownload.php?group_id=184600\">Download latest version</a><br>");
|
|
|
|
|
}
|
|
|
|
|
buffer.append("<br>Help and setup instructions available at:<br>" +
|
|
|
|
|
"<a href=\"http://davmail.sourceforge.net\">http://davmail.sourceforge.net</a><br>" +
|
|
|
|
|
"<br>" +
|
|
|
|
|
"To send comments or report bugs, <br>use <a href=\"http://sourceforge.net/tracker/?group_id=184600\">" +
|
|
|
|
|
"DavMail Sourceforge trackers</a><br>" +
|
|
|
|
|
"or contact me at <a href=\"mailto:mguessan@free.fr\">mguessan@free.fr</a>" +
|
|
|
|
|
"</html>");
|
|
|
|
|
return buffer.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-03 11:07:13 -05:00
|
|
|
|
|
2008-11-04 05:38:31 -05:00
|
|
|
|
public void update() {
|
|
|
|
|
jEditorPane.setText(getContent());
|
|
|
|
|
pack();
|
|
|
|
|
}
|
2008-11-03 11:07:13 -05:00
|
|
|
|
|
2008-10-19 17:00:22 -04:00
|
|
|
|
}
|