Issue#36 improved aboutDialog
This commit is contained in:
parent
bedef25565
commit
49d30e1195
@ -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("");
|
||||
|
@ -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<String> availableLookAndFeels()
|
||||
{
|
||||
List<String> result;
|
||||
@ -100,4 +50,5 @@ public class GUIToolBox
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user