mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 11:12:22 -05:00
Add an about frame with contact and version information
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@145 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
d56022aa6d
commit
4bbbde0de5
10
build.xml
10
build.xml
@ -38,7 +38,15 @@
|
||||
</taskdef>
|
||||
<delete dir="dist"/>
|
||||
<mkdir dir="dist"/>
|
||||
<jar basedir="target/classes" destfile="dist/davmail.jar"/>
|
||||
<jar basedir="target/classes" destfile="dist/davmail.jar">
|
||||
<manifest>
|
||||
<section name="davmail/">
|
||||
<attribute name="Implementation-Title" value="DavMail Gateway"/>
|
||||
<attribute name="Implementation-Version" value="${version}"/>
|
||||
<attribute name="Implementation-Vendor" value="Mickael Guessant"/>
|
||||
</section>
|
||||
</manifest>
|
||||
</jar>
|
||||
<copy todir="dist/lib">
|
||||
<fileset dir="lib">
|
||||
<include name="*.jar"/>
|
||||
|
102
src/java/davmail/AboutFrame.java
Normal file
102
src/java/davmail/AboutFrame.java
Normal file
@ -0,0 +1,102 @@
|
||||
package davmail;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
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;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* About frame
|
||||
*/
|
||||
public class AboutFrame extends JFrame {
|
||||
protected static final Logger LOGGER = Logger.getLogger(AboutFrame.class);
|
||||
|
||||
public AboutFrame() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setTitle("About DavMail");
|
||||
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) {
|
||||
LOGGER.error("Unable to create icon", e);
|
||||
}
|
||||
Package davmailPackage = this.getClass().getPackage();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("<html><b>DavMail Gateway</b><br/>");
|
||||
String version = davmailPackage.getImplementationVersion();
|
||||
if (version != null) {
|
||||
buffer.append("<b>Version ").append(version).append("</b><br/>");
|
||||
}
|
||||
buffer.append("By Mickaël Guessant<br/>" +
|
||||
"<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>");
|
||||
JEditorPane jEditorPane = new JEditorPane("text/html", buffer.toString());
|
||||
StyleSheet stylesheet = ((HTMLEditorKit) jEditorPane.getEditorKit()).getStyleSheet();
|
||||
stylesheet.addRule("body { font-size:small;font-family: " + jEditorPane.getFont().getFamily() + "}");
|
||||
|
||||
jEditorPane.setEditable(false);
|
||||
jEditorPane.setOpaque(false);
|
||||
jEditorPane.addHyperlinkListener(new HyperlinkListener() {
|
||||
public void hyperlinkUpdate(HyperlinkEvent hle) {
|
||||
if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
|
||||
try {
|
||||
Desktop desktop = Desktop.getDesktop();
|
||||
desktop.browse(hle.getURL().toURI());
|
||||
dispose();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Unable to open link", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -17,6 +17,7 @@ public class SettingsFrame extends JFrame {
|
||||
}
|
||||
|
||||
public SettingsFrame() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setTitle("DavMail Settings");
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
@ -78,6 +79,7 @@ public class SettingsFrame extends JFrame {
|
||||
tabbedPane.add("Main", mainPanel);
|
||||
|
||||
JPanel advancedPanel = new JPanel();
|
||||
advancedPanel.setLayout(new BorderLayout());
|
||||
|
||||
JPanel networkSettingsPanel = new JPanel(new GridLayout(2, 2));
|
||||
networkSettingsPanel.setBorder(BorderFactory.createTitledBorder("Network settings"));
|
||||
@ -92,8 +94,8 @@ public class SettingsFrame extends JFrame {
|
||||
addSettingComponent(networkSettingsPanel, "Bind address: ", bindAddressField);
|
||||
addSettingComponent(networkSettingsPanel, "Allow Remote Connections: ", allowRemoteField);
|
||||
|
||||
advancedPanel.add(networkSettingsPanel);
|
||||
|
||||
advancedPanel.add("North", networkSettingsPanel);
|
||||
|
||||
tabbedPane.add("Advanced", advancedPanel);
|
||||
|
||||
add("Center", tabbedPane);
|
||||
@ -116,7 +118,7 @@ public class SettingsFrame extends JFrame {
|
||||
Settings.setProperty("davmail.proxyUser", httpProxyUserField.getText());
|
||||
Settings.setProperty("davmail.proxyPassword", httpProxyPasswordField.getText());
|
||||
Settings.save();
|
||||
setVisible(false);
|
||||
dispose();
|
||||
// restart listeners with new config
|
||||
DavGateway.start();
|
||||
}
|
||||
@ -142,7 +144,7 @@ public class SettingsFrame extends JFrame {
|
||||
httpProxyPortField.setText(Settings.getProperty("davmail.proxyPort"));
|
||||
httpProxyUserField.setText(Settings.getProperty("davmail.proxyUser"));
|
||||
httpProxyPasswordField.setText(Settings.getProperty("davmail.proxyPassword"));
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2,6 +2,7 @@ package davmail.tray;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.SettingsFrame;
|
||||
import davmail.AboutFrame;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.apache.log4j.lf5.LF5Appender;
|
||||
@ -82,6 +83,20 @@ public class AwtGatewayTray implements DavGatewayTrayInterface {
|
||||
image2 = Toolkit.getDefaultToolkit().getImage(imageUrl2);
|
||||
// create a popup menu
|
||||
PopupMenu popup = new PopupMenu();
|
||||
|
||||
final AboutFrame aboutFrame = new AboutFrame();
|
||||
aboutFrame.setIconImage(image);
|
||||
// create an action settingsListener to listen for settings action executed on the tray icon
|
||||
ActionListener aboutListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
aboutFrame.setVisible(true);
|
||||
}
|
||||
};
|
||||
// create menu item for the default action
|
||||
MenuItem aboutItem = new MenuItem("About...");
|
||||
aboutItem.addActionListener(aboutListener);
|
||||
popup.add(aboutItem);
|
||||
|
||||
final SettingsFrame settingsFrame = new SettingsFrame();
|
||||
settingsFrame.setIconImage(image);
|
||||
// create an action settingsListener to listen for settings action executed on the tray icon
|
||||
|
@ -2,6 +2,7 @@ package davmail.tray;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.SettingsFrame;
|
||||
import davmail.AboutFrame;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.apache.log4j.lf5.LF5Appender;
|
||||
@ -145,6 +146,23 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem aboutItem = new MenuItem(popup, SWT.PUSH);
|
||||
aboutItem.setText("About...");
|
||||
final AboutFrame aboutFrame = new AboutFrame();
|
||||
if (awtImage != null) {
|
||||
aboutFrame.setIconImage(awtImage);
|
||||
}
|
||||
aboutItem.addListener(SWT.Selection, new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
display.asyncExec(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
aboutFrame.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
final SettingsFrame settingsFrame = new SettingsFrame();
|
||||
if (awtImage != null) {
|
||||
settingsFrame.setIconImage(awtImage);
|
||||
@ -205,10 +223,12 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
public void handleEvent(Event event) {
|
||||
shell.dispose();
|
||||
|
||||
if (image != null)
|
||||
if (image != null) {
|
||||
image.dispose();
|
||||
if (image2 != null)
|
||||
}
|
||||
if (image2 != null) {
|
||||
image2.dispose();
|
||||
}
|
||||
display.dispose();
|
||||
|
||||
//noinspection CallToSystemExit
|
||||
@ -222,14 +242,17 @@ public class SwtGatewayTray implements DavGatewayTrayInterface {
|
||||
}
|
||||
|
||||
while (!shell.isDisposed()) {
|
||||
if (!display.readAndDispatch())
|
||||
if (!display.readAndDispatch()) {
|
||||
display.sleep();
|
||||
}
|
||||
}
|
||||
|
||||
if (image != null)
|
||||
if (image != null) {
|
||||
image.dispose();
|
||||
if (image2 != null)
|
||||
}
|
||||
if (image2 != null) {
|
||||
image2.dispose();
|
||||
}
|
||||
display.dispose();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user