summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Abraham <andreas.abraham@egiz.gv.at>2018-09-06 14:41:40 (GMT)
committerAndreas Abraham <andreas.abraham@egiz.gv.at>2018-09-06 14:41:40 (GMT)
commit51ac35d46acc9056b515391609d866ac8afbd231 (patch)
tree2a52b09d2b6f519e799c7eedf154a00e22d346d0
parente7376591b62c80a59ad891e8926e831552f42019 (diff)
downloadmocca-51ac35d46acc9056b515391609d866ac8afbd231.zip
mocca-51ac35d46acc9056b515391609d866ac8afbd231.tar.gz
mocca-51ac35d46acc9056b515391609d866ac8afbd231.tar.bz2
new dialog window implementation added
-rw-r--r--utils/src/main/java/at/gv/egiz/upater/NewVersionDialog.java133
1 files changed, 133 insertions, 0 deletions
diff --git a/utils/src/main/java/at/gv/egiz/upater/NewVersionDialog.java b/utils/src/main/java/at/gv/egiz/upater/NewVersionDialog.java
new file mode 100644
index 0000000..2199b7f
--- /dev/null
+++ b/utils/src/main/java/at/gv/egiz/upater/NewVersionDialog.java
@@ -0,0 +1,133 @@
+package at.gv.egiz.upater;
+
+import java.awt.BorderLayout;
+import java.awt.Desktop;
+import java.awt.FlowLayout;
+import java.awt.Image;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JLabel;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+
+
+public class NewVersionDialog extends JDialog {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7913669490723497774L;
+ private final JPanel contentPanel = new JPanel();
+ private final Logger log = LoggerFactory.getLogger(NewVersionDialog.class);
+
+ /**
+ * Launch the application.
+ */
+ public static void main(String[] args) {
+ try {
+ NewVersionDialog dialog = new NewVersionDialog("dummy");
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setVisible(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Create the dialog.
+ * @throws IOException
+ */
+ public NewVersionDialog(String version) throws IOException {
+ setTitle("New Version Available!");
+ setResizable(false);
+ setBounds(100, 100, 330, 180);
+ getContentPane().setLayout(new BorderLayout());
+ contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+ getContentPane().add(contentPanel, BorderLayout.CENTER);
+ contentPanel.setLayout(null);
+ BufferedImage myPicture = ImageIO.read(new File("C:/Users/aabraham/Downloads/information-icon.png"));
+ ImageIcon icon = new ImageIcon(myPicture.getScaledInstance(50, 50, Image.SCALE_SMOOTH));
+ {
+ JLabel lblNewVersion = new JLabel("New Mocca Version " + version + " available.");
+ lblNewVersion.setBounds(76, 36, 228, 27);
+ contentPanel.add(lblNewVersion);
+ }
+ {
+ JLabel lblNewLabel = new JLabel("Open download page now?");
+ lblNewLabel.setBounds(76, 55, 186, 27);
+ contentPanel.add(lblNewLabel);
+ }
+ {
+
+ JLabel lblIcon = new JLabel(icon);
+ lblIcon.setBounds(10, 36, 56, 49);
+ contentPanel.add(lblIcon);
+ }
+ {
+ JPanel buttonPane = new JPanel();
+ buttonPane.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+
+
+ }
+ });
+ buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ getContentPane().add(buttonPane, BorderLayout.SOUTH);
+ {
+ JButton okButton = new JButton("OK");
+ okButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ openLink();
+ }
+ });
+ okButton.setActionCommand("OK");
+ buttonPane.add(okButton);
+ getRootPane().setDefaultButton(okButton);
+ }
+ {
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ close();
+ }
+ });
+ cancelButton.setActionCommand("Cancel");
+ buttonPane.add(cancelButton);
+ }
+ }
+ }
+
+ private void close() {
+ this.dispose();
+ }
+
+
+ private void openLink() {
+ if (Desktop.isDesktopSupported()) {
+ try {
+ Desktop.getDesktop().browse(new URI(Constants.WEBSTART_URL+Constants.MOCCA_STR));
+ } catch (IOException | URISyntaxException e) {
+ log.error(e.getMessage());
+ }
+ }
+ }
+
+}