From fab340487cf73f55650da023ec049bcf74e25cbd Mon Sep 17 00:00:00 2001
From: mmk2410
Date: Mon, 13 Jul 2015 17:24:25 +0200
Subject: [PATCH] Localization and better Updatedialog
---
.gitignore | 3 ++-
.../marcelkapfer/c/morseconverter/Main.form | 26 +++++++++++++------
.../marcelkapfer/c/morseconverter/Main.java | 13 ++++++----
.../c/morseconverter/text.properties | 10 +++++--
.../c/morseconverter/text_de.properties | 10 +++++--
.../c/morseconverter/update/UpdateDialog.form | 8 +++---
.../c/morseconverter/update/UpdateDialog.java | 20 +++++++++-----
7 files changed, 61 insertions(+), 29 deletions(-)
diff --git a/.gitignore b/.gitignore
index 4511c9c..4b1eb12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.idea/
out/
-*.iml
\ No newline at end of file
+*.iml
+res/
diff --git a/src/de/marcelkapfer/c/morseconverter/Main.form b/src/de/marcelkapfer/c/morseconverter/Main.form
index b32c9b5..a84d617 100644
--- a/src/de/marcelkapfer/c/morseconverter/Main.form
+++ b/src/de/marcelkapfer/c/morseconverter/Main.form
@@ -99,7 +99,7 @@
-
+
@@ -115,14 +115,9 @@
-
-
-
-
-
-
+
@@ -139,11 +134,26 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/de/marcelkapfer/c/morseconverter/Main.java b/src/de/marcelkapfer/c/morseconverter/Main.java
index fafeded..fbd9172 100644
--- a/src/de/marcelkapfer/c/morseconverter/Main.java
+++ b/src/de/marcelkapfer/c/morseconverter/Main.java
@@ -31,6 +31,7 @@ import de.marcelkapfer.c.morseconverter.update.Update;
import de.marcelkapfer.c.morseconverter.update.UpdateDialog;
import javax.swing.*;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@@ -40,8 +41,8 @@ import java.util.ResourceBundle;
public class Main extends JFrame {
// Version numbers for update check
- public static final int currentVersion = 200;
- public int latestVersion = currentVersion;
+ public static final int currentVersion = 190;
+ public static int latestVersion = currentVersion;
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
public JTabbedPane morseConverterPane;
@@ -51,6 +52,7 @@ public class Main extends JFrame {
private JTextArea inputAreaNormalMorse;
private JTextArea outputAreaNormalMorse;
private JButton updateDialogButton;
+ private JLabel updateAvailable;
// Contains mainly listeners
public Main() {
@@ -70,12 +72,12 @@ public class Main extends JFrame {
});
// Trying to read a file from a server
- latestVersion = Update.getLatestVersion("http://c2/LAB/java/morseconverter/version.txt", currentVersion);
+ latestVersion = Update.getLatestVersion("http://lab.marcel-kapfer.de/writtenmorse/desktop/version.txt", currentVersion);
-
- //TODO To be also shown in the about view
if (currentVersion < latestVersion){
JOptionPane.showMessageDialog(null, resourceBundle.getString("updateAvailable"));
+ updateAvailable.setVisible(true);
+ updateDialogButton.setText(resourceBundle.getString("aboutUpdateAvailableButton"));
}
updateDialogButton.addActionListener(new ActionListener() {
@@ -103,6 +105,7 @@ public class Main extends JFrame {
main.pack();
// Window position and Size
main.setBounds(100, 100, 800, 400);
+ main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png")));
// MAKE IT HAPPEN :D
main.setVisible(true);
}
diff --git a/src/de/marcelkapfer/c/morseconverter/text.properties b/src/de/marcelkapfer/c/morseconverter/text.properties
index eb16473..8b874cb 100644
--- a/src/de/marcelkapfer/c/morseconverter/text.properties
+++ b/src/de/marcelkapfer/c/morseconverter/text.properties
@@ -1,4 +1,6 @@
-about= Developer
Marcel Kapfer
Version
2.0.0 dev
+about=\n\n\n\n\nVersion
1.9.0 alpha\n
\n\nDeveloper
Marcel Michael Kapfer\n
\n\nWebsite
marcel-kapfer.de/writtenmorse\n
\n\nContact
marcelmichaelkapfer@yahoo.co.nz\n
\n\nLicense
GNU GPL v3.0\n
\n\nBug
If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n
\n\nHow to
You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n
\nMissing Code
If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n
\n
\n\n
+aboutUpdateAvailable=Update available
+aboutUpdateAvailableButton=Install Update
inputText=Enter your text
tabAbout=About
tabNormalMorse=Normal Morse
@@ -8,4 +10,8 @@ update-no-connection=The connection to the server was not possible.\nTry again l
update-not-successful=Update not successful
update-successful=Update successful.\nPlease restart the software to activate the changes.
updateAvailable=An Update is available\!\nGo to the 'About' section for more.
-updateButton=Check for updates
\ No newline at end of file
+updateButton=Check for updates
+updateDialogClose=Close
+updateDialogNewVersion=A new version of the Morse Converter is available.
+updateDialogUpToDateText=You're running the latest version.
+updateDialogUpdateQuestion=Do you want to download and install it?
\ No newline at end of file
diff --git a/src/de/marcelkapfer/c/morseconverter/text_de.properties b/src/de/marcelkapfer/c/morseconverter/text_de.properties
index de4327e..a86c11d 100644
--- a/src/de/marcelkapfer/c/morseconverter/text_de.properties
+++ b/src/de/marcelkapfer/c/morseconverter/text_de.properties
@@ -1,4 +1,6 @@
-about= Entwickler\:
Marcel Kapfer
Version
2.0.0 dev
+about=\n\n\n\n\nVersion
1.9.0 alpha\n
\n\nEntwickler
Marcel Michael Kapfer\n
\n\nWebsite
marcel-kapfer.de/writtenmorse\n
\n\nKontakt
marcelmichaelkapfer@yahoo.co.nz\n
\n\nLizenz
GNU GPL v3.0\n
\n\nFehler
Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n
\n\nHow to
Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n
\nFehlender Code
Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n
\n\n\n
+aboutUpdateAvailable=Update verfügbar
+aboutUpdateAvailableButton=Update installieren
inputText=Geben Sie einen Text ein
tabAbout=Über
tabNormalMorse=Normales Morse
@@ -8,4 +10,8 @@ update-no-connection=Eine Verbindung zum Server war nicht möglich\nVersuchen Si
update-not-successful=Update nich erfolgreich
update-successful=Update erfolgreich\nBitte starten Sie die Software neu um die Änderungen zu aktivieren
updateAvailable=Ein Update ist verfügbarr\nMehr in der "Über" Abteilung.
-updateButton=Auf Updates überprüfen
\ No newline at end of file
+updateButton=Auf Updates überprüfen
+updateDialogClose=Schließen
+updateDialogNewVersion=Ein neues Update für den Morse Umwandler ist verfügbar.
+updateDialogUpToDateText=Du verwendest die aktuellste Version.
+updateDialogUpdateQuestion=Willst Du diese herunterladen und installieren?
\ No newline at end of file
diff --git a/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.form b/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.form
index 0f715d3..4a283f2 100644
--- a/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.form
+++ b/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.form
@@ -57,20 +57,20 @@
-
+
-
+
-
+
-
+
diff --git a/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.java b/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.java
index 7ef53ee..e6d466f 100644
--- a/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.java
+++ b/src/de/marcelkapfer/c/morseconverter/update/UpdateDialog.java
@@ -28,21 +28,26 @@ import javax.swing.*;
import java.awt.event.*;
import java.io.File;
import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ResourceBundle;
public class UpdateDialog extends JDialog {
private JPanel contentPane;
- private JButton buttonOK;
- private JButton buttonCancel;
+ public JButton buttonOK;
+ public JButton buttonCancel;
+ public JLabel updateDialogQuestion;
+ public JLabel updateDialogNewVersion;
private ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
public UpdateDialog() {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);
-
+ if(Main.currentVersion == Main.latestVersion){
+ buttonOK.setVisible(false);
+ buttonCancel.setText(resourceBundle.getString("updateDialogClose"));
+ updateDialogNewVersion.setVisible(false);
+ updateDialogQuestion.setText(resourceBundle.getString("updateDialogUpToDateText"));
+ }
buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onOK();
@@ -76,8 +81,8 @@ public class UpdateDialog extends JDialog {
try {
String path = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
path = path.substring(0, path.lastIndexOf(File.separator));
- if(Update.isConnected("http://c2/LAB/java/morseconverter/morseconverter-1.jar")){
- if(Update.update(path + File.separator, "morseconverter-1.jar")){
+ if(Update.isConnected("http://lab.marcel-kapfer.de/writtenmorse/desktop/morseconverter.jar")){
+ if(Update.update(path + File.separator, "morseconverter.jar")){
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-successful"));
} else {
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-not-successful"));
@@ -102,4 +107,5 @@ public class UpdateDialog extends JDialog {
dialog.pack();
dialog.setVisible(true);
}
+
}