Issue#36 new aboutDialog
This commit is contained in:
parent
5d83fc61c9
commit
3c9bd895e6
|
@ -40,8 +40,6 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JTextPane;
|
import javax.swing.JTextPane;
|
||||||
|
|
||||||
import org.dclermonte.siba.gui.utils.GUIToolBox;
|
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
|
public class AboutDialog extends JDialog
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 8868109575782482455L;
|
private static final long serialVersionUID = 8868109575782482455L;
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AboutDialog.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the constructor for the dialog.
|
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,12 @@ import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.JMenuBar;
|
import javax.swing.JMenuBar;
|
||||||
|
@ -273,7 +275,18 @@ public class SibaGUI
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(final ActionEvent e)
|
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);
|
mnNewMenu.add(mntmMenuItemAbout);
|
||||||
|
|
|
@ -19,16 +19,17 @@
|
||||||
*/
|
*/
|
||||||
package org.dclermonte.siba.gui.utils;
|
package org.dclermonte.siba.gui.utils;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
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.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ResourceBundle;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.compress.utils.IOUtils;
|
||||||
import org.dclermonte.siba.gui.AboutDialog;
|
import org.dclermonte.siba.gui.AboutDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +40,6 @@ import org.dclermonte.siba.gui.AboutDialog;
|
||||||
*/
|
*/
|
||||||
public class GUIToolBox
|
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
|
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");
|
URL url = AboutDialog.class.getResource(resource);
|
||||||
File aboutFile = new File(AboutDialog.class.getResource("/org/dclermonte/siba/gui/" + about).getFile());
|
inputStream = url.openStream();
|
||||||
result = FileUtils.readFileToString(aboutFile, (Charset) null);
|
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
|
||||||
|
StringBuilder resultBuilder = new StringBuilder();
|
||||||
return result;
|
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()
|
public static List<String> availableLookAndFeels()
|
||||||
|
|
Loading…
Reference in New Issue