diff --git a/src/org/dclermonte/siba/gui/AboutDialog.java b/src/org/dclermonte/siba/gui/AboutDialog.java index 51da3ec..c4a4c51 100644 --- a/src/org/dclermonte/siba/gui/AboutDialog.java +++ b/src/org/dclermonte/siba/gui/AboutDialog.java @@ -29,6 +29,7 @@ import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; +import java.util.Locale; import javax.swing.Box; import javax.swing.BoxLayout; @@ -39,7 +40,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextPane; -import org.dclermonte.siba.gui.utils.GUIToolBox; +import org.dclermonte.siba.model.SibaUtils; /** * @@ -108,7 +109,17 @@ public class AboutDialog extends JDialog txtpnSimpleBackupDveloppeur.setBackground(Color.GREEN); txtpnSimpleBackupDveloppeur.setFont(new Font("Dialog", Font.BOLD, 14)); txtpnSimpleBackupDveloppeur.setContentType("text/html"); - txtpnSimpleBackupDveloppeur.setText(GUIToolBox.aboutDialog()); + String resource; + String locale = Locale.getDefault().toString(); + if (locale.equals("fr_FR")) + { + resource = "/org/dclermonte/siba/gui/about_fr.html"; + } + else + { + resource = "/org/dclermonte/siba/gui/about_en.html"; + } + txtpnSimpleBackupDveloppeur.setText(SibaUtils.readResource(resource)); panel.add(txtpnSimpleBackupDveloppeur); { JLabel lblNewLabel = new JLabel(""); diff --git a/src/org/dclermonte/siba/gui/utils/GUIToolBox.java b/src/org/dclermonte/siba/gui/utils/GUIToolBox.java index 2cfe84f..34c1e43 100644 --- a/src/org/dclermonte/siba/gui/utils/GUIToolBox.java +++ b/src/org/dclermonte/siba/gui/utils/GUIToolBox.java @@ -19,19 +19,11 @@ */ package org.dclermonte.siba.gui.utils; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import javax.swing.UIManager; -import org.apache.commons.compress.utils.IOUtils; -import org.dclermonte.siba.gui.AboutDialog; - /** * Some utility * @@ -41,48 +33,6 @@ import org.dclermonte.siba.gui.AboutDialog; public class GUIToolBox { - /** - * - * @return - * @throws IOException - */ - public static String aboutDialog() throws IOException - { - InputStream inputStream = null; - try - { - String result = ""; - String locale = Locale.getDefault().toString(); - String resource = ""; - if (locale.equals("fr_FR")) - { - resource = "/org/dclermonte/siba/gui/about_fr.html"; - } - else if (locale.equals("en_EN")) - { - resource = "/org/dclermonte/siba/gui/about_fr.html"; - } - - URL url = AboutDialog.class.getResource(resource); - inputStream = url.openStream(); - InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - StringBuilder resultBuilder = new StringBuilder(); - int charRead = inputStreamReader.read(); - while (charRead >= 0) - { - resultBuilder.append((char) charRead); - charRead = inputStreamReader.read(); - } - inputStreamReader.close(); - result = resultBuilder.toString(); - return result; - } - finally - { - IOUtils.closeQuietly(inputStream); - } - } - public static List availableLookAndFeels() { List result; @@ -100,4 +50,5 @@ public class GUIToolBox // return result; } + } \ No newline at end of file diff --git a/src/org/dclermonte/siba/model/SibaUtils.java b/src/org/dclermonte/siba/model/SibaUtils.java index d707651..921a8d3 100644 --- a/src/org/dclermonte/siba/model/SibaUtils.java +++ b/src/org/dclermonte/siba/model/SibaUtils.java @@ -25,12 +25,15 @@ import java.io.FileInputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; -import org.apache.commons.compress.utils.IOUtils; +import org.apache.commons.io.IOUtils; +import org.dclermonte.siba.gui.AboutDialog; /** * @@ -222,6 +225,29 @@ public class SibaUtils return result; } + /** + * + * @return + * @throws IOException + */ + public static String readResource(final String resource) throws IOException + { + String result; + InputStream inputStream = null; + try + { + URL url = AboutDialog.class.getResource(resource); + inputStream = url.openStream(); + result = IOUtils.toString(inputStream, (String) null); + inputStream.close(); + } + finally + { + IOUtils.closeQuietly(inputStream); + } + return result; + } + /** * * @param fileToSave