Localization and better Updatedialog
This commit is contained in:
parent
cf65377930
commit
fab340487c
7 changed files with 61 additions and 29 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
.idea/
|
.idea/
|
||||||
out/
|
out/
|
||||||
*.iml
|
*.iml
|
||||||
|
res/
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="4a85e" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="4a85e" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<tabbedpane title-resource-bundle="de/marcelkapfer/c/morseconverter/text" title-key="tabAbout"/>
|
<tabbedpane title-resource-bundle="de/marcelkapfer/c/morseconverter/text" title-key="tabAbout"/>
|
||||||
|
@ -115,14 +115,9 @@
|
||||||
<text resource-bundle="de/marcelkapfer/c/morseconverter/text" key="updateButton"/>
|
<text resource-bundle="de/marcelkapfer/c/morseconverter/text" key="updateButton"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<hspacer id="f1f0d">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
</hspacer>
|
|
||||||
<scrollpane id="ba62c">
|
<scrollpane id="ba62c">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
|
@ -139,11 +134,26 @@
|
||||||
<clientProperties>
|
<clientProperties>
|
||||||
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="false"/>
|
<JEditorPane.honorDisplayProperties class="java.lang.Boolean" value="false"/>
|
||||||
<charset class="java.lang.String" value="UTF-8"/>
|
<charset class="java.lang.String" value="UTF-8"/>
|
||||||
<html.disable class="java.lang.Boolean" value="false"/>
|
<html.disable class="java.lang.Boolean" value="true"/>
|
||||||
</clientProperties>
|
</clientProperties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
|
<component id="ebd0c" class="javax.swing.JLabel" binding="updateAvailable">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<foreground color="-4517120"/>
|
||||||
|
<text resource-bundle="de/marcelkapfer/c/morseconverter/text" key="aboutUpdateAvailable"/>
|
||||||
|
<visible value="false"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<hspacer id="8aa16">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</hspacer>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -31,6 +31,7 @@ import de.marcelkapfer.c.morseconverter.update.Update;
|
||||||
import de.marcelkapfer.c.morseconverter.update.UpdateDialog;
|
import de.marcelkapfer.c.morseconverter.update.UpdateDialog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
|
@ -40,8 +41,8 @@ import java.util.ResourceBundle;
|
||||||
public class Main extends JFrame {
|
public class Main extends JFrame {
|
||||||
|
|
||||||
// Version numbers for update check
|
// Version numbers for update check
|
||||||
public static final int currentVersion = 200;
|
public static final int currentVersion = 190;
|
||||||
public int latestVersion = currentVersion;
|
public static int latestVersion = currentVersion;
|
||||||
|
|
||||||
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
|
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
|
||||||
public JTabbedPane morseConverterPane;
|
public JTabbedPane morseConverterPane;
|
||||||
|
@ -51,6 +52,7 @@ public class Main extends JFrame {
|
||||||
private JTextArea inputAreaNormalMorse;
|
private JTextArea inputAreaNormalMorse;
|
||||||
private JTextArea outputAreaNormalMorse;
|
private JTextArea outputAreaNormalMorse;
|
||||||
private JButton updateDialogButton;
|
private JButton updateDialogButton;
|
||||||
|
private JLabel updateAvailable;
|
||||||
|
|
||||||
// Contains mainly listeners
|
// Contains mainly listeners
|
||||||
public Main() {
|
public Main() {
|
||||||
|
@ -70,12 +72,12 @@ public class Main extends JFrame {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Trying to read a file from a server
|
// 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){
|
if (currentVersion < latestVersion){
|
||||||
JOptionPane.showMessageDialog(null, resourceBundle.getString("updateAvailable"));
|
JOptionPane.showMessageDialog(null, resourceBundle.getString("updateAvailable"));
|
||||||
|
updateAvailable.setVisible(true);
|
||||||
|
updateDialogButton.setText(resourceBundle.getString("aboutUpdateAvailableButton"));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDialogButton.addActionListener(new ActionListener() {
|
updateDialogButton.addActionListener(new ActionListener() {
|
||||||
|
@ -103,6 +105,7 @@ public class Main extends JFrame {
|
||||||
main.pack();
|
main.pack();
|
||||||
// Window position and Size
|
// Window position and Size
|
||||||
main.setBounds(100, 100, 800, 400);
|
main.setBounds(100, 100, 800, 400);
|
||||||
|
main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png")));
|
||||||
// MAKE IT HAPPEN :D
|
// MAKE IT HAPPEN :D
|
||||||
main.setVisible(true);
|
main.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
about=<html> <head> </head> <body> <p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px"> <b>Developer</b><br>Marcel Kapfer </p> <p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px"> <b>Version</b><br>2.0.0 dev </p> </body> </html>
|
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Developer</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Contact</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>License</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Bug</b><br>If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Missing Code</b><br>If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n</p>\n</p>\n</body>\n</html>
|
||||||
|
aboutUpdateAvailable=Update available
|
||||||
|
aboutUpdateAvailableButton=Install Update
|
||||||
inputText=Enter your text
|
inputText=Enter your text
|
||||||
tabAbout=About
|
tabAbout=About
|
||||||
tabNormalMorse=Normal Morse
|
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-not-successful=Update not successful
|
||||||
update-successful=Update successful.\nPlease restart the software to activate the changes.
|
update-successful=Update successful.\nPlease restart the software to activate the changes.
|
||||||
updateAvailable=An Update is available\!\nGo to the 'About' section for more.
|
updateAvailable=An Update is available\!\nGo to the 'About' section for more.
|
||||||
updateButton=Check for updates
|
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?
|
|
@ -1,4 +1,6 @@
|
||||||
about=<html> <head> </head> <body> <p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px"> <b>Entwickler\:</b><br>Marcel Kapfer </p> <p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px"> <b>Version</b><br>2.0.0 dev </p> </body> </html>
|
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Entwickler</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Kontakt</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Lizenz</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehler</b><br>Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehlender Code</b><br>Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n</p>\n</p>\n</body>\n</html>
|
||||||
|
aboutUpdateAvailable=Update verfügbar
|
||||||
|
aboutUpdateAvailableButton=Update installieren
|
||||||
inputText=Geben Sie einen Text ein
|
inputText=Geben Sie einen Text ein
|
||||||
tabAbout=Über
|
tabAbout=Über
|
||||||
tabNormalMorse=Normales Morse
|
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-not-successful=Update nich erfolgreich
|
||||||
update-successful=Update erfolgreich\nBitte starten Sie die Software neu um die Änderungen zu aktivieren
|
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.
|
updateAvailable=Ein Update ist verfügbarr\nMehr in der "Über" Abteilung.
|
||||||
updateButton=Auf Updates überprüfen
|
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?
|
|
@ -57,20 +57,20 @@
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<component id="4147a" class="javax.swing.JLabel">
|
<component id="4147a" class="javax.swing.JLabel" binding="updateDialogNewVersion">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="A new version of the Morse Converter is available."/>
|
<text resource-bundle="de/marcelkapfer/c/morseconverter/text" key="updateDialogNewVersion"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="89f1c" class="javax.swing.JLabel">
|
<component id="89f1c" class="javax.swing.JLabel" binding="updateDialogQuestion">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Do you want to download and install it?"/>
|
<text resource-bundle="de/marcelkapfer/c/morseconverter/text" key="updateDialogUpdateQuestion"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -28,21 +28,26 @@ import javax.swing.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class UpdateDialog extends JDialog {
|
public class UpdateDialog extends JDialog {
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private JButton buttonOK;
|
public JButton buttonOK;
|
||||||
private JButton buttonCancel;
|
public JButton buttonCancel;
|
||||||
|
public JLabel updateDialogQuestion;
|
||||||
|
public JLabel updateDialogNewVersion;
|
||||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
|
private ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
|
||||||
|
|
||||||
public UpdateDialog() {
|
public UpdateDialog() {
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
getRootPane().setDefaultButton(buttonOK);
|
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() {
|
buttonOK.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
onOK();
|
onOK();
|
||||||
|
@ -76,8 +81,8 @@ public class UpdateDialog extends JDialog {
|
||||||
try {
|
try {
|
||||||
String path = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
|
String path = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
|
||||||
path = path.substring(0, path.lastIndexOf(File.separator));
|
path = path.substring(0, path.lastIndexOf(File.separator));
|
||||||
if(Update.isConnected("http://c2/LAB/java/morseconverter/morseconverter-1.jar")){
|
if(Update.isConnected("http://lab.marcel-kapfer.de/writtenmorse/desktop/morseconverter.jar")){
|
||||||
if(Update.update(path + File.separator, "morseconverter-1.jar")){
|
if(Update.update(path + File.separator, "morseconverter.jar")){
|
||||||
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-successful"));
|
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-successful"));
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-not-successful"));
|
JOptionPane.showMessageDialog(null, resourceBundle.getString("update-not-successful"));
|
||||||
|
@ -102,4 +107,5 @@ public class UpdateDialog extends JDialog {
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue