Issue#36 new aboutDialog

This commit is contained in:
Didier Clermonté 2016-07-27 22:12:06 +02:00
parent 5d83fc61c9
commit 3c9bd895e6
3 changed files with 51 additions and 31 deletions

View File

@ -40,8 +40,6 @@ import javax.swing.JPanel;
import javax.swing.JTextPane;
import org.dclermonte.siba.gui.utils.GUIToolBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
@ -51,7 +49,6 @@ import org.slf4j.LoggerFactory;
public class AboutDialog extends JDialog
{
private static final long serialVersionUID = 8868109575782482455L;
private static final Logger logger = LoggerFactory.getLogger(AboutDialog.class);
/**
* This is the constructor for the dialog.
@ -122,20 +119,4 @@ public class AboutDialog extends JDialog
}
/**
* This method Launch the application.
*/
public static void view(final String string)
{
try
{
AboutDialog dialog = new AboutDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
}
catch (Exception exception)
{
logger.error("Exception ", exception);
}
}
}

View File

@ -32,10 +32,12 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
@ -273,7 +275,18 @@ public class SibaGUI
@Override
public void actionPerformed(final ActionEvent e)
{
AboutDialog.view("");
AboutDialog dialog;
try
{
dialog = new AboutDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
}
catch (IOException exception)
{
logger.error("Exception ", exception);
}
}
});
mnNewMenu.add(mntmMenuItemAbout);

View File

@ -19,16 +19,17 @@
*/
package org.dclermonte.siba.gui.utils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Locale;
import javax.swing.UIManager;
import org.apache.commons.io.FileUtils;
import org.apache.commons.compress.utils.IOUtils;
import org.dclermonte.siba.gui.AboutDialog;
/**
@ -39,7 +40,6 @@ import org.dclermonte.siba.gui.AboutDialog;
*/
public class GUIToolBox
{
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
/**
*
@ -48,13 +48,39 @@ public class GUIToolBox
*/
public static String aboutDialog() throws IOException
{
String result = null;
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";
}
String about = BUNDLE.getString("AboutDialog");
File aboutFile = new File(AboutDialog.class.getResource("/org/dclermonte/siba/gui/" + about).getFile());
result = FileUtils.readFileToString(aboutFile, (Charset) null);
return result;
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()